Commit Graph

4516 Commits

Author SHA1 Message Date
Hyrum Wright e546b53e01 [clang-tidy] Rename time lookup functions; NFC
llvm-svn: 352964
2019-02-02 19:57:37 +00:00
Eric Liu 44d6f9e131 [clangd] Fix heap-use-after-free after r352868
llvm-svn: 352957
2019-02-02 10:35:39 +00:00
Sam McCall 0dbab7feca [Clangd] textDocument/definition and textDocument/declaration "bounce" between definition and declaration location when they are distinct.
Summary:
This helps minimize the disruption of not returning declarations as part of
a find-definition response (r352864).

Reviewers: hokein

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, ilya-biryukov

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57580

llvm-svn: 352953
2019-02-02 05:56:00 +00:00
Sam McCall 9c8f432617 [clangd] Expose SelectionTree to code tweaks, and use it for swap if branches.
Summary:
This reduces the per-check implementation burden and redundant work.
It also makes checks range-aware by default (treating the commonAncestor
as if it were a point selection should be good baseline behavior).

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57570

llvm-svn: 352876
2019-02-01 15:09:47 +00:00
Sam McCall 2048f22892 [clangd] Lib to compute and represent selection under cursor.
Summary:
The primary problem this solves is to expose the codeAction selection to
AST-based refactorings in a way that makes it easy and efficient for them to
bind to the right parts of the AST.

It should also allow us to make XRefs based features (textDocument/definition)
more robust, more easily implement textDocument/typeDefinition etc.
As an example, template parameter references can be identified without special
handling.
There should be slight speedup too: we can prune most of the AST traversal
in most cases.

Elephant in the room: this is similar-but-different to Tooling/Refactoring/ASTSelection.
That captures a smaller set of AST nodes, has a slightly different way of
representing selections, and generally has mare features and does more work.
The overall shape is pretty similar, and yet I can't quite get to behave as I
expect.

Reviewers: ilya-biryukov, kadircet

Subscribers: mgorny, ioeric, MaskRay, jkorous, mgrang, arphaman

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57562

llvm-svn: 352875
2019-02-01 15:09:41 +00:00
Sam McCall 3186e3ceb8 [clangd] Lib to compute and represent selection under cursor.
Summary:
The primary problem this solves is to expose the codeAction selection to
AST-based refactorings in a way that makes it easy and efficient for them to
bind to the right parts of the AST.

It should also allow us to make XRefs based features (textDocument/definition)
more robust, more easily implement textDocument/typeDefinition etc.
As an example, template parameter references can be identified without special
handling.
There should be slight speedup too: we can prune most of the AST traversal
in most cases.

Elephant in the room: this is similar-but-different to Tooling/Refactoring/ASTSelection.
That captures a smaller set of AST nodes, has a slightly different way of
representing selections, and generally has mare features and does more work.
The overall shape is pretty similar, and yet I can't quite get to behave as I
expect.

Reviewers: ilya-biryukov, kadircet

Subscribers: mgorny, ioeric, MaskRay, jkorous, mgrang, arphaman

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57562

llvm-svn: 352874
2019-02-01 15:05:11 +00:00
Sam McCall a4cf26b499 [clangd] Penalize file-scope symbols in the ranking for non-completion queries
Patch by Nathan Ridge!

Differential Revision: https://reviews.llvm.org/D56653

llvm-svn: 352868
2019-02-01 13:07:37 +00:00
Sam McCall 866ba2c924 [clangd] Implement textDocument/declaration from LSP 3.14
Summary:
LSP now reflects the declaration/definition distinction.

Language server changes:
 - textDocument/definition now returns a definition if one is found, otherwise
   the declaration. It no longer returns declaration + definition if they are
   distinct.
 - textDocument/declaration returns the best declaration we can find.
 - For macros, the active macro definition is returned for both methods.
 - For include directive, the top of the target file is returned for both.
There doesn't appear to be a discovery mechanism (we can't return everything to
clients that only know about definition), so this changes existing behavior.
In practice, it should greatly reduce the fraction of the time we need to show
the user a menu of options.

C++ API changes:
 - findDefinitions is replaced by locateSymbolAt, which returns a
   vector<LocatedSymbol> - one for each symbol under the cursor.
 - this contains the preferred declaration, the definition (if found), and
   the symbol name
This API enables some potentially-neat extensions, like swapping between decl
and def, and exposing the symbol name to the UI in the case of multiple symbols.

Reviewers: hokein

Subscribers: ilya-biryukov, javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D57388

llvm-svn: 352864
2019-02-01 11:26:13 +00:00
Sam McCall b34fca6b47 [clangd] Use delimited style to make life easier for the fuzzer
llvm-svn: 352863
2019-02-01 11:20:20 +00:00
Sam McCall 554644e512 [clangd] Unbreak fuzzer target
llvm-svn: 352857
2019-02-01 11:09:06 +00:00
Roman Lebedev 3440c33989 [clangd] clangDaemonTweaks - fix -DBUILD_SHARED_LIBS=ON build
Followup for rL352841.

llvm-svn: 352843
2019-02-01 08:58:37 +00:00
Roman Lebedev 11f7969256 [clangd] Fix -DBUILD_SHARED_LIBS=ON build - SwapIfBranches needs clangAST.
Else, fails with:

[1/2] Linking CXX executable bin/clangd
FAILED: bin/clangd
: && /usr/bin/g++  -pipe -O2 -g0 -UNDEBUG -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -pipe -O2 -g0 -UNDEBUG  -fuse-ld=lld -Wl,--color-diagnostics -Wl,-allow-shlib-undefined     -Wl,-O3 -Wl,--gc-sections tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/SwapIfBranches.cpp.o tools/clang/tools/extra/clangd/tool/CMakeFiles/clangd.dir/ClangdMain.cpp.o  -o bin/clangd  -Wl,-rpath,"\$ORIGIN/../lib" lib/libLLVMSupport.so.9svn -lpthread lib/libclangBasic.so.9svn lib/libclangTidy.so.9svn lib/libclangDaemon.so.9svn lib/libclangFormat.so.9svn lib/libclangFrontend.so.9svn lib/libclangSema.so.9svn lib/libclangTooling.so.9svn lib/libclangToolingCore.so.9svn && :
ld.lld: error: undefined symbol: clang::FunctionDecl::getBody(clang::FunctionDecl const*&) const
>>> referenced by SwapIfBranches.cpp
>>>               tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/SwapIfBranches.cpp.o:(clang::FunctionDecl::getBody() const)

and so on.

llvm-svn: 352841
2019-02-01 08:23:23 +00:00
Sam McCall 8a32f3b7a0 [clangd] Fix crash in applyTweak, remove TweakID alias.
Strings are complicated, giving them opaque names makes us forget
they're complicated.

llvm-svn: 352837
2019-02-01 05:41:50 +00:00
Ilya Biryukov 4399878082 [clangd] A code action to swap branches of an if statement
Reviewers: sammccall

Reviewed By: sammccall

Subscribers: llvm-commits, mgorny, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D56611

llvm-svn: 352796
2019-01-31 21:30:05 +00:00
Eric Liu 00eaf6732e [clangd] Append "(fix available)" to diagnostic message when fixes are present.
Summary:
This would make diagnostic fixits more discoverable, especially for
plugins like YCM.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D57509

llvm-svn: 352764
2019-01-31 16:09:25 +00:00
Jonas Toth 9b127421b6 [clang-tidy] refactor bugprone-exception-escape analysis into class
Summary:
The check `bugprone-exception-escape` does an AST-based analysis to determine
if a function might throw an exception and warns based on that information.
The analysis part is refactored into a standalone class similiar to
`ExprMutAnalyzer` that is generally useful.
I intent to use that class in a new check to automatically introduce `noexcept`
if possible.

Reviewers: aaron.ballman, alexfh, hokein, baloghadamsoftware, lebedev.ri

Reviewed By: baloghadamsoftware, lebedev.ri

Subscribers: lebedev.ri, mgorny, xazax.hun, rnkovacs, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D57100

llvm-svn: 352741
2019-01-31 10:46:37 +00:00
Ilya Biryukov c6ed77812b [clangd] Drop fixes if replying with tweaks resulted in an error
This should not happen in normal operation, as it implies that the diagnostics
with some available fixes were produced but the AST is invalid.
Moreover, the code had an error: always returned code actions ignoring the
SupportsCodeAction capability and writing a test for this is impossible,
since this can only happen due to programmer's error rather than invalid inputs.

llvm-svn: 352624
2019-01-30 14:24:17 +00:00
Ilya Biryukov c9409c6d86 [clangd] Fix a use after move
Introduced in r352494.

llvm-svn: 352612
2019-01-30 09:39:01 +00:00
James Y Knight 5d71fc5d7b Adjust documentation for git migration.
This fixes most references to the paths:
 llvm.org/svn/
 llvm.org/git/
 llvm.org/viewvc/
 github.com/llvm-mirror/
 github.com/llvm-project/
 reviews.llvm.org/diffusion/

to instead point to https://github.com/llvm/llvm-project.

This is *not* a trivial substitution, because additionally, all the
checkout instructions had to be migrated to instruct users on how to
use the monorepo layout, setting LLVM_ENABLE_PROJECTS instead of
checking out various projects into various subdirectories.

I've attempted to not change any scripts here, only documentation. The
scripts will have to be addressed separately.

Additionally, I've deleted one document which appeared to be outdated
and unneeded:
  lldb/docs/building-with-debug-llvm.txt

Differential Revision: https://reviews.llvm.org/D57330

llvm-svn: 352514
2019-01-29 16:37:27 +00:00
Ilya Biryukov dd471681d0 [clangd] Remove extra ';' to fix -Wpedantic warning. NFC
llvm-svn: 352511
2019-01-29 16:04:39 +00:00
Ilya Biryukov d2167ec732 [clangd] Attempt to fix failing buildbots after r352494
For failures see:
http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/38501/steps/build-unified-tree/logs/stdio

llvm-svn: 352510
2019-01-29 15:57:14 +00:00
Ilya Biryukov 73afee2d7c [clangd] Make -clang-tidy-checks a non-hidden command-line arg
Summary:
This looks like a useful user-facing configuration parameter,
which should be discoverable.

Also fix a small typo in the description.

Reviewers: hokein

Reviewed By: hokein

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D57384

llvm-svn: 352509
2019-01-29 15:52:05 +00:00
Ilya Biryukov 060f7fe3e3 [clangd] Unit test for sourceLocationInMainFile.
This should have been part of r352494, which added the corresponding
function. The unit test ended up as a separate commit accidentally.

llvm-svn: 352501
2019-01-29 14:31:19 +00:00
Ilya Biryukov cce67a32cf [clangd] Interfaces for writing code tweaks
Summary:
The code tweaks are an implementation of mini-refactorings exposed
via the LSP code actions. They run in two stages:
  - Stage 1. Decides whether the action is available to the user and
    collects all the information required to finish the action.
    Should be cheap, since this will run over all the actions known to
    clangd on each textDocument/codeAction request from the client.

  - Stage 2. Uses information from stage 1 to produce the actual edits
    that the code action should perform. This stage can be expensive and
    will only run if the user chooses to perform the specified action in
    the UI.

One unfortunate consequence of this change is increased latency of
processing the textDocument/codeAction requests, which now wait for an
AST. However, we cannot avoid this with what we have available in the LSP
today.

Reviewers: kadircet, ioeric, hokein, sammccall

Reviewed By: sammccall

Subscribers: mgrang, mgorny, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D56267

llvm-svn: 352494
2019-01-29 14:17:36 +00:00
Haojian Wu e30d87ecea [clangd] dlog clang-tidy configuration
vlog seems to be too spammy in unittests.

llvm-svn: 352485
2019-01-29 12:32:32 +00:00
Kadir Cetinkaya 249ea33ddf [clangd] Make USRs for macros to be position independent
Summary:
USRs for macros were not cannonical due to usage of cursor location
instead of definition location.

Reviewers: jkorous

Subscribers: ilya-biryukov, ioeric, MaskRay, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D57228

llvm-svn: 352481
2019-01-29 11:19:15 +00:00
Haojian Wu 7b6f874717 [clangd] Index main-file macros (bug 39761)
Patch by Nathan Ridge!

Differential Revision: https://reviews.llvm.org/D55739

llvm-svn: 352367
2019-01-28 14:11:49 +00:00
Haojian Wu f02e9f3783 [clang-tidy] Fix a build error.
llvm-svn: 352364
2019-01-28 14:07:45 +00:00
Hyrum Wright 722191be25 [clang-tidy] Add the abseil-duration-addition check
Differential Revision: https://reviews.llvm.org/D57185

llvm-svn: 352362
2019-01-28 14:03:09 +00:00
Eric Liu dd66277c36 [clangd] Suggest adding missing includes for incomplete type diagnostics.
Summary:
This enables clangd to intercept compiler diagnostics and attach fixes (e.g. by
querying index). This patch adds missing includes for incomplete types e.g.
member access into class with only forward declaration. This would allow adding
missing includes for user-typed symbol names that are missing declarations
(e.g. typos) in the future.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: mgorny, ilya-biryukov, javed.absar, MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D56903

llvm-svn: 352361
2019-01-28 14:01:55 +00:00
Kristof Umann 64c3fe9103 Fix a lit test failure after D54438
llvm-svn: 352290
2019-01-26 21:22:58 +00:00
Jonas Toth 09197fac59 [clang-tidy] fix unit tests for dropped _Float16 support in X86
Summary:
Because _Float16 was disabled for X86 targets the unit-tests started failing.
Extract the pieces for _Float16 and run theses tests under AArch64.

Reviewers: aaron.ballman, erichkeane, lebedev.ri

Reviewed By: erichkeane

Subscribers: javed.absar, xazax.hun, kristof.beyls, cfe-commits

Differential Revision: https://reviews.llvm.org/D57249

llvm-svn: 352231
2019-01-25 19:05:12 +00:00
Roman Lebedev 76c9877b56 Temporairly disable readability-uppercase-literal-suffix tests that depend on _Float16, to get bots back to green
llvm-svn: 352224
2019-01-25 18:05:43 +00:00
Haojian Wu aa3ed5a983 [clangd] NFC: fix clang-tidy warnings.
Most are about llvm code style violation (found via
readability-identifier-naming check).

llvm-svn: 352205
2019-01-25 15:14:03 +00:00
Haojian Wu 7a35bdb7ec [clangd] Log clang-tidy configuration, NFC
Summary: This is used for debugging purpose.

Reviewers: sammccall

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D57057

llvm-svn: 352184
2019-01-25 10:14:27 +00:00
Haojian Wu c67dab5bd0 [clang-tidy] Add check for underscores in googletest names.
Summary: Adds a clang-tidy warning for underscores in googletest names.

Patch by Kar Epker!

Reviewers: hokein, alexfh, aaron.ballman

Reviewed By: hokein

Subscribers: Eugene.Zelenko, JonasToth, MyDeveloperDay, lebedev.ri, xazax.hun, mgorny, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D56424

llvm-svn: 352183
2019-01-25 10:03:49 +00:00
Hyrum Wright 1ec465dbfd [clang-tidy] Rename the absl duration helper functions; NFC
llvm-svn: 352088
2019-01-24 19:23:50 +00:00
Haojian Wu 66038ffa13 [clangd] Clean the cache of file statuses on vscode-clangd when clangd crashes.
Summary:
Clear the cached file statuses, otherwise we will leave some garbage texts on
the status bar when clangd crashes.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D56540

llvm-svn: 352049
2019-01-24 14:25:53 +00:00
Ilya Biryukov c514adef05 [CodeComplete] [clangd] Fix crash on ValueDecl with a null type
Reviewers: kadircet

Reviewed By: kadircet

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D57093

llvm-svn: 352040
2019-01-24 10:41:43 +00:00
David Carlier 7e37bf26d5 [extra] unit tests enable crash-recovery cases on FreeBSD
Seems the previous statement does not hold up anymore.

Reviewers: steveire

Reviewed By: steveire

Differential Revision: https://reviews.llvm.org/D57102

llvm-svn: 352031
2019-01-24 07:58:42 +00:00
Ilya Biryukov 88d7d296f4 [clangd] Workaround a test failure after r351941
This should fix failing buildbots.

llvm-svn: 351943
2019-01-23 11:32:07 +00:00
Ilya Biryukov 4e0c400a47 [clangd] Fix crash due to ObjCPropertyDecl
With ObjCPropertyDecl, ASTNode.OrigD can be a ObjCPropertyImplDecl
which is not a NamedDecl, leading to a crash since the code
incorrectly assumes ASTNode.OrigD will always be a NamedDecl.

Change by dgoldman (David Goldman)!

Differential Revision: https://reviews.llvm.org/D56916

llvm-svn: 351941
2019-01-23 10:35:12 +00:00
Haojian Wu 87b0e3fda9 [clangd] Link clangTidy into clangd tests
Patch by Nathan Ridge!

Differential Revision: https://reviews.llvm.org/D57077

llvm-svn: 351929
2019-01-23 08:04:17 +00:00
Zinovy Nis 79639e9737 [doc] Fix svn property for bugprone-parent-virtual-call.rst
llvm-svn: 351925
2019-01-23 06:46:27 +00:00
Stephane Moore 05a449b481 Revert rCTE351921 to fix documentation geneeration.
Original review: https://reviews.llvm.org/D56945

llvm-svn: 351922
2019-01-23 02:58:59 +00:00
Stephane Moore be9eca442e [clang-tidy] Delete obsolete objc-property-declaration options ✂️
Summary:
The `Acronyms` and `IncludeDefaultAcronyms` options were deprecated in
https://reviews.llvm.org/D51832. These options can be removed.

Tested by running the clang-tidy tests.

Reviewers: benhamilton, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: Eugene.Zelenko, xazax.hun, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D56945

llvm-svn: 351921
2019-01-23 02:34:21 +00:00
Zinovy Nis 1449277fc0 [doc] Replace 'class' with 'struct' for 'public' by default
Make sample syntax correct.

llvm-svn: 351867
2019-01-22 20:27:02 +00:00
Eugene Zelenko b272ec1347 [Documentation] Use HTTPS whenever possible.
Differential revision: https://reviews.llvm.org/D56926

llvm-svn: 351862
2019-01-22 19:19:48 +00:00
Haojian Wu 32cd41f229 [clangd] Followup fix of rL351818
ClangTidyOptions::getDefaults is not free, it will initialize all
clang-tidy modules to get check-specific options, and we don't use this
information in CodeComplete, so using an empty one (constructed by
default constructor) is sufficient.

llvm-svn: 351826
2019-01-22 14:48:04 +00:00
Simon Pilgrim 6202a3ad67 Fix "missing field 'ClangTidyOpts' initializer" warning. NFCI.
llvm-svn: 351818
2019-01-22 13:35:16 +00:00
Alexander Kornienko 73eb326203 [clang-tidy] Fix whitespace in docs. NFC
Actually, just testing commits via monorepo ;)

llvm-svn: 351814
2019-01-22 12:59:34 +00:00
Eric Liu 464bbe5812 [clangd] NFC: reduce log noise from Diagnostics.
Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D57042

llvm-svn: 351813
2019-01-22 12:55:27 +00:00
Haojian Wu 65e1099eed [clangd] Fix the broken buildbot.
llvm-svn: 351812
2019-01-22 12:55:15 +00:00
Haojian Wu 72ef4510b6 [clangd] Fix the `-Wtype-limits` warning, NFC
The assertion is always true, and triggers a compiler warning, so remove it.

llvm-svn: 351809
2019-01-22 12:21:25 +00:00
Kadir Cetinkaya a65bcbfd9c [clangd] NFC: Use buildCompilerInvocation in CodeComplete
Reviewers: ilya-biryukov, sammccall

Reviewed By: sammccall

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D56860

llvm-svn: 351793
2019-01-22 09:58:53 +00:00
Haojian Wu 1ca0c58c81 [clangd] Support clang-tidy configuration in clangd.
Summary:
This patch adds some basic supports for clang-tidy configurations in clangd:
      - clangd will respect .clang-tidy configurations for each file
      - we don't aim to support all clang-tidy options in clangd, only a
        small subset of condfigurations (options related to which checks will be
        enabled) are supported.
      - add a `clang-tidy-checks` CLI option that can override options from
        .clang-tidy file

Reviewers: ilya-biryukov, sammccall

Reviewed By: sammccall

Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D55256

llvm-svn: 351792
2019-01-22 09:39:05 +00:00
Kadir Cetinkaya be6b35dac4 [clangd] Filter out plugin related flags and move all commandline manipulations into OverlayCDB.
Summary:
Some projects make use of clang plugins when building, but clangd is
not aware of those plugins therefore can't work with the same compile command
arguments.

There were multiple places clangd performed commandline manipulations,
 this one also moves them all into OverlayCDB.

Reviewers: ilya-biryukov

Subscribers: klimek, sammccall, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D56841

llvm-svn: 351788
2019-01-22 09:10:20 +00:00
Alexander Kornienko efde822cd1 [clang-tidy] Work around http://llvm.org/PR40392
The readability-else-after-return check should be smarter about cases where the
variable defined in the condition is used in the `else` branch. This patch makes
it just ignore such cases, but alternative solutions may be better (added a
FIXME).

llvm-svn: 351751
2019-01-21 16:26:54 +00:00
Kadir Cetinkaya fd29980f09 [clang-tidy] Use getStripPluginsAdjuster
Summary: See rC351531 for the introduction of getStripPluginsAdjuster.

Reviewers: alexfh

Subscribers: xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D56902

llvm-svn: 351738
2019-01-21 10:10:18 +00:00
Chandler Carruth 4a1b95bda0 Fix typos throughout the license files that somehow I and my reviewers
all missed!

Thanks to Alex Bradbury for pointing this out, and the fact that I never
added the intended `legacy` anchor to the developer policy. Add that
anchor too. With hope, this will cause the links to all resolve
successfully.

llvm-svn: 351731
2019-01-21 09:52:34 +00:00
Miklos Vajna 61c818f253 [clang-tidy] misc-non-private-member-variables-in-classes: ignore implicit methods
Otherwise we don't warn on a struct containing a single public int, but
we warn on a struct containing a single public std::string, which is
inconsistent.

llvm-svn: 351686
2019-01-20 14:28:27 +00:00
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00
Chandler Carruth 4a50956c07 Convert two more files that were using Windows line endings and remove
a stray single '\r' from one file. These are the last line ending issues
I can find in the files containing parts of LLVM's file headers.

llvm-svn: 351634
2019-01-19 06:36:08 +00:00
Chandler Carruth 79b37483c8 Update some code used in our visual studio plugins to use linux file
endings. We already used them in some cases, and this makes things
consistent. This will also simplify updating the licenses in these
files.

llvm-svn: 351632
2019-01-19 06:29:07 +00:00
Chandler Carruth 469bdefd44 Install new LLVM license structure and new developer policy.
This installs the new developer policy and moves all of the license
files across all LLVM projects in the monorepo to the new license
structure. The remaining projects will be moved independently.

Note that I've left odd formatting and other idiosyncracies of the
legacy license structure text alone to make the diff easier to read.
Critically, note that we do not in any case *remove* the old license
notice or terms, as that remains necessary until we finish the
relicensing process.

I've updated a few license files that refer to the LLVM license to
instead simply refer generically to whatever license the LLVM project is
under, basically trying to minimize confusion.

This is really the culmination of so many people. Chris led the
community discussions, drafted the policy update and organized the
multi-year string of meeting between lawyers across the community to
figure out the strategy. Numerous lawyers at companies in the community
spent their time figuring out initial answers, and then the Foundation's
lawyer Heather Meeker has done *so* much to help refine and get us ready
here. I could keep going on, but I just want to make sure everyone
realizes what a huge community effort this has been from the begining.

Differential Revision: https://reviews.llvm.org/D56897

llvm-svn: 351631
2019-01-19 06:14:24 +00:00
Jonas Toth ae17ff0781 [clang-tidy] add reproducer for PR39949 into test-suite
Summary:
The underlying issue is fixed in https://reviews.llvm.org/D56444
and this test ensures the issue does not creep back into our
code-base.

Reviewers: alexfh, aaron.ballman, hokein, hwright

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D56918

llvm-svn: 351569
2019-01-18 18:03:11 +00:00
Ilya Biryukov 1c48f0383c [clangd] Make background index less chatty
Summary:
It is producing too much input in non-verbose mode,
i.e. a message per indexed file

Reviewers: sammccall, kadircet

Reviewed By: sammccall

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D56915

llvm-svn: 351563
2019-01-18 17:04:26 +00:00
Hyrum Wright b60de17b51 [clang-tidy] Add abseil-duration-conversion-cast check
Differential Revision: https://reviews.llvm.org/D56532

llvm-svn: 351473
2019-01-17 20:37:35 +00:00
Aaron Ballman b95b6f42f9 Revert r351208 (which was a revert of r350892).
This corresponds to the fix to Clang in r351470.

llvm-svn: 351471
2019-01-17 20:21:44 +00:00
Eugene Zelenko 390b3b34e0 [Documentation] Fix another link in docs/clang-tidy/Contributing.rst.
llvm-svn: 351468
2019-01-17 20:00:23 +00:00
Eugene Zelenko 76c77d9eaf [Documentation] Another attempt to fix link in docs/clang-tidy/Contributing.rst. Use HTTPS for links.
llvm-svn: 351467
2019-01-17 19:47:44 +00:00
Eugene Zelenko 6bea2f21ce [Documentation] Fix link in docs/clang-tidy/Contributing.rst.
llvm-svn: 351466
2019-01-17 19:35:39 +00:00
Eugene Zelenko fb877cb9f2 [Documentation] Add a chapter about Clang-tidy integrations.
Patch by Marina Kalashina.

Differential Revision: https://reviews.llvm.org/D54945

llvm-svn: 351463
2019-01-17 18:31:34 +00:00
Hyrum Wright 56de30fd4b [clang-tidy] Move the macro helper function to a common location; NFC
This is useful for multiple checks.

llvm-svn: 351348
2019-01-16 14:49:32 +00:00
Hans Wennborg 1fe469ae6c Bump the trunk version to 9.0.0svn
llvm-svn: 351320
2019-01-16 10:57:02 +00:00
Pavel Labath 7b5565418f Fix build breakage from llvm r351317
The two-argument version of  llvm::sys::fs::make_absolute no longer
returns an error code.

llvm-svn: 351319
2019-01-16 10:26:52 +00:00
Clement Courbet ae814fcb4c [clang-tidy] bugprone-string-constructor: Catch string from nullptr.
Summary: Context: https://twitter.com/willkirkby/status/1084219580799741953

Subscribers: xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D56657

llvm-svn: 351308
2019-01-16 08:36:23 +00:00
Sam McCall 5a8e6afff2 [clang-tidy] Avoid fuchsia-overloaded-operator false positive with lambdas after r351047
llvm-svn: 351307
2019-01-16 08:29:54 +00:00
Fangrui Song 54762df8f6 [clangd] Fix XPC after rCTE351280
llvm-svn: 351306
2019-01-16 08:13:15 +00:00
Martin Bohme c4db59c63c [clang-tidy] Treat references to smart pointers correctly in use-after-move.
Summary:
Previously, we weren't recognizing these as smart pointers and thus
weren't allowing non-dereference accesses as we should -- see new test
cases which fail without the fix.

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: JonasToth

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D56585

llvm-svn: 351303
2019-01-16 07:53:25 +00:00
Jan Korous dca9c7cf24 [clangd] XPC transport layer
- New transport layer for macOS.
- XPC Framework
- Test client

Framework and client were written by Alex Lorenz.

Differential Revision: https://reviews.llvm.org/D54428

llvm-svn: 351280
2019-01-16 00:24:22 +00:00
Paul Hoad b16e288c7d [clang-tidy] add options documentation to readability-identifier-naming checker
Summary:
The documentation for this clang-checker did not explain what the options are. But this checkers only works with at least some options defined.

To discover the options, you have to read the source code. This shouldn't be necessary for users who just have access to the clang-tidy binary.

This revision, explains the options and gives an example.

Patch by MyDeveloperDay.

Reviewers: JonasToth, Eugene.Zelenko

Reviewed By: JonasToth

Subscribers: xazax.hun, Eugene.Zelenko

Differential Revision: https://reviews.llvm.org/D56563

llvm-svn: 351261
2019-01-15 22:06:49 +00:00
Benjamin Kramer b709b600a5 Revert "Update clang-tools-extra for r350891 from Clang."
This reverts commit r350892.

llvm-svn: 351208
2019-01-15 17:20:04 +00:00
Hans Wennborg eb60fbfdb4 Update year in license files
In last year's update (D48219) it was suggested that the release manager
might want to do this, so here we go.

llvm-svn: 351194
2019-01-15 15:10:32 +00:00
Kadir Cetinkaya 226af75a02 [clangd] Fix updated file detection logic in indexing
Summary:
Files without any symbols were never marked as updated during indexing, which resulted in failure while writing shards for these files.

This patch fixes the logic to mark files that are seen for the first time but don't contain any symbols as updated.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D56592

llvm-svn: 351170
2019-01-15 09:03:33 +00:00
Amara Emerson cadf4b61f0 Revert r351051 "[clangd] Unlink VFS working dir from OS working dir."
The llvm commit r351050 broke some bots and was reverted.

llvm-svn: 351100
2019-01-14 18:59:17 +00:00
Haojian Wu c34f022bfe [clangd] Add Limit parameter for xref.
Reviewers: sammccall

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D56597

llvm-svn: 351081
2019-01-14 18:11:09 +00:00
Kadir Cetinkaya 560b853ccf [clangd] Fix a reference invalidation
Summary: Fix for the breakage in http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/52811/consoleFull#-42777206a1ca8a51-895e-46c6-af87-ce24fa4cd561

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D56656

llvm-svn: 351052
2019-01-14 11:24:07 +00:00
Sam McCall 2dccf13538 [clangd] Unlink VFS working dir from OS working dir.
A lot of our previous FS manipulation was thread-unsafe in practice with
the RealFS implementation.

This switches to a different RealFS mode where path-manipulation is used
to simulate multiple working dirs.
r351050 both added this mode and removed the cache. If we want to
move back to the old implementation we need to put the cache back.

llvm-svn: 351051
2019-01-14 11:06:48 +00:00
Sam McCall d37be4b779 [clang-tidy] update FunctionSizeCheck for D56444
Reviewers: JonasToth, aaron.ballman

Subscribers: xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D56552

llvm-svn: 351048
2019-01-14 10:40:41 +00:00
Sam McCall 0e93b076c4 [clangd] Index main-file symbols (bug 39761)
Patch by Nathan Ridge!

Differential Revision: https://reviews.llvm.org/D55185

llvm-svn: 351041
2019-01-14 10:01:17 +00:00
Miklos Vajna 98ef5337c9 [clang-tidy] new check 'readability-redundant-preprocessor'
Finds potentially redundant preprocessor directives.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D54349

llvm-svn: 350922
2019-01-11 07:59:47 +00:00
Brian Gesiak eb139def3d Adapt to CXXMethodDecl::getThisType change (NFC)
Summary:
https://reviews.llvm.org/D56509 changed the API of the
CXXMethodDecl::getThisType method. Adapt to the change (and re-apply
clang-format) to fix the clang-tidy build.

llvm-svn: 350916
2019-01-11 02:12:31 +00:00
Aaron Ballman 25116708c4 Update clang-tools-extra for r350891 from Clang.
llvm-svn: 350892
2019-01-10 21:22:28 +00:00
Kadir Cetinkaya 99b060e447 [clangd] Introduce loading of shards within auto-index
Summary:
Whenever a change happens on a CDB, load shards associated with that
CDB before issuing re-index actions.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D55224

llvm-svn: 350847
2019-01-10 17:03:04 +00:00
Jonas Toth 6a9f831ffd [clang-tidy] Fix case of local variables in modernize-use-nodiscard checker
Summary:
Correct the case of the local variables..

Rational:
I want to be able to run clang-tidy on new clang-tidy checker code prior to creating a review (to demonstrate we should dog food our own tools during development, not my suggestion but @Eugene.Zelenko)

To this end I am running the following in a script, prior to make a change.

```
tidy:
    @for source in $$(git status -suno | grep ".cpp$$" | cut -c4-) ;\
    do \
        clang-tidy -quiet  $$source -- $(TIDY_FLAGS);\
    done

```

I then want to go through the checkers and see which checkers most closely match the review style of the reviewers

```
---
Checks:          '
-clang-diagnostic-*,
readability-identifier-naming,
llvm-header-guard
'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle:     LLVM
CheckOptions:
  - key:             readability-identifier-naming.IgnoreFailedSplit
    value:           '0'
  - key:             readability-identifier-naming.VariableCase
    value:           'CamelCase'
  - key:             readability-identifier-naming.LocalVariableCase
    value:           'CamelCase'
...

```

Unfortunately in doing so, I have identified that my previous review {D55433} it violates what looks like to be the convention of local variables being in CamelCase.

Sending this small review in the hope it can be corrected.

Patch by MyDeveloperDay.

Reviewers: JonasToth, Eugene.Zelenko

Reviewed By: JonasToth

Subscribers: xazax.hun, Eugene.Zelenko

Differential Revision: https://reviews.llvm.org/D56536

llvm-svn: 350814
2019-01-10 11:56:44 +00:00
Haojian Wu 8f85b9f867 [clangd] Don't store completion info if the symbol is not used for code completion.
Summary:
This would save us some memory and disk space:
  - Dex usage (261 MB vs 266 MB)
  - Disk (75 MB vs 76 MB)

It would save more when we index the main file symbol D55185.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: nridge, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D56314

llvm-svn: 350803
2019-01-10 09:22:40 +00:00
Richard Trieu b9e7359204 Remove unnecessary include.
QuerySession.h does not need anything from Query.h, so it does not need to
include it.

llvm-svn: 350797
2019-01-10 04:53:10 +00:00
Jonas Toth a86d5c46e1 [clang-tidy] another take at fixing doc
llvm-svn: 350765
2019-01-09 21:27:59 +00:00
Jonas Toth 3bdb8fd6c9 [clang-tidy] tryfix documentation build
llvm-svn: 350763
2019-01-09 21:19:44 +00:00
Jonas Toth e6406dceff [clang-tidy] fix-up failing tests
llvm-svn: 350761
2019-01-09 21:03:54 +00:00
Jonas Toth ca8e20cdf7 [clang-tidy] Adding a new modernize use nodiscard checker
Summary: Adds a checker to clang-tidy to warn when a non void const member function, taking only parameters passed by value or const reference could be marked as '[[nodiscard]]'

Patch by MyDeveloperDay.

Reviewers: alexfh, stephenkelly, curdeius, aaron.ballman, hokein, JonasToth

Reviewed By: curdeius, JonasToth

Subscribers: Eugene.Zelenko, lefticus, lebedev.ri, mgorny, xazax.hun, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D55433

llvm-svn: 350760
2019-01-09 20:50:50 +00:00
Haojian Wu 0b097b1a8a [clangd] Add a test for SignatureHelp on dynamic index.
Summary: This would catch regressions caused by future changes of the index.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D56483

llvm-svn: 350720
2019-01-09 13:42:03 +00:00
Ilya Biryukov c3ce99970a Fix clang-tidy test after r350714. NFC
llvm-svn: 350715
2019-01-09 13:08:31 +00:00
Stephen Kelly de4533621c [Query] NFC: Port QueryParser to StringRef
Summary:
There is no reason for it to not be a StringRef.  Making it one
simplifies existing code, and makes follow-up features easier.

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56415

llvm-svn: 350660
2019-01-08 22:27:08 +00:00
Haojian Wu 073d184ee3 [clangd] Fix a crash when reading an empty index file.
Summary:
Unfortunately, yaml::Input::setCurrentDocument() and yaml::Input::nextDocument() are
internal APIs, the way we use them may cause a nullptr accessing when
processing an empty YAML file.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D56442

llvm-svn: 350633
2019-01-08 15:24:47 +00:00
Stephen Kelly 1baa2897ef ReleaseNotes: Update with my clang-query contributions this cycle
llvm-svn: 350584
2019-01-08 00:09:34 +00:00
Ilya Biryukov 47f174a2be [clangd] Fix Windows build after r350531
llvm-svn: 350542
2019-01-07 17:03:15 +00:00
Ilya Biryukov 9d96c3c7f2 [clangd] Include <cstdio> instead of <stdio.h>. NFC
This fixes the only clang-tidy check currently enabled by clangd.

llvm-svn: 350540
2019-01-07 16:55:59 +00:00
Ilya Biryukov f2001aa743 [clangd] Remove 'using namespace llvm' from .cpp files. NFC
The new guideline is to qualify with 'llvm::' explicitly both in
'.h' and '.cpp' files. This simplifies moving the code between
header and source files and is easier to keep consistent.

llvm-svn: 350531
2019-01-07 15:45:19 +00:00
Hyrum Wright 1bec67f605 [clang-tidy] Use the public hasInit matcher, rather than defining our own, NFC
llvm-svn: 350526
2019-01-07 14:36:47 +00:00
Haojian Wu e1ced5c926 [clangd] Fix a regression issue caused by r348365.
Summary:
With r348365, we now detect libc++ dir using the actual compiler path
(from the compilation command), rather than the resource-dir.

This new behavior will cause clangd couldn't find libc++ dir (even the libc++ is
built from the source) when using a fallback compilation command (`clang xxx`)

The fix is to use `<clangd_install_dir>/clang` as the actual compiler path.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D56380

llvm-svn: 350515
2019-01-07 12:35:02 +00:00
Ilya Biryukov 082072873f [clangd] Disable BackgroundIndexTest.PeriodicalIndex
It sometimes fails on AArch64.

llvm-svn: 350512
2019-01-07 11:18:11 +00:00
Jonas Toth 964f816dba [Documentation] fix order of checks in checks/list.rst
llvm-svn: 350466
2019-01-05 11:40:05 +00:00
Michal Gorny c1d5999dd1 [clangd] Fix detecting atomics in stand-alone builds
Include CheckAtomic CMake module from LLVM in order to detect support
for atomics when building stand-alone.  Otherwise,
the HAVE_CXX_ATOMICS64_WITHOUT_LIB variable is undefined and clangd
wrongly attempts to link -latomic on systems not using the library.

Original bug report: https://bugs.gentoo.org/667016

Differential Revision: https://reviews.llvm.org/D56061

llvm-svn: 350329
2019-01-03 16:43:27 +00:00
Haojian Wu 9ff50013b1 [clangd] Move helpers from global namespace into anonymous namespace, NFC.
llvm-svn: 350325
2019-01-03 15:36:18 +00:00
Haojian Wu 347600a0cc [clangd] Bump vscode-clangd v0.0.9
llvm-svn: 350324
2019-01-03 15:28:38 +00:00
Kadir Cetinkaya 41f98c834b [clangd] Always try to build absolute path
Summary:
This only changes behavior in cases when the file itself is a symlink.

When canonicalizing paths do not look at tryGetRealPathName, which
contains the resolved path for files that are symlinks. Instead first build the
absolute path even if it contains some symlinks on the path. Then resolve only
the symlinks on the path and leave it as it is if the file itself is a symlink.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D56263

llvm-svn: 350306
2019-01-03 13:46:10 +00:00
Ilya Biryukov b0826bdffe [clangd] Check preceding char when completion triggers on ':' or '>'
Summary:
Only run completion when we were trigerred on '->' and '::', otherwise
send an error code in return.
To avoid automatically invoking completions in cases like 'a >^' or
'a ? b :^'.

Reviewers: hokein

Reviewed By: hokein

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D55994

llvm-svn: 350304
2019-01-03 13:37:12 +00:00
Ilya Biryukov 22fa465a8c [clangd] clang-format everything. NFC
llvm-svn: 350303
2019-01-03 13:28:05 +00:00
Eugene Zelenko a6182460d6 [Documentation] Alphabetical order in Clang-tidy checks changes list.
llvm-svn: 350273
2019-01-02 23:35:57 +00:00
Haojian Wu 91051537b8 [clangd] Show FileStatus in vscode-clangd.
Summary:
The file status will be shown in the status bar.
Depends on D55363.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D55374

llvm-svn: 350210
2019-01-02 11:25:37 +00:00
Hyrum Wright 4ce05801c7 [clang-tidy] Export the abseil duration inverse lookup function, NFC
This allows other tools to use this function.

llvm-svn: 350133
2018-12-28 19:04:21 +00:00
Miklos Vajna 7fb1c2a6ca [clang-tidy] add IgnoreMacros option to readability-uppercase-literal-suffix
And also enable it by default to be consistent with e.g.
modernize-use-using.

This helps e.g. when running this check on client code where the macro
is provided by the system, so there is no easy way to modify it.

Reviewed By: JonasToth, lebedev.ri

Differential Revision: https://reviews.llvm.org/D56025

llvm-svn: 350056
2018-12-24 17:47:32 +00:00
Fangrui Song 9ea1e9136b [clangd] Delete stray semicolon. NFC
llvm-svn: 350040
2018-12-24 03:19:53 +00:00
Fangrui Song 2ea656f3ab [clangd] Delete trailing ; NFC
llvm-svn: 350037
2018-12-23 22:20:34 +00:00
Hyrum Wright 9fc3a5f438 [clang-tidy] Be more liberal about literal zeroes in abseil checks
Summary:
Previously, we'd only match on literal floating or integral zeroes, but I've now also learned that some users spell that value as int{0} or float{0}, which also need to be matched.

Differential Revision: https://reviews.llvm.org/D56012

llvm-svn: 349953
2018-12-21 21:07:11 +00:00
Julie Hockett e2e73b221b [clang-tidy] Add export-fixes flag to clang-tidy-diff
Differential Revision: https://reviews.llvm.org/D55848

llvm-svn: 349930
2018-12-21 17:25:27 +00:00
Haojian Wu 744eb3c3be [clangd] Cleanup syntax errors in the test, NFC.
llvm-svn: 349893
2018-12-21 09:32:49 +00:00
Bjorn Pettersson f069f1c288 Fix warning about unused variable [NFC]
llvm-svn: 349891
2018-12-21 08:51:04 +00:00
Ilya Biryukov d363f08426 [clangd] Try to workaround test failure by increasing the timeouts
Ideally we'd figure out a way to run this test without any sleeps, this
workaround is only there to avoid annoying people with test failures
around the holiday period when everyone is on vacation.

llvm-svn: 349769
2018-12-20 16:27:19 +00:00
Haojian Wu b618849e31 [clangd] Expose FileStatus to LSP.
Summary:
Add an LSP extension "textDocument/clangd.fileStatus" to emit file-status information.

Reviewers: ilya-biryukov

Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D55363

llvm-svn: 349768
2018-12-20 15:39:12 +00:00
Alexander Kornienko 14706b9687 [clang-tidy] Use translationUnitDecl() instead of a custom matcher.
llvm-svn: 349758
2018-12-20 13:50:04 +00:00
Haojian Wu b2d7e269d5 [clangd] Don't miss the expected type in merge.
Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D55918

llvm-svn: 349750
2018-12-20 13:05:46 +00:00
Hyrum Wright 06a8febe76 [clang-tidy] Diagnose abseil-duration-comparison on macro arguments
Summary:
This change relaxes the requirements on the utility
`rewriteExprFromNumberToDuration` function, and introduces new checking
inside of the `abseil-duration-comparison` check to allow macro argument
expression transformation.

Differential Revision: https://reviews.llvm.org/D55784

llvm-svn: 349636
2018-12-19 16:03:34 +00:00
Haojian Wu bbcfa7c1e2 [clangd] Fix a syntax error on the test.
llvm-svn: 349632
2018-12-19 14:51:07 +00:00
Haojian Wu 530108cb5c [clang-tidy] use "const SourceManager&" parameter, NFC.
llvm-svn: 349623
2018-12-19 13:25:08 +00:00
Kadir Cetinkaya dd67793c0c [clangd] Unify path canonicalizations in the codebase
Summary:
There were a few different places where we canonicalized paths, each
one had its own flavor. This patch tries to unify them all under one place.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D55818

llvm-svn: 349618
2018-12-19 10:46:21 +00:00
Eric Liu ae7ac3ca5b [clangd] Try to fix buildbot failure after r349496
Increase timeout from 10ms to 100ms.
See http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/27959

llvm-svn: 349502
2018-12-18 16:06:29 +00:00
Eric Liu 667e8ef7e1 [clangd] BackgroundIndex rebuilds symbol index periodically.
Summary:
Currently, background index rebuilds symbol index on every indexed file,
which can be inefficient. This patch makes it only rebuild symbol index periodically.
As the rebuild no longer happens too often, we could also build more efficient
dex index.

Reviewers: ilya-biryukov, kadircet

Reviewed By: kadircet

Subscribers: dblaikie, MaskRay, jkorous, arphaman, jfb, cfe-commits

Differential Revision: https://reviews.llvm.org/D55770

llvm-svn: 349496
2018-12-18 15:39:33 +00:00
Kadir Cetinkaya e913b956aa [clangd] Change diskbackedstorage to be atomic
Summary:
There was a chance that multiple clangd instances could try to write
same shard, in which case we would get a malformed file most likely. This patch
changes the writing mechanism to first write to a temporary file and then rename
it to fit real destination. Which is guaranteed to be atomic by POSIX.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, jfb, cfe-commits

Differential Revision: https://reviews.llvm.org/D55417

llvm-svn: 349348
2018-12-17 12:38:22 +00:00
Kadir Cetinkaya 375c54fd1e [clangd] Only reduce priority of a thread for indexing.
Summary:
We'll soon have tasks pending for reading shards from disk, we want
them to have normal priority. Because:
- They are not CPU intensive, mostly IO bound.
- Give a good coverage for the project at startup, therefore it is worth
  spending some cycles.
- We have only one task per whole CDB rather than one task per file.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, jfb, cfe-commits

Differential Revision: https://reviews.llvm.org/D55315

llvm-svn: 349345
2018-12-17 12:30:27 +00:00
Kristof Umann 224ddd5b11 Revert rCTE349288 'Fix a lit test failure after MallocChecker changes'
llvm-svn: 349341
2018-12-17 12:08:39 +00:00
Kristof Umann 78e607eccc Fix a lit test failure after MallocChecker changes
llvm-svn: 349288
2018-12-16 00:00:18 +00:00
Kadir Cetinkaya 1b65b376ae [dexp] Change FuzzyFind to also print scope of symbols
Summary:
When there are multiple symbols in the result of a fuzzy find with the
same name, one has to perform an additional query to figure out which of those
symbols are coming from the "interesting" scope. This patch prints the scope in
fuzzy find results to get rid of the second symbol.

Reviewers: hokein

Subscribers: ilya-biryukov, ioeric, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D55705

llvm-svn: 349152
2018-12-14 14:17:18 +00:00
Philipp Stephani 113e2cd958 clang-include-fixer.el: support remote files
Summary: Support remote files (e.g., Tramp) in the Emacs integration for clang-include-fixer

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D54672

llvm-svn: 349150
2018-12-14 13:56:05 +00:00
Haojian Wu 941ce02deb [clangd] Use buildCompilerInvocation to simplify the HeadersTests, NFC.
llvm-svn: 349148
2018-12-14 13:49:00 +00:00
Haojian Wu 23ae22b669 [clangd] Fix memory leak in ClangdTests.
Summary:
createInvocationFromCommandLine sets DisableFree to true by default,
which leads memory leak in clangd. The fix is to  use the `BuildCompilationInvocation`
to create CI with the correct options (DisableFree is false).

Fix https://bugs.llvm.org/show_bug.cgi?id=39991.

Reviewers: kadircet

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D55702

llvm-svn: 349145
2018-12-14 13:19:38 +00:00
Haojian Wu d5a78e6e59 [clangd] Fix an assertion failure in background index.
Summary:
When indexing a file which contains an uncompilable error, we will
trigger an assertion failure -- the IndexFileIn data is not set, but we
access them in the backgound index.

Reviewers: kadircet

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D55650

llvm-svn: 349144
2018-12-14 12:39:08 +00:00
Ivan Donchevskii 13c9c05441 [clang-tidy] Remove extra config.h includes
It's included in a new header ClangTidyForceLinker.h and should not
be included the second time.

Follow up for the https://reviews.llvm.org/D55595

llvm-svn: 349132
2018-12-14 07:44:52 +00:00
Ivan Donchevskii 37512e58ba [clang-tidy] Share the forced linking code between clang-tidy tool and plugin
Extract code that forces linking to the separate header and include it in both plugin and standalone tool.
Try 2: missing header guard and "clang/Config/config.h" are added to the new header.

Differential Revision: https://reviews.llvm.org/D55595

llvm-svn: 349131
2018-12-14 07:29:06 +00:00
Stephane Moore b69ece899d [clang-tidy] Improve google-objc-function-naming diagnostics 📙
Summary:
The diagnostics from google-objc-function-naming check will be more
actionable if they provide a brief description of the requirements from
the Google Objective-C style guide. The more descriptive diagnostics may
help clarify that functions in the global namespace must have an
appropriate prefix followed by Pascal case (engineers working previously
with static functions might not immediately understand the different
requirements of static and non-static functions).

Test Notes:
Verified against the clang-tidy tests.

Reviewers: benhamilton, aaron.ballman

Reviewed By: benhamilton

Subscribers: MyDeveloperDay, xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D55482

llvm-svn: 349123
2018-12-14 03:13:31 +00:00
Douglas Yung 29bfeb97d4 Revert "[clang-tidy] Share the forced linking code between clang-tidy tool and plugin"
This reverts commit r349038 as it was causing test failures:

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/22185
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/40886

llvm-svn: 349121
2018-12-14 02:04:04 +00:00
Hyrum Wright 35cb7e9fe8 [clang-tidy] Add the abseil-duration-subtraction check
Summary:
This check uses the context of a subtraction expression as well as knowledge
about the Abseil Time types, to infer the type of the second operand of some
subtraction expressions in Duration conversions. For example:

   absl::ToDoubleSeconds(duration) - foo

can become
   absl::ToDoubleSeconds(duration - absl::Seconds(foo))

This ensures that time calculations are done in the proper domain, and also
makes it easier to further deduce the types of the second operands to these
expressions.

Reviewed By: JonasToth

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D55245

llvm-svn: 349073
2018-12-13 19:23:52 +00:00
Eric Liu e2012972f9 [clangd] Enable cross-namespace completions by default in clangd
Summary:
Code completion will suggest symbols from any scope (incl. inaccessible
scopes) when there's no qualifier explicitly specified. E.g.
{F7689815}

As we are assigning relatively low scores for cross-namespace completion items, the overall code completion quality doesn't regress. The feature has been tried out by a few folks, and the feedback is generally positive, so I think it should be ready to be enabled by default.

Reviewers: hokein, ilya-biryukov, kadircet

Reviewed By: hokein, ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D55649

llvm-svn: 349049
2018-12-13 15:35:43 +00:00
Ivan Donchevskii e74d487be8 [clang-tidy] Share the forced linking code between clang-tidy tool and plugin
Extract code that forces linking to the separate header and include it in both plugin and standalone tool

Differential Revision: https://reviews.llvm.org/D55595

llvm-svn: 349038
2018-12-13 14:37:17 +00:00
Haojian Wu bf28533726 [clangd] Refine the way of checking a declaration is referenced by the written code.
Summary:
The previous solution (checking the AST) is not a reliable way to
determine whether a declaration is explicitly referenced by the source
code, we are still missing a few cases.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D55191

llvm-svn: 349033
2018-12-13 13:17:04 +00:00
Haojian Wu e58e0903e2 [clangd] Avoid emitting Queued status when we are able to acquire the Barrier.
Reviewers: ilya-biryukov

Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D55359

llvm-svn: 349032
2018-12-13 13:09:50 +00:00
Haojian Wu 9d0d9f884c [clangd] Move the utility function to anonymous namespace, NFC.
llvm-svn: 349031
2018-12-13 13:07:29 +00:00
Fangrui Song 41c249adc4 Add explicit dependency on clangSerialization after rC348911
llvm-svn: 348916
2018-12-12 08:25:16 +00:00
Jonas Toth 4b59a1fe29 Use the standard Duration factory matcher
Summary: A new check came in over the weekend; it should use our existing infrastructure for matching `absl::Duration` factories.

Patch by hwright.

Reviewers: JonasToth

Reviewed By: JonasToth

Subscribers: astrelni

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D55541

llvm-svn: 348842
2018-12-11 12:45:51 +00:00
Jonas Toth fe7592d48e [clang-tidy] NFC Consolidate test absl::Time implementation
Summary: Several tests re-implement these same prototypes (differently), so we can put them in a common location.

Patch by hwright.

Reviewers: JonasToth

Reviewed By: JonasToth

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D55540

llvm-svn: 348840
2018-12-11 12:42:17 +00:00
Jonas Toth e740145e19 [clang-tidy] insert release notes for new checkers alphabetically
Summary:
Almost all code review comments on new checkers {D55433} {D48866} {D54349} seem to ask for the release notes to be added alphabetically, plus I've seen commits by @Eugene.Zelenko reordering the lists

Make add_new_check.py add those release notes alphabetically based on checker name

If include-fixer section is seen add it at the end

Minor change in the message format to prevent double newlines added before the checker.

Do the tools themselves have unit tests? (sorry new to this game)

- Tested adding new checker at the beginning
- Tested on adding new checker in the middle
- Tested on empty ReleasesNotes.rst (as we would see after RC)

Patch by MyDeveloperDay.

Reviewers: alexfh, JonasToth, curdeius, aaron.ballman, benhamilton, hokein

Reviewed By: JonasToth

Subscribers: cfe-commits, xazax.hun, Eugene.Zelenko

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D55508

llvm-svn: 348793
2018-12-10 19:41:53 +00:00
Eugene Zelenko 7bde7265f2 [Documentation] Alphabetical order in new checks list.
llvm-svn: 348666
2018-12-08 00:07:34 +00:00
Eric Fiselier 2bbbd8be24 [clang-tidy]: Abseil: new check 'abseil-upgrade-duration-conversions'
Patch by Alex Strelnikov.
Reviewed as D53830

Introduce a new check to upgrade user code based on upcoming API breaking changes to absl::Duration.

The check finds calls to arithmetic operators and factory functions for absl::Duration that rely on
an implicit user defined conversion to int64_t. These cases will no longer compile after proposed
changes are released. Suggested fixes explicitly cast the argument int64_t.

llvm-svn: 348633
2018-12-07 20:03:03 +00:00
Haojian Wu 75f6caddab [clang-tidy] Remove duplicated getText implementation, NFC
llvm-svn: 348583
2018-12-07 11:25:37 +00:00
Ilya Biryukov f30c4ad325 [clangd] Remove the test that sometimes deadlocks
Will figure out how to properly rewrite it and recommit.

llvm-svn: 348490
2018-12-06 15:14:11 +00:00
Haojian Wu a44eb93a4b [clangd] Update the test code
I forgot to update it in the last round of code review.

llvm-svn: 348478
2018-12-06 10:22:48 +00:00
Haojian Wu ec3d02013f [clangd] C++ API for emitting file status.
Introduce clangd C++ API to emit the current status of file.

llvm-svn: 348475
2018-12-06 09:41:04 +00:00
Haojian Wu e3fa82fcde [clangd] Fix a typo in TUSchedulerTests
Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D55312

llvm-svn: 348467
2018-12-06 08:55:24 +00:00
Ilya Biryukov 44a40046c8 Move detection of libc++ include dirs to Driver on MacOS
Summary:
The intention is to make the tools replaying compilations from 'compile_commands.json'
(clang-tidy, clangd, etc.) find the same standard library as the original compiler
specified in 'compile_commands.json'.

Previously, the library detection logic was in the frontend (InitHeaderSearch.cpp) and relied
on the value of resource dir as an approximation of the compiler install dir. The new logic
uses the actual compiler install dir and is performed in the driver. This is consistent with
the C++ standard library detection on other platforms and allows to override the resource dir
in the tools using the compile_commands.json without altering the
standard library detection mechanism. The tools have to override the resource dir to make sure
they use a consistent version of the builtin headers.

There is still logic in InitHeaderSearch that attemps to add the absolute includes for the
the C++ standard library, so we keep passing the -stdlib=libc++ from the driver to the frontend
via cc1 args to avoid breaking that. In the long run, we should move this logic to the driver too,
but it could potentially break the library detection on other systems, so we don't tackle it in this
patch to keep its scope manageable.

This is a second attempt to fix the issue, first one was commited in r346652 and reverted in r346675.
The original fix relied on an ad-hoc propagation (bypassing the cc1 flags) of the install dir from the
driver to the frontend's HeaderSearchOptions. Unsurpisingly, the propagation was incomplete, it broke
the libc++ detection in clang itself, which caused LLDB tests to break.

The LLDB tests pass with new fix.

Reviewers: JDevlieghere, arphaman, EricWF

Reviewed By: arphaman

Subscribers: mclow.lists, ldionne, dexonsmith, ioeric, christof, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D54630

llvm-svn: 348365
2018-12-05 14:24:14 +00:00
Kadir Cetinkaya 6f9b204261 [clangd] Dont provide locations for non-existent files.
Summary:
We were getting assertion errors when we had bad file names, instead we
should skip those.

Reviewers: hokein

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D55275

llvm-svn: 348359
2018-12-05 11:57:15 +00:00
Mikael Holmen 18e800f0dd Fix compilation error when using clang 3.6.0
llvm-svn: 348357
2018-12-05 11:29:27 +00:00
Jonas Toth 71a29aa947 Revert "[clang-tidy] new check: bugprone-branch-clone"
The patch broke on buildbot with assertion-failure. Revert until this
is figured out.

llvm-svn: 348344
2018-12-05 09:34:18 +00:00
Jonas Toth cd207f1552 [clang-tidy] new check: bugprone-branch-clone
Summary:
Implement a check for detecting if/else if/else chains where two or more
branches are Type I clones of each other (that is, they contain identical code)
and for detecting switch statements where two or more consecutive branches are
Type I clones of each other.

Patch by donat.nagy.

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: JonasToth

Subscribers: MTC, lebedev.ri, whisperity, xazax.hun, Eugene.Zelenko, mgorny, rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D54757

llvm-svn: 348343
2018-12-05 09:16:25 +00:00
Jonas Toth c361e0d627 Fix a false positive in misplaced-widening-cast
Summary:
bugprone-misplaced-widening-cast check
used to give a false warning to the
following example.

 enum DaysEnum{
    MON = 0,
    TUE = 1
    };

 day = (DaysEnum)(day + 1);
 //warning: either cast from 'int' to 'DaysEnum' is ineffective...

But i think int to enum cast is not widening neither ineffective.

Patch by dkrupp.

Reviewers: JonasToth, alexfh

Reviewed By: alexfh

Subscribers: rnkovacs, Szelethus, gamesh411, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D55255

llvm-svn: 348341
2018-12-05 08:29:56 +00:00
Stephane Moore af4755aca8 [clang-tidy/checks] Update objc-property-declaration check to allow arbitrary acronyms and initialisms 🔧
Summary:
§1 Description

This changes the objc-property-declaration check to allow arbitrary acronyms and initialisms instead of using whitelisted acronyms. In Objective-C it is relatively common to use project prefixes in property names for the purposes of disambiguation. For example, the CIColor¹ and CGColor² properties on UIColor both represent symbol prefixes being used in proeprty names outside of Apple's accepted acronyms³. The union of Apple's accepted acronyms and all symbol prefixes that might be used for disambiguation in property declarations effectively allows for any arbitrary sequence of capital alphanumeric characters to be acceptable in property declarations. This change updates the check accordingly.

The test variants with custom configurations are deleted as part of this change because their configurations no longer impact behavior. The acronym configurations are currently preserved for backwards compatibility of check configuration.

[1] https://developer.apple.com/documentation/uikit/uicolor/1621951-cicolor?language=objc
[2] https://developer.apple.com/documentation/uikit/uicolor/1621954-cgcolor?language=objc
[3] https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/APIAbbreviations.html#//apple_ref/doc/uid/20001285-BCIHCGAE

§2 Test Notes

Changes verified by:
• Running clang-tidy unit tests.
• Used check_clang_tidy.py to verify expected output of processing objc-property-declaration.m

Reviewers: benhamilton, Wizard

Reviewed By: benhamilton

Subscribers: jfb, cfe-commits

Differential Revision: https://reviews.llvm.org/D51832

llvm-svn: 348331
2018-12-05 03:44:03 +00:00
George Karpenkov d499725b8f [clang-query] Continue if compilation command not found for some files
When searching for a code pattern in an entire project with a
compilation database it's tempting to run

```
clang-query **.cpp
```

And yet, that often breaks because some files are just not in the
compilation database: tests, sample code, etc..
clang-query should not stop when encountering such cases.

Differential Revision: https://reviews.llvm.org/D51183

llvm-svn: 348328
2018-12-05 02:02:40 +00:00
Stephane Moore f6d96e0f98 [clang-tidy] Ignore namespaced and C++ member functions in google-objc-function-naming check 🙈
Summary: The google-objc-function-naming check applies to functions that are not namespaced and should not be applied to C++ member functions. Such function declarations should be ignored by the check to avoid false positives in Objective-C++ sources.

Reviewers: benhamilton, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D55101

llvm-svn: 348317
2018-12-04 23:40:42 +00:00
Eugene Zelenko 86c804d3f8 [Documentation] Make options section in Clang-tidy readability-uppercase-literal-suffix consistent with other checks.
llvm-svn: 348302
2018-12-04 21:19:08 +00:00
Simon Pilgrim 2d12d810f4 Fix "array must be initialized with a brace-enclosed initializer" build error.
Try to fix clang-bpf-build buildbot.

llvm-svn: 348262
2018-12-04 14:07:29 +00:00
Kadir Cetinkaya 219c0fae5c [clangd] Partition include graph on auto-index.
Summary:
Partitions include graphs in auto-index so that each shards contains
only part of the include graph related to itself.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D55062

llvm-svn: 348252
2018-12-04 11:31:57 +00:00
Eugene Zelenko 1dbbc5f640 [Documentation] Fix formatting and wrap up to 80 characters in Clang-tidy readability-uppercase-literal-suffix documentation.
llvm-svn: 348202
2018-12-03 22:35:40 +00:00
Zachary Turner aa2711f1f8 Fix compilation failure on Windows.
This was introduced earlier but apparently used an incorrect
class name so it doesn't compile on Windows.

llvm-svn: 348176
2018-12-03 19:59:00 +00:00
Jonas Toth 3f51ee19ae [clang-tidy] Fix unordered_map failure with specializing std::hash<> and remove previous wrong attempt at doing so
llvm-svn: 348172
2018-12-03 19:41:04 +00:00
Jonas Toth 00f1d76738 [clang-tidy] Recommit: Add the abseil-duration-comparison check
Summary:
This check finds instances where Duration values are being converted to a numeric value in a comparison expression, and suggests that the conversion happen on the other side of the expression to a Duration.  See documentation for examples.

This also shuffles some code around so that the new check may perform in sone step simplifications also caught by other checks.
Compilation is unbroken, because the hash-function is now directly
specified for std::unordered_map, as 'enum class' does not compile as
key (seamingly only on some compilers).

Patch by hwright.

Reviewers: aaron.ballman, JonasToth, alexfh, hokein

Reviewed By: JonasToth

Subscribers: sammccall, Eugene.Zelenko, xazax.hun, cfe-commits, mgorny

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D54737

llvm-svn: 348169
2018-12-03 19:22:08 +00:00
Jonas Toth b77711e297 Revert "[clang-tidy] Add the abseil-duration-comparison check"
This commit broke buildbots and needs adjustments.

llvm-svn: 348165
2018-12-03 18:59:27 +00:00
Jonas Toth 5da1825ebc [clang-tidy] Add the abseil-duration-comparison check
Summary:
This check finds instances where Duration values are being converted to a numeric value in a comparison expression, and suggests that the conversion happen on the other side of the expression to a Duration.  See documentation for examples.

This also shuffles some code around so that the new check may perform in sone step simplifications also caught by other checks.

Patch by hwright.

Reviewers: aaron.ballman, JonasToth, alexfh, hokein

Reviewed By: JonasToth

Subscribers: sammccall, Eugene.Zelenko, xazax.hun, cfe-commits, mgorny

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D54737

llvm-svn: 348161
2018-12-03 18:35:56 +00:00
Ilya Biryukov 1712bc7640 [clangd] Avoid memory-mapping files on Windows
Summary:
Memory-mapping files on Windows leads to them being locked and prevents
editors from saving changes to those files on disk. This is fine for the
compiler, but not acceptable for an interactive tool like clangd.
Therefore, we choose to avoid using memory-mapped files on Windows.

Reviewers: hokein, kadircet

Reviewed By: kadircet

Subscribers: yvvan, zturner, nik, malaperle, mgorny, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D55139

llvm-svn: 348147
2018-12-03 15:21:49 +00:00
Haojian Wu 7800dbe157 [clangd] Fix a stale comment, NFC.
llvm-svn: 348133
2018-12-03 13:16:04 +00:00
Haojian Wu dd61ccbb70 [clangd] Get rid of AST matchers in CodeComplete, NFC
Summary:
The isIndexedForCodeCompletion is called in the code patch of
SymbolCollector.

Reviewers: kadircet

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D55206

llvm-svn: 348130
2018-12-03 12:53:19 +00:00
Fangrui Song 23b123f675 [clangd] Recommit the "AnyScope" changes in requests.json by rCTE347753 (reverted by rCTE347792)
This fixes IndexBenchmark tests.

llvm-svn: 348066
2018-12-01 01:57:15 +00:00
Kadir Cetinkaya 5399552da1 [clangd] Populate include graph during static indexing action.
Summary:
This is the second part for introducing include hierarchy into index
files produced by clangd. You can see the base patch that introduces structures
and discusses the future of the patches in D54817

Reviewers: ilya-biryukov

Subscribers: mgorny, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D54999

llvm-svn: 348005
2018-11-30 16:59:00 +00:00
Eric Liu 5ac37f495a [clangd] Penalize destructor and overloaded operators in code completion.
Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D55061

llvm-svn: 347983
2018-11-30 11:17:15 +00:00
Eric Liu b1317fa8df [clangd] Drop injected class name when class scope is not explicitly specified.
Summary: E.g. allow injected "A::A" in `using A::A^` but not in "A^".

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D55065

llvm-svn: 347982
2018-11-30 11:12:40 +00:00
Haojian Wu 260f83c426 [clangd] Bump vscode-clangd v0.0.8
llvm-svn: 347969
2018-11-30 09:18:31 +00:00
Haojian Wu a5f6a93889 [clangd] Fix junk output in clangd vscode plugin
Summary:
When using the vscode clangd plugin, lots and lots of junk output is printed to the output window, which constantly reopens itself.
Example output:

I[11:13:17.733] <-- textDocument/codeAction(4)
I[11:13:17.733] --> reply:textDocument/codeAction(4) 0 ms
I[11:13:17.937] <-- textDocument/codeAction(5)
I[11:13:17.937] --> reply:textDocument/codeAction(5) 0 ms
I[11:13:18.557] <-- textDocument/hover(6)
I[11:13:18.606] --> reply:textDocument/hover(6) 48 ms

This should prevent that from happening.

Patch by James Findley!

Reviewers: ioeric, ilya-biryukov, hokein

Reviewed By: ioeric

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D55052

llvm-svn: 347968
2018-11-30 09:14:52 +00:00
Aaron Ballman 3e3696bf46 Adding a FIXME test to document an area for improvement with the cert-err58-cpp check; NFC.
llvm-svn: 347860
2018-11-29 12:45:50 +00:00
Eugene Zelenko 54c82d3642 [Documentation] Try to fix build failure in cppcoreguidelines-narrowing-conversions documentation
llvm-svn: 347825
2018-11-29 02:13:25 +00:00
Matthew Voss bc5679eaff Ensure that test clang-tidy/export-relpath.cpp works with Windows path separators.
llvm-svn: 347815
2018-11-28 22:16:18 +00:00
Matthew Voss 2c8a054310 Revert "[clang-tools-extra] r347753 - [clangd] Build and test IndexBenchmark in check-clangd"
This revision was causing failures on the buildbots, and our internal CI.

See: http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/20856
llvm-svn: 347792
2018-11-28 18:48:32 +00:00
Aaron Ballman e0fddb4e56 Fix false positive with lambda assignments in cert-err58-cpp.
This check is about preventing exceptions from being thrown before main() executes, and assigning a lambda (rather than calling it) to a global object cannot throw any exceptions.

llvm-svn: 347761
2018-11-28 15:04:38 +00:00
Ilya Biryukov 8a0a5a3197 [clang-tidy] Added a test -export-fixes with relative paths.
Summary: A test for D51864.

Reviewers: ioeric, steveire

Reviewed By: steveire

Subscribers: xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D51865

llvm-svn: 347760
2018-11-28 14:43:26 +00:00
Hans Wennborg cab8dd692e Re-commit r347419 "Update call to EvaluateAsInt() to the new syntax."
llvm-svn: 347757
2018-11-28 14:04:26 +00:00
Eric Liu 1208240ac9 [clangd] Fix test broken in r347754.
llvm-svn: 347755
2018-11-28 14:00:09 +00:00
Eric Liu e9a33b7ece [clangd] Less penalty for cross-namespace completions.
llvm-svn: 347754
2018-11-28 13:45:25 +00:00
Haojian Wu 90754ef22a [clangd] Build and test IndexBenchmark in check-clangd
Summary:
Include IndexBenchmark in check-clangd to make sure we won't forget to update
it when doing breaking changes; also fix an out-of-date test input.

Reviewers: ilya-biryukov

Subscribers: mgorny, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D54998

llvm-svn: 347753
2018-11-28 13:31:05 +00:00
Aaron Ballman dda6290f16 Fix a false-positive with cert-err58-cpp.
If a variable is declared constexpr then its initializer needs to be a constant expression, and thus, cannot throw. This check is about not throwing exceptions before main() runs, and so it doesn't apply if the initializer cannot throw. This silences the diagnostic when initializing a constexpr variable and fixes PR35457.

llvm-svn: 347745
2018-11-28 11:57:13 +00:00
Eric Liu 4d814a93e5 [clangd] Canonicalize file path in URIForFile.
Summary:
File paths in URIForFile can come from index or local AST. Path from
index goes through URI transformation and the final path is resolved by URI
scheme and could be potentially different from the original path. Hence, we
should do the same transformation for all paths. We do this in URIForFile, which
now converts a path to URI and back to a canonicalized path.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D54845

llvm-svn: 347739
2018-11-28 10:30:42 +00:00
Jan Korous 613c80d22f [clangd] Fix backward-compatibility - follow-up to textDocument/SymbolInfo
Apparently clang 3.6 couldn't build the preceding patch.

llvm-svn: 347738
2018-11-28 10:24:07 +00:00
Haojian Wu d7ef7ff5b2 [clangd] Bump vscode-clangd v0.0.7
llvm-svn: 347737
2018-11-28 10:23:15 +00:00
Jan Korous b406701f66 [clangd] textDocument/SymbolInfo extension
New method returning symbol info for given source position.

Differential Revision: https://reviews.llvm.org/D54799

rdar://problem/46050281

llvm-svn: 347675
2018-11-27 16:40:46 +00:00
Jan Korous 6089b6192e [clangd][NFC] Move SymbolID to a separate file
Prerequisity for textDocument/SymbolInfo

Differential Revision: https://reviews.llvm.org/D54799

llvm-svn: 347674
2018-11-27 16:40:34 +00:00
Malcolm Parsons d8851b5def [clang-tidy] Ignore bool -> single bit bitfield conversion in readability-implicit-bool-conversion
Summary: There is no ambiguity / information loss in this conversion

Reviewers: alexfh, aaron.ballman, hokein

Reviewed By: alexfh

Subscribers: xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D54941

llvm-svn: 347671
2018-11-27 16:23:39 +00:00
Kadir Cetinkaya d08eab4281 [clangd] Put direct headers into srcs section.
Summary:
Currently, there's no way of knowing about header files
using compilation database, since it doesn't contain header files as entries.

Using this information, restoring from cache using compile commands becomes
possible instead of doing directory traversal. Also, we can issue indexing
actions for out-of-date headers even if source files depending on them haven't
changed.

Reviewers: sammccall

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D54817

llvm-svn: 347669
2018-11-27 16:08:53 +00:00
Hans Wennborg 02f5511ff4 Revert r347419 "Update call to EvaluateAsInt() to the new syntax."
It's pre-requisite was reverted in r347656.

llvm-svn: 347657
2018-11-27 14:15:37 +00:00
Sam McCall 032f3e7fd8 [clangd] Prevent thread starvation in tests on loaded systems.
Summary:
Background index deliberately runs low-priority, but for tests this may stop
them making progress.

Reviewers: kadircet

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jfb, cfe-commits

Differential Revision: https://reviews.llvm.org/D54938

llvm-svn: 347655
2018-11-27 12:09:13 +00:00
Alexander Kornienko 8577dcc533 [clang-tidy] Avoid inconsistent notes in readability-container-size-empty
When a warning is issued in a template instantiation, the check would previously
use template arguments in a note, which would result in inconsistent or
duplicate warnings (depending on how deduplication was done). This patch removes
template arguments from the note.

llvm-svn: 347652
2018-11-27 10:53:44 +00:00
Alexander Kornienko 6f6b2ba9ab [clang-tidy] Minor fixes in a test
Use CHECK-FIXES where it was intended instead of CHECK-MESSAGES. Fixed compiler
warnings to pacify YouCompleteMe.

llvm-svn: 347651
2018-11-27 10:53:38 +00:00
Henry Wong 1a1fbdc6ef [clangd] NFC: Prefer `isa<>` to `dyn_cast<>` to do the checking.
Summary: Prefer `isa<>` to `dyn_cast<>` when there only need a checking.

Reviewers: ilya-biryukov, MaskRay

Reviewed By: ilya-biryukov, MaskRay

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits, MTC

Differential Revision: https://reviews.llvm.org/D54878

llvm-svn: 347635
2018-11-27 04:27:00 +00:00
Ilya Biryukov e8ccb8238d [clangd] Do not drop diagnostics from macros
if they still end up being in the main file.

llvm-svn: 347574
2018-11-26 17:05:13 +00:00
Guillaume Chatelet 10a7ee7044 [clang-tidy] Improving narrowing conversions
Summary:
Newly flagged narrowing conversions:
 - integer to narrower signed integer (this is compiler implementation defined),
 - integer - floating point narrowing conversions,
 - floating point - integer narrowing conversions,
 - constants with narrowing conversions (even in ternary operator).

Reviewers: hokein, alexfh, aaron.ballman, JonasToth

Reviewed By: aaron.ballman, JonasToth

Subscribers: lebedev.ri, courbet, nemanjai, xazax.hun, kbarton, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D53488

llvm-svn: 347570
2018-11-26 16:25:55 +00:00
Sam McCall 422c828dfc [clangd] Enable auto-index behind a flag.
Summary:
Ownership and configuration:
The auto-index (background index) is maintained by ClangdServer, like Dynamic.
(This means ClangdServer will be able to enqueue preamble indexing in future).
For now it's enabled by a simple boolean flag in ClangdServer::Options, but
we probably want to eventually allow injecting the storage strategy.

New 'sync' command:
In order to meaningfully test the integration (not just unit-test components)
we need a way for tests to ensure the asynchronous index reads/writes occur
before a certain point.
Because these tests and assertions are few, I think exposing an explicit "sync"
command for use in tests is simpler than allowing threading to be completely
disabled in the background index (as we do for TUScheduler).

Bugs:
I fixed a couple of trivial bugs I found while testing, but there's one I can't.
JSONCompilationDatabase::getAllFiles() may return relative paths, and currently
we trigger an assertion that assumes they are absolute.
There's no efficient way to resolve them (you have to retrieve the corresponding
command and then resolve against its directory property). In general I think
this behavior is broken and we should fix it in JSONCompilationDatabase and
require CompilationDatabase::getAllFiles() to be absolute.

Reviewers: kadircet

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D54894

llvm-svn: 347567
2018-11-26 16:00:11 +00:00
Ilya Biryukov d60c289625 [clangd] Fix compilation of IndexBenchmark
llvm-svn: 347566
2018-11-26 15:58:29 +00:00
Ilya Biryukov 4d3d82eef9 [clangd] Fix use-after-free with expected types in indexing
llvm-svn: 347563
2018-11-26 15:52:16 +00:00
Ilya Biryukov 647da3e8a5 [clangd] Add type boosting in code completion
Reviewers: sammccall, ioeric

Reviewed By: sammccall

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D52276

llvm-svn: 347562
2018-11-26 15:38:01 +00:00
Ilya Biryukov a21392bfc7 [clangd] Collect and store expected types in the index
Summary:
And add a hidden option to control whether the types are collected.
For experiments, will be removed when expected types implementation
is stabilized.

The index size is almost unchanged, e.g. the YAML index for all clangd
sources increased from 53MB to 54MB.

Reviewers: ioeric, sammccall

Reviewed By: sammccall

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D52274

llvm-svn: 347560
2018-11-26 15:29:14 +00:00
Ilya Biryukov d360b2984e [clangd] Initial implementation of expected types
Summary:
Provides facilities to model the C++ conversion rules without the AST.
The introduced representation can be stored in the index and used to
implement type-based ranking improvements for index-based completions.

Reviewers: sammccall, ioeric

Reviewed By: sammccall

Subscribers: malaperle, mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D52273

llvm-svn: 347559
2018-11-26 15:25:20 +00:00
Sam McCall 7d0e4848ad [clangd] Fix missing include from r347538 - fix windows buildbots
llvm-svn: 347554
2018-11-26 13:35:02 +00:00
Haojian Wu 77c56fffad [clang-tidy] No warning for auto new expression in smart check
Summary: The fix for `auto` new expression is illegal.

Reviewers: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D54832

llvm-svn: 347551
2018-11-26 12:42:08 +00:00
Eric Liu 4fac50e72f [clangd] Tune down scope boost for global scope
Summary:
This improves cross-namespace completions and has ignorable
impact on other completion types.

Metrics
```
==================================================================================================
                                        OVERALL (excl. CROSS_NAMESPACE)
==================================================================================================
  Total measurements: 109367 (-6)
  All measurements:
	MRR: 68.11 (+0.04)	Top-1: 58.59% (+0.03%)	Top-5: 80.00% (+0.01%)	Top-100: 95.92% (-0.02%)
  Full identifiers:
	MRR: 98.35 (+0.09)	Top-1: 97.87% (+0.17%)	Top-5: 98.96% (+0.01%)	Top-100: 99.03% (+0.00%)
  Filter length 0-5:
	MRR:      23.20 (+0.05)		58.72 (+0.01)		70.16 (-0.03)		73.44 (+0.03)		76.24 (+0.00)		80.79 (+0.14)
	Top-1:    11.90% (+0.03%)		45.07% (+0.03%)		58.49% (-0.05%)		62.44% (-0.02%)		66.31% (-0.05%)		72.10% (+0.07%)
	Top-5:    35.51% (+0.08%)		76.94% (-0.01%)		85.10% (-0.13%)		87.40% (-0.02%)		88.65% (+0.01%)		91.84% (+0.17%)
	Top-100:  83.25% (-0.02%)		96.61% (-0.15%)		98.15% (-0.02%)		98.43% (-0.01%)		98.53% (+0.01%)		98.66% (+0.02%)

==================================================================================================
                                        CROSS_NAMESPACE
==================================================================================================
  Total measurements: 17702 (+27)
  All measurements:
	MRR: 28.12 (+3.26)	Top-1: 21.07% (+2.70%)	Top-5: 35.11% (+4.48%)	Top-100: 74.31% (+1.02%)
  Full identifiers:
	MRR: 79.20 (+3.72)	Top-1: 71.78% (+4.86%)	Top-5: 88.39% (+2.84%)	Top-100: 98.99% (+0.00%)
  Filter length 0-5:
	MRR:      0.92 (-0.10)		5.51 (+0.57)		18.30 (+2.34)		21.62 (+3.76)		32.00 (+6.00)		41.55 (+7.61)
	Top-1:    0.56% (-0.08%)		2.44% (+0.15%)		9.82% (+1.47%)		12.59% (+2.16%)		21.17% (+4.47%)		30.05% (+6.72%)
	Top-5:    1.20% (-0.15%)		7.14% (+1.04%)		25.17% (+3.91%)		29.74% (+5.90%)		43.29% (+9.59%)		54.75% (+9.79%)
	Top-100:  5.49% (-0.01%)		56.22% (+2.59%)		86.69% (+1.08%)		89.03% (+2.04%)		93.74% (+0.78%)		96.99% (+0.59%)
```

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D54851

llvm-svn: 347548
2018-11-26 12:12:01 +00:00
Haojian Wu 43efc6ba65 [clangd] Use testPath in the test.
llvm-svn: 347547
2018-11-26 11:18:16 +00:00
Alexander Kornienko f90bdf73a2 [clang-tidy] PrintStackTraceOnErrorSignal
llvm-svn: 347546
2018-11-26 11:11:52 +00:00
Ilya Biryukov 4174d09680 [clangd] Cleanup after landing documentSymbol. NFC
- fix compile error on older gcc in Protocol.cpp,
- remove redundant 'llvm::' qualifiers from Protocol.cpp,
- remove unused variables in AST.cpp

llvm-svn: 347539
2018-11-26 09:57:41 +00:00
Sam McCall 6e2d2a33b6 [clangd] Auto-index watches global CDB for changes.
Summary:
Instead of receiving compilation commands, auto-index is triggered by just
filenames to reindex, and gets commands from the global comp DB internally.
This has advantages:
 - more of the work can be done asynchronously (fetching compilation commands
   upfront can be slow for large CDBs)
 - we get access to the CDB which can be used to retrieve interpolated commands
   for headers (useful in some cases where the original TU goes away)
 - fits nicely with the filename-only change observation from r347297

The interface to GlobalCompilationDatabase gets extended: when retrieving a
compile command, the GCDB can optionally report the project the file belongs to.
This naturally fits together with getCompileCommand: it's hard to implement one
without the other. But because most callers don't care, I've ended up with an
awkward optional-out-param-in-virtual method pattern - maybe there's a better
one.

This is the main missing integration point between ClangdServer and
BackgroundIndex, after this we should be able to add an auto-index flag.

Reviewers: ioeric, kadircet

Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov

Differential Revision: https://reviews.llvm.org/D54865

llvm-svn: 347538
2018-11-26 09:51:50 +00:00
Haojian Wu dbfa9c3e0a [clang-tidy] Don't generate incorrect fixes for class with deleted copy constructor in smart_ptr check.
Summary:
The fix for aggregate initialization (`std::make_unique<Foo>(Foo {1, 2})` needs
to see Foo copy constructor, otherwise we will have a compiler error. So we
only emit the check warning.

Reviewers: JonasToth, aaron.ballman

Subscribers: xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D54745

llvm-svn: 347537
2018-11-26 09:33:08 +00:00
Alexander Kornienko 976e0c07a0 A bit of AST matcher cleanup, NFC.
Removed the uses of the allOf() matcher inside node matchers that are implicit
allOf(). Replaced uses of allOf() with the explicit node matcher where it makes
matchers more readable. Replace anyOf(hasName(), hasName(), ...) with the more
efficient and readable hasAnyName().

llvm-svn: 347520
2018-11-25 02:41:01 +00:00
Marc-Andre Laperle 479f018b2b [clangd] Add 'Switch header/source' command in clangd-vscode
Summary:
Alt+o is used on Windows/Linux and Option+Cmd+o on macOS.

Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>

Reviewers: hokein, ilya-biryukov, ioeric

Reviewed By: ioeric

Subscribers: sammccall, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D54781

llvm-svn: 347509
2018-11-24 02:53:17 +00:00
Ilya Biryukov 19d75608f8 [clangd] Add support for hierarchical documentSymbol
Reviewers: ioeric, sammccall, simark

Reviewed By: sammccall

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D52311

llvm-svn: 347498
2018-11-23 15:21:19 +00:00
Benjamin Kramer da113f3202 Remove the optional dependency from libclang to clang-tidy/include-fixer
clangd does a better job on both of these, so don't slow down everyone's build
for a poorly working libclang feature.

llvm-svn: 347496
2018-11-23 15:02:33 +00:00
Alexander Kornienko daa515e6a1 [clang-tidy] Ignore matches in template instantiations (cert-dcl21-cpp)
The test fails with a local modification to
clang-tidy/ClangTidyDiagnosticConsumer.cpp to include fixes into the key when
deduplicating the warnings.

llvm-svn: 347495
2018-11-23 14:30:14 +00:00
Ilya Biryukov 16cc195e8d [clangd] Cleanup: make the diags callback global in TUScheduler
Reviewers: sammccall

Reviewed By: sammccall

Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D54760

llvm-svn: 347474
2018-11-22 17:27:08 +00:00
Ilya Biryukov 27b83d230d [clangd] Cleanup error consumption code. NFC
- Remove reimplementations of llvm::consumeError.
- Simplify test code by using EXPECT_ERROR where it fits.

llvm-svn: 347472
2018-11-22 16:20:12 +00:00
Alexander Kornienko b34b6ffa9d [clang-tidy] Ignore template instantiations in modernize-use-using
The test I'm adding passes without the change due to the deduplication logic in
ClangTidyDiagnosticConsumer::take(). However this bug manifests in our internal
integration with clang-tidy.
I've verified the fix by locally changing LessClangTidyError to consider
replacements.

llvm-svn: 347470
2018-11-22 16:10:18 +00:00
Ilya Biryukov c76394bc4b [clangd] Cleanup: make diagnostics callbacks from TUScheduler non-racy
Summary:
Previously, removeDoc followed by an addDoc to TUScheduler resulted in
racy diagnostic responses, i.e. the old dianostics could be delivered
to the client after the new ones by TUScheduler.

To workaround this, we tracked a version number in ClangdServer and
discarded stale diagnostics. After this commit, the TUScheduler will
stop delivering diagnostics for removed files and the workaround in
ClangdServer is not required anymore.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, jfb, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D54829

llvm-svn: 347468
2018-11-22 15:39:54 +00:00
Eric Liu c0ac4bb17c [clangd] Cleanup: stop passing around list of supported URI schemes.
Summary:
Instead of passing around a list of supported URI schemes in clangd, we
expose an interface to convert a path to URI using any compatible scheme
that has been registered. It favors customized schemes and falls
back to "file" when no other scheme works.

Changes in this patch are:
- URI::create(AbsPath, URISchemes) -> URI::create(AbsPath). The new API finds a
compatible scheme from the registry.
- Remove URISchemes option everywhere (ClangdServer, SymbolCollecter, FileIndex etc).
- Unit tests will use "unittest" by default.
- Move "test" scheme from ClangdLSPServer to ClangdMain.cpp, and only
register the test scheme when lit-test or enable-lit-scheme is set.
(The new flag is added to make lit protocol.test work; I wonder if there
is alternative here.)

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D54800

llvm-svn: 347467
2018-11-22 15:02:05 +00:00
Eric Liu 5628c1455f [clangd] Cleanup: use index file instead of header in workspace symbols lit test.
Summary:
The full path of the input header depends on the execution environment
and may result in different behavior (e.g. when different URI schemes are used).

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D54833

llvm-svn: 347466
2018-11-22 14:59:22 +00:00
Benjamin Kramer 2c3477596f [clangd] Fix use-after-scope in unit test
The scheduler holds a reference to `Proceed`, so it has to be destroyed
after the scheduler. Found by asan.

llvm-svn: 347460
2018-11-22 12:54:25 +00:00
Sam McCall a2b048bc4b [clangd] Respect task cancellation in TUScheduler.
Summary:
- Reads are never executed if canceled before ready-to run.
  In practice, we finalize cancelled reads eagerly and out-of-order.
- Cancelled reads don't prevent prior updates from being elided, as they don't
  actually depend on the result of the update.
- Updates are downgraded from WantDiagnostics::Yes to WantDiagnostics::Auto when
  cancelled, which allows them to be elided when all dependent reads are
  cancelled and there are subsequent writes. (e.g. when the queue is backed up
  with cancelled requests).

The queue operations aren't optimal (we scan the whole queue for cancelled
tasks every time the scheduler runs, and check cancellation twice in the end).
However I believe these costs are still trivial in practice (compared to any
AST operation) and the logic can be cleanly separated from the rest of the
scheduler.

Reviewers: ilya-biryukov

Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D54746

llvm-svn: 347450
2018-11-22 10:22:16 +00:00
Haojian Wu af5b1603ea Move the llvm lit test dependencies to clang-tools-extra.
Summary: Part of revert r343473

Reviewers: mgorny

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D54798

llvm-svn: 347449
2018-11-22 10:14:55 +00:00