Commit Graph

4392 Commits

Author SHA1 Message Date
Eric Liu 37b45dc22c [clangd] Fix an assertion in TypoCorrection.
Summary: https://github.com/clangd/clangd/issues/7

Reviewers: sammccall, hokein

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

Tags: #clang

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

llvm-svn: 353514
2019-02-08 13:27:47 +00:00
Kadir Cetinkaya b88144e4ba [clangd] Mention indexing in docs.
Reviewers: sammccall

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

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

llvm-svn: 353423
2019-02-07 16:10:39 +00:00
Kadir Cetinkaya ee23633eab [clangd] Reduce number of threads used by BackgroundIndex to number of physical cores.
Summary:
clangd is using as many threads as logical cores for BackgroundIndex
by default. We observed that it increases latency of foreground tasks.

This patch aims to change that default to number of physical cores to get rid of
that extra latency.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 353422
2019-02-07 16:04:30 +00:00
Haojian Wu ddd64a4f50 [clangd] Fix an assertion failure in Selection.
Summary:
The assertion is triggered when the Decl is null.

Details for the assertion:

F0207 09:55:09.069385   47308 logging.cc:84] assert.h assertion failed at llvm/include/llvm/Support/Casting.h:105 in static bool llvm::isa_impl_cl<clang::TranslationUnitDecl, const clang::      Decl *>::doit(const From *) [To = clang::TranslationUnitDecl, From = const clang::Decl *]: Val && "isa<> used on a null pointer"
 15 *** Check failure stack trace: ***
 19     @     0x55615c1f7e06  __assert_fail
 20     @     0x55615a6297d8  clang::clangd::(anonymous namespace)::SelectionVisitor::TraverseDecl()
 21     @     0x55615a62f48d  clang::RecursiveASTVisitor<>::TraverseTemplateTemplateParmDecl()
 22     @     0x55615a62b264  clang::RecursiveASTVisitor<>::TraverseDecl()
 23     @     0x55615a62979c  clang::clangd::(anonymous namespace)::SelectionVisitor::TraverseDecl()
 24     @     0x55615a63060c  clang::RecursiveASTVisitor<>::TraverseClassTemplatePartialSpecializationDecl()
 25     @     0x55615a62ae45  clang::RecursiveASTVisitor<>::TraverseDecl()

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 353421
2019-02-07 16:00:44 +00:00
Fangrui Song 8ebb854bc2 [ELF] Format lines inadvertently indented by rCTE353380
llvm-svn: 353415
2019-02-07 15:38:14 +00:00
Eric Liu 4b68d910d9 [clangd] Use Dex for dynamic index by default.
Summary:
Memory usage for a sample TU:
  Without Dex: 17.9M
  With    Dex: 24.4M

The memory increase is considerable but seems tolerable.

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

Tags: #clang

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

llvm-svn: 353413
2019-02-07 15:34:37 +00:00
Jonas Toth a822b1155e [clang-tidy] Fixed a std::bind() transformation
There was an extra semicolon that was somehow working in some contexts.

Patch by oleg.smolsky.

llvm-svn: 353389
2019-02-07 11:00:59 +00:00
Alexander Kornienko 68d5652380 [clang-tidy] Expand and clarify the NOLINT documentation a bit.
llvm-svn: 353382
2019-02-07 10:34:43 +00:00
Eric Liu a9e9c506aa [clangd] Suggest adding missing includes for typos (like include-fixer).
Summary:
This adds include-fixer feature into clangd based on D56903. Clangd now captures
diagnostics caused by typos and attach include insertion fixes to potentially
fix the typo.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

llvm-svn: 353380
2019-02-07 09:23:22 +00:00
Roman Lebedev 058b628264 [clang-tidy] modernize-avoid-c-arrays: avoid main function (PR40604)
Summary:
The check should ignore the main function, the program entry point.
It is not possible to use `std::array<>` for the `argv`.
The alternative is to use `char** argv`.

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=40604 | PR40604 ]]

Reviewers: JonasToth, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: xazax.hun, hans, cfe-commits

Tags: #clang-tools-extra, #clang

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

llvm-svn: 353327
2019-02-06 19:17:30 +00:00
Eric Liu d7cb5b8a33 [clangd] Add type boost to fuzzy find in Dex.
Summary:
No noticeable impact on code completions overall except some improvement on
cross-namespace completion.

Reviewers: sammccall, ilya-biryukov

Reviewed By: sammccall

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

Tags: #clang

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

llvm-svn: 353310
2019-02-06 15:36:23 +00:00
Haojian Wu ea27b59a86 [clangd] Bump vscode-clangd v0.0.11
CHANGELOG:
- activate the extension on ObjC files.

llvm-svn: 353309
2019-02-06 15:29:54 +00:00
Haojian Wu 12e194cbb7 [clangd] Format tweak's replacements.
llvm-svn: 353306
2019-02-06 15:24:50 +00:00
Ilya Biryukov 8e42c62240 [clangd] Update dev dependencies of clangd-vscode
Summary:
The version bumps are a result of running `npm audit`, which found
3 security issues in previous versions of our dependencies.

Also add 'package-lock.json' to the repo, it's a common practice to
check in those files into the repository to get consistent versions of
dependencies when running on different machines.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 353296
2019-02-06 13:53:24 +00:00
Ilya Biryukov 7a621551a3 [clangd] Enable clangd on Objective-C in VSCode
Summary: Thanks to Andreas Ostermeyer for raising this on the mailing list.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 353295
2019-02-06 13:47:49 +00:00
Haojian Wu ac6d2e1b16 [clangd] Add CLI flag "-clang-tidy" to enable/disable running clang-tidy checks.
Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 353284
2019-02-06 09:10:47 +00:00
Haojian Wu 5dcc66d0b8 [clangd] Some minor fixes.
Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 353283
2019-02-06 09:08:26 +00:00
Malcolm Parsons a7c957fd81 [clang-tidy] Handle unions with existing default-member-init
Summary:
clang-tidy's modernize-use-default-member-init was crashing for unions
with an existing default member initializer.

Fixes PR40492

Reviewers: aaron.ballman, alexfh, JonasToth

Reviewed By: JonasToth

Subscribers: JonasToth, riccibruno, xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

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

llvm-svn: 353092
2019-02-04 21:09:31 +00:00
Hyrum Wright 1c250bf296 [clang-tidy] Add the abseil-duration-unnecessary-conversion check
Differential Revision: https://reviews.llvm.org/D57353

llvm-svn: 353079
2019-02-04 19:28:20 +00:00
Kadir Cetinkaya c3dcd2673e [clangd] Enable include insertion for static index
Summary:
This enables include insertion by adding canonical includes into
preambledata.

Reviewers: ioeric, ilya-biryukov

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

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

llvm-svn: 353054
2019-02-04 16:19:57 +00:00
Haojian Wu 8e933c1ccf [clangd] Bump vscode-clangd v0.0.10
CHANGELOG:
- cleanup filestatus caches when clangd crashes
- extension workwith LSP v3.14.0, support go-to-declaration feature

llvm-svn: 353027
2019-02-04 09:26:42 +00:00
Haojian Wu a1b0596916 [clangd] Update vscode dependencies
This allows us to use latest LSP v3.14.0 (for go-to-declaration feature).

llvm-svn: 353026
2019-02-04 09:20:41 +00:00
Simon Pilgrim 22f538ce11 Remove trailing semicolon. NFCI.
llvm-svn: 352991
2019-02-03 14:11:32 +00:00
Simon Pilgrim e9a136b58f Remove trailing semicolon. NFCI.
llvm-svn: 352990
2019-02-03 14:08:30 +00:00
Stephane Moore 003311270b Revert rCTE352968 due to compilation failures 💥
llvm-svn: 352969
2019-02-02 23:01:20 +00:00
Stephane Moore b08a2d4851 [clang-tidy] Make google-objc-function-naming ignore implicit functions 🙈
Summary:
Implicit functions are outside the control of source authors and should
be exempt from style restrictions.

Tested via running clang tools tests.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

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

llvm-svn: 352968
2019-02-02 22:07:00 +00:00
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