Commit Graph

5376 Commits

Author SHA1 Message Date
Mitchell Balan 782392db81 [clang-tidy] modernize-use-using work with multi-argument templates
Summary:
If clang-tidy's modernize-use-using feature finds any commas that are not within parentheses, it won't create a fix. That means it won't change lines like:
  typedef std::pair<int, int> Point;
to
  using Point = std::pair<int, int>;
or even:
  typedef std::map<std::string, Foo> MyMap;
  typedef std::vector<int,MyCustomAllocator<int>> MyVector;

This patch allows the fix to apply to lines with commas if they are within parentheses or angle brackets that were not themselves within parentheses.

Reviewers: alexfh, hokein, aaron.ballman

Patch by: poelmanc

Subscribers: jonathanmeier, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D67460
2019-11-15 16:09:10 -05:00
Sam McCall 209e30b7e0 [clangd] Don't repeat class template args when printing constructor definitions
This fixes part of https://github.com/clangd/clangd/issues/76
2019-11-15 19:23:20 +01:00
Sam McCall c9081968ea [clangd] Fix typo in symbol kind conversion
Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70309
2019-11-15 17:34:22 +01:00
Sam McCall 713c30b389 [clangd] Don't consider class template params part of constructor name.
Summary:
This is shorter and usually the extra info is noise.
There are cases where the params become type-parameter-0-0 that are hard to fix.

This affects a few features:
 - 'name' field in structured hover API (not exposed yet)
 - 'name' field in locateSymbolAt (not exposed in LSP)
 - 'document/symbol' - the symbol is hierarchically nested in the class
   template, or written as foo<t>::foo when defined out-of-line.

Added a test case for hover from https://github.com/clangd/clangd/issues/76.
This patch fixes one field, but no fewer than four others are wrong!
I'll fix them...

Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70308
2019-11-15 17:32:55 +01:00
Sam McCall ad9fd32009 [clangd] Fix SelectionTree behavior on constructor init-lists.
Summary:
For the constructor Foo() : classmember(arg) {}

The AST looks like:
 - CXXCtorInitializer  classmember(arg)
   - CXXConstructExpr  classmember(arg)
     - DeclRefExpr:                arg

We want the 'classmember' to be associated with the CXXCtorInitializer, not the
CXXConstructExpr. (CXXConstructExpr is known to have bad ranges).
So just early-claim it.

Thanks @hokein for tracking down/reducing the bug.

Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70312
2019-11-15 17:32:13 +01:00
Haojian Wu b221c9d09d [clangd] Replace getLangOpts().isHeaderFile usage with isHeaderFile helper.
Summary:
The helper is more correct to detect header file, this would fix our
issues caused by false positive before.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70299
2019-11-15 16:28:10 +01:00
Haojian Wu 509efe5d8e [clangd] Add isHeaderFile helper.
Summary:
we have a few places using `ASTCtx.getLangOpts().IsHeaderFile` to
determine a header file, but it relies on "-x c-header" compiler flag,
if the compilation command doesn't have this flag, we will get a false
positive. We are encountering this issue in bazel build system.

To solve this problem, we infer the file from file name, actual changes will
come in follow-ups.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70235
2019-11-15 16:18:27 +01:00
Sam McCall 87054ec07b [AST] Use written names instead of `type-param-0-0` in more cases when printing types and decls.
Summary:
This doesn't cover decls in diagnostics, which use NamedDecl::getNameForDiagnostic().
(That should also be fixed later I think).

This covers some cases of https://github.com/clangd/clangd/issues/76
(hover, but not outline or sighelp)

Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70236
2019-11-15 10:40:38 +01:00
Reid Kleckner e2369fd197 [clang-include-fixer] Skip .rc files when finding symbols
Summary:
For some reason CMake includes entries for .rc files, but
find-all-symbols handles them improperly.

See PR43993

Reviewers: sammccall, bkramer

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70196
2019-11-14 10:04:35 -08:00
Sam McCall bbcbb10e2d [clangd] Ignore more implicit nodes in computing selection.
Summary:
The DeclRefExpr for the callee of overloaded `operator()` and `operator[]` are
assigned the range of the paren/bracket lists in the AST.
These are better thought of as implicit (at least `()` - `[] is murkier).
But there's no bit on Expr for implicit, so just ignore them on our side.

While here, deal with the case where an implicit stmt (e.g. implicit-this)
is wrapped in an implicit cast. Previously we ignored the statement but not
the cast, and so the cast ended up being selected.

Fixes https://github.com/clangd/clangd/issues/195

Reviewers: kadircet, lh123

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70194
2019-11-14 17:35:00 +01:00
Sam McCall 37abeed814 [clangd] Expose value of enumerators to Hover API. (not UI yet)
Summary: This is part of https://github.com/clangd/clangd/issues/180.

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70209
2019-11-14 17:26:59 +01:00
Ilya Biryukov 5a9547b007 [clangd] Simplify the code in Index::refs
Summary:
While here, also fix potential UB in MergeIndex.

Thanks Kadir for finding this!

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70225
2019-11-14 14:43:29 +01:00
Haojian Wu 33e882d5ad [clangd] Add bool return type to Index::refs API.
Summary:
Similar to fuzzyFind, the bool indicates whether there are more xref
results.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70139
2019-11-13 14:42:30 +01:00
Sam McCall b9213dfec4 [clangd] Fix crash in DefineInline::prepare() 2019-11-11 19:01:06 +01:00
Yitzhak Mandelbaum 489449c28a [libTooling] Further simplify `Stencil` type and introduce `MatchComputation`.
Summary:
This revision introduces a new interface `MatchComputation` which generalizes
the `Stencil` interface and replaces the `std::function` interface of
`MatchConsumer`. With this revision, `Stencil` (as an abstraction) becomes just
one collection of implementations of
`MatchComputation<std::string>`. Correspondingly, we remove the `Stencil` class
entirely in favor of a simple type alias, deprecate `MatchConsumer` and change
all functions that accepted `MatchConsumer<std::string>` to use
`MatchComputation<std::string>` instead.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69802
2019-11-11 12:44:15 -05:00
Simon Pilgrim b6cd799e29 Fix filename typo in rG8d288a0668a5 2019-11-11 17:23:21 +00:00
Abel Kocsis 8d288a0668 [clang-tidy] Add bugprone-bad-signal-to-kill-thread check and its alias cert-pos44-c 2019-11-11 17:47:14 +01:00
Abel Kocsis 8cec7e0208 Revert "[clang-tidy] Add bugprone-bad-signal-to-kill-thread checker and alias cert-pos44-c"
This reverts commit 4edf0cb0e0.
2019-11-11 17:34:04 +01:00
Abel Kocsis 4edf0cb0e0 [clang-tidy] Add bugprone-bad-signal-to-kill-thread checker and alias cert-pos44-c 2019-11-11 17:26:44 +01:00
Haojian Wu f8c17fe111 [clangd] fixes semantic highlighting test
Summary: fixes https://github.com/clangd/clangd/issues/176

Patch by liu hui!

Reviewers: ilya-biryukov, hokein, sammccall

Reviewed By: hokein

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

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D70078
2019-11-11 16:47:44 +01:00
Utkarsh Saxena 02ec6ff77e [clangd] Use name of Macro to compute its SymbolID, NFC.
Summary:
We use the name from the IdentifierInfo of the Macro to compute its
SymbolID. It is better to just take the Name as a parameter to avoid
storing the IdentifierInfo whenever we need the SymbolID for the Macro.

Patch by UTKARSH SAXENA!

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69937
2019-11-11 12:38:49 +01:00
Haojian Wu 41104a9406 [clangd] Fix a regression of not showing documentation from forward declarations.
Summary:
There is a regression from https://reviews.llvm.org/D68467. Unlike class
forward declarations, function ducomentation is written in the declaration in
headers, the function definition doesn't contain any documentation, cases like:

```
foo.h
// this is foo.
void foo();
foo.cc

void foo() {}
```
we should still show documentation from the foo declaration.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69961
2019-11-11 10:46:52 +01:00
Ilya Biryukov b4f46a9bb4 [clangd] Fixes colon escaping on Windows
vscode always escapes the colon on the file uri, which causes the semantic highlighting fails on windows.

fixes: https://github.com/clangd/clangd/issues/176
2019-11-11 09:21:25 +01:00
Alex Lorenz e1b07aac3d [clangd] NFC, reuse the source manager variable in the RawStringLiteral apply method
Differential Revision: https://reviews.llvm.org/D69544
2019-11-08 14:50:54 -08:00
Melanie Blower d0b3e73175 Revert "Reapply "Fix crash on switch conditions of non-integer types in templates""
This reverts commit 759948467e.
There were build bot failures in clang-tidy
2019-11-08 14:18:15 -08:00
Melanie Blower 759948467e Reapply "Fix crash on switch conditions of non-integer types in templates"
This patch reapplies commit 76945821b9. The first version broke
buildbots due to clang-tidy test fails. The fails are because some
errors in templates are now diagnosed earlier (does not wait till
instantiation). I have modified the tests to add checks for these
diagnostics/prevent these diagnostics. There are no additional code
changes.

Summary of code changes:

Clang currently crashes for switch statements inside a template when the
condition is a non-integer field member because contextual implicit
conversion is skipped when parsing the condition. This conversion is
however later checked in an assert when the case statement is handled.
The conversion is skipped when parsing the condition because
the field member is set as type-dependent based on its containing class.
This patch sets the type dependency based on the field's type instead.

This patch fixes Bug 40982.

Reviewers: rnk, gribozavr2

Patch by: Elizabeth Andrews (eandrews)

Differential revision: https://reviews.llvm.org/D69950
2019-11-08 10:17:06 -08:00
Haojian Wu c5e4cf40ac [clangd] NFC, hide the internal-only utility function lex.
To avoid any potential ODR violations.
2019-11-07 10:58:09 +01:00
Ilya Biryukov dec8d8d3f2 [clangd] Add unit tests for comments in system headers 2019-11-07 10:24:27 +01:00
Ilya Biryukov 0019684900 [clangd] Set RetainCommentsFromSystemHeaders to true
clangd should retain comments from system headers.

fixes https://github.com/clangd/clangd/issues/96

Patch by lh123!

Differential revision: https://reviews.llvm.org/D69928
2019-11-07 09:54:20 +01:00
Yitzhak Mandelbaum bde3293302 [clang-tidy] Update TransformerClangTidyCheck to use new Transformer bindings.
Summary:
Updates the relevant source files to use bindings in `clang::transformer` rather
than `clang::tooling`.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69804
2019-11-06 10:13:33 -05:00
Haojian Wu b0eed2a5cf [clangd] Improve the output of rename tests where there are failures.
Summary:
Previously, we match ranges, which is hard to spot the difference.
Now, we diff the code after rename against the expected result, it
produces much nicer output.

Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69890
2019-11-06 15:34:38 +01:00
Haojian Wu 7ea4c6fa51 [clangd] Implement a function to lex the file to find candidate occurrences.
Summary:
This will be used for incoming cross-file rename (to detect index
staleness issue).

Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69615
2019-11-06 09:56:02 +01:00
Matthias Gehre 24130d661e [clang-tidy] Add readability-make-member-function-const
Summary:
Finds non-static member functions that can be made ``const``
because the functions don't use ``this`` in a non-const way.

The check conservatively tries to preserve logical costness in favor of
physical costness. See readability-make-member-function-const.rst for more
details.

Reviewers: aaron.ballman, gribozavr, hokein, alexfh

Subscribers: mgorny, xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D68074
2019-11-06 09:27:02 +01:00
Ilya Biryukov 87e0cb4f1a [clangd] Implement semantic highlightings via findExplicitReferences
Summary:
To keep the logic of finding locations of interesting AST nodes in one
place.

The advantage is better coverage of various AST nodes, both now and in
the future: as new nodes get added to `findExplicitReferences`, semantic
highlighting will automatically pick them up.

The drawback of this change is that we have to traverse declarations
inside our file twice in order to highlight dependent names, 'auto'
and 'decltype'. Hopefully, this should not affect the actual latency
too much, most time should be spent in building the AST and not
traversing it.

Reviewers: hokein

Reviewed By: hokein

Subscribers: nridge, merge_guards_bot, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69673
2019-11-05 19:15:24 +01:00
Anton Bikineev d36a033310 [clang-tidy] New checker performance-trivially-destructible-check
Checks for types which can be made trivially-destructible by removing
out-of-line defaulted destructor declarations.

The check is motivated by the work on C++ garbage collector in Blink
(rendering engine for Chrome), which strives to minimize destructors and
improve runtime of sweeping phase.

In the entire chromium codebase the check hits over 2000 times.

Differential Revision: https://reviews.llvm.org/D69435
2019-11-01 16:16:49 +01:00
Nathan Ridge b6429cdd65 Refactor getDeclAtPosition() to use SelectionTree + targetDecl()
Summary: This fixes issue #163, among other improvements to go-to-definition.

Reviewers: sammccall

Subscribers: jkorous, mgrang, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69237
2019-10-31 17:37:27 -04:00
Ilya Biryukov 733777a816 [clangd] Fix namespace aliases in findExplicitReferences
Reviewers: kadircet

Reviewed By: kadircet

Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69624
2019-10-31 13:35:25 +01:00
Kadir Cetinkaya 1c66d09b73
[clangd] Add fno-delayed-parsing to new define inline tests
To unbreak windows buildbots.
2019-10-31 13:22:52 +01:00
Kadir Cetinkaya 71aa3f7b7e
[clangd] Add parameter renaming to define-inline code action
Summary:
When moving a function definition to declaration location we also need
to handle renaming of the both function and template parameters.

This patch achives that by making sure every parameter name and dependent type
in destination is renamed to their respective name in the source.

Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D68937
2019-10-31 09:23:09 +01:00
Stephane Moore 9baf4958cd [clang-tidy] Regenerate clang-tidy check list 📋
Summary:
These changes were generated by invoking
clang-tools-extra/clang-tidy/add_new_check.py and then reverting the
check that was added.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69414
2019-10-30 18:15:34 -07:00
Vladimir Plyashkun 3a0c86a179 Add a test file that was missed in 4de6b15868 2019-10-30 16:55:43 -04:00
Daniel 7b6174bb14 Add a test file that was missed in e477988309 2019-10-30 16:52:19 -04:00
Daniel e477988309 Fix readability-identifier-naming to prevent variables becoming keywords.
Do not provide a fix-it when clang-tidy encounters a name that would become
a keyword.
2019-10-30 14:18:40 -04:00
Vladimir Plyashkun 4de6b15868 Add an option to hicpp-signed-bitwise for positive integer literals.
This gives developers a way to deviate from the coding standard to reduce the
chattiness of the check.
2019-10-30 14:11:29 -04:00
Aaron Ballman 0de262d718 Move this release note to its appropriate location; NFC. 2019-10-30 13:48:26 -04:00
Aaron Ballman 661d2ce619 Fix modernize-use-nodiscard for classes marked [[nodiscard]]
Current implementation suggests to add [[nodiscard]] to methods even if the
return type is marked already as [[nodiscard]].

Patch by Eugene Sedykh.
2019-10-30 13:45:37 -04:00
Aaron Ballman 1caa66d075 Fix a false positive in misc-redundant-expression check
Do not warn for redundant conditional expressions when the true and false
branches are expanded from different macros even when they are defined by
one another.

Patch by Daniel Krupp.
2019-10-30 13:38:25 -04:00
Aaron Ballman 29dc0b17de Add the readability-redundant-access-specifiers check.
This finds redundant access specifier declarations inside classes, structs, and unions.

Patch by Mateusz Mackowski.
2019-10-30 13:30:57 -04:00
Haojian Wu 80b0cdde0f [clangd] Add a hidden tweak to dump symbol under the cursor.
Summary:
This provides a convenient way to see the SymbolID/USR of the symbol, mainly
for debugging purpose.

Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69517
2019-10-29 13:06:34 +01:00
Haojian Wu f821ab807d [clangd] NFC, use URI::resolve to simplify the code. 2019-10-29 10:53:16 +01:00
Haojian Wu 94cd2f0303 [clangd] Add missing highlights for using decls.
Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69506
2019-10-29 09:49:42 +01:00
Simon Pilgrim 93a3128a67 Remove extra ';'. NFCI. 2019-10-28 16:32:02 +00:00
Ilya Biryukov 4c430a7c6f [clangd] Do not report anonymous entities in findExplicitReferences
Summary:
Otherwise every client dealing with name location should handle
anonymous names in a special manner.

This seems too error-prone, clients can probably handle anonymous
entities they care about differently.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69511
2019-10-28 14:41:34 +01:00
Kadir Cetinkaya 3cb5764f90
[clangd] Flush streams when printing HoverInfo Name and Definition
Summary: Fixes some windows breakages when compiled via msvc.
2019-10-28 12:05:03 +01:00
Ilya Biryukov c814f4c459 [clangd] Do not highlight keywords in semantic highlighting
Summary:
Editors are good at highlightings the keywords themselves.
Note that this only affects highlightings of builtin types spelled out
as keywords in the source code. Highlightings of typedefs to builtin
types are unchanged.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69431
2019-10-28 12:03:09 +01:00
Ilya Biryukov d9971d0b2e [clangd] Do not insert parentheses when completing a using declaration
Summary:
Would be nice to also fix this in clang, but that looks like more work
if we want to preserve signatures in informative chunks.

Fixes https://github.com/clangd/clangd/issues/118

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69382
2019-10-28 09:45:10 +01:00
Kadir Cetinkaya f4d7caf6df
[clangd] Reland Store Index in Tweak::Selection
Summary:
Incoming define out-of-line tweak requires access to index.

This patch simply propogates the index in ClangdServer to Tweak::Selection while
passing the AST. Also updates TweakTest to accommodate this change.

Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69165
2019-10-28 07:55:58 +01:00
Kadir Cetinkaya 3d65def1fd
[clangd] Reland DefineInline action apply logic with fully qualified names
Summary:
Initial version of DefineInline action that will fully qualify every
name inside function body.

Reviewers: sammccall, ilya-biryukov, hokein

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66647
2019-10-28 07:45:38 +01:00
Kadir Cetinkaya 5ab9a850f6
[clangd] Reland DefineInline action availability checks
Summary:
Introduces DefineInline action and initial version of availability
checks.

Reviewers: sammccall, ilya-biryukov, hokein

Reviewed By: hokein

Subscribers: thakis, usaxena95, mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65433
2019-10-28 07:28:21 +01:00
Kadir Cetinkaya 1a9c01c7f6
[clangd] Pass ExtraArgs to TestTU in TweakIsAvailable matcher 2019-10-28 07:18:26 +01:00
Kadir Cetinkaya 8e567b0730
[clangd] Revert define-inline action changes to un-break windows build-bots 2019-10-25 18:40:01 +02:00
Kadir Cetinkaya 43e931cb5f
[clangd][NFC] Get rid of raw string literals in macros to make stage1 compiler happy 2019-10-25 15:01:28 +02:00
Kadir Cetinkaya ce1e249a68
Fix compilation error in clangd/refactor/tweaks/ExpandAutoType.cpp
Summary:
During the compilation of the `clangd/refactor/tweaks/ExpandAutoType.cpp`, MSVC returns the following error:

llvm-monorepo\llvm\tools\clang\tools\extra\clangd\refactor\tweaks\ExpandAutoType.cpp(85): error C2146: syntax error: missing ')' before identifier 'and'
llvm-monorepo\llvm\tools\clang\tools\extra\clangd\refactor\tweaks\ExpandAutoType.cpp(85): error C2065: 'and': undeclared identifier
llvm-monorepo\llvm\tools\clang\tools\extra\clangd\refactor\tweaks\ExpandAutoType.cpp(86): error C2143: syntax error: missing ';' before '<template-id>'
llvm-monorepo\llvm\tools\clang\tools\extra\clangd\refactor\tweaks\ExpandAutoType.cpp(73): fatal error C1075: '{': no matching token found

So, && must be used instead of `and`.

Patch By Pavel Samolysov (@psamolysov) !

Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D69427
2019-10-25 14:16:59 +02:00
Kadir Cetinkaya 8aa84ad37d
[clangd] Store Index in Tweak::Selection
Summary:
Incoming define out-of-line tweak requires access to index.

This patch simply propogates the index in ClangdServer to Tweak::Selection while
passing the AST. Also updates TweakTest to accommodate this change.

Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69165
2019-10-25 12:15:20 +02:00
Kadir Cetinkaya d62e3ed3f4
[clangd] Implement GetEligiblePoints
Summary:
This is an helper for incoming move definition out-of-line action to
figure out possible insertion locations for definition of a qualified name.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D68024
2019-10-25 12:13:30 +02:00
Kadir Cetinkaya dfd6374c78
[clangd] DefineInline action apply logic with fully qualified names
Summary:
Initial version of DefineInline action that will fully qualify every
name inside function body.

Reviewers: sammccall, ilya-biryukov, hokein

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66647
2019-10-25 11:52:47 +02:00
Kadir Cetinkaya 74d39a42f1
[clangd] DefineInline action availability checks
Summary:
Introduces DefineInline action and initial version of
availability checks.

Reviewers: sammccall, ilya-biryukov, hokein

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65433
2019-10-25 11:52:47 +02:00
Ilya Biryukov ed913a2915 [clangd] Fix case of variables and functions in code complete tests. NFC 2019-10-24 15:41:50 +02:00
Haojian Wu 13fc899cde [clangd] Handle the missing constructor initializers in findExplicitReferences.
Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69241
2019-10-24 10:38:37 +02:00
Haojian Wu bf71e4fe0a [clangd] Collect name references in the index.
Summary:
This is used for cross-file rename. When renaming a class, we expect to
rename all related constructors/destructors.

Reviewers: kadircet, ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69338
2019-10-24 10:25:16 +02:00
Sam McCall 8bda5f2067 [clangd] abort if shutdown takes more than a minute.
Summary:
A certain class of bug (e.g. infloop on an AST worker thread) currently means
clangd never terminates, even if the editor shuts down the protocol and closes
our stdin, and the main thread recognizes that.

Instead, let's wait 60 seconds for threads to finish cleanly, and then crash
if they haven't.

(Obviously, we should still fix these bugs).

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69329
2019-10-23 17:52:59 +02:00
Kadir Cetinkaya 10c8dbcb84 [clangd] Propogate context in TUScheduler::run
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69328
2019-10-23 15:31:24 +02:00
Reid Kleckner 90c64a3456 Move endian constant from Host.h to SwapByteOrder.h, prune include
Works on this dependency chain:
  ArrayRef.h ->
  Hashing.h -> --CUT--
  Host.h ->
  StringMap.h / StringRef.h

ArrayRef is very popular, but Host.h is rarely needed. Move the
IsBigEndianHost constant to SwapByteOrder.h. Clients of that header are
more likely to need it.

llvm-svn: 375316
2019-10-19 00:48:11 +00:00
Haojian Wu 65f61c0030 [clangd] Report declaration references in findExplicitReferences.
Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 375226
2019-10-18 12:07:19 +00:00
Haojian Wu c8e3f43ab5 [clangd] Use our own relation kind.
Summary:
Move the RelationKind from Serialization.h to Relation.h. This patch doesn't
introduce any breaking changes.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 375117
2019-10-17 14:08:28 +00:00
Simon Pilgrim 2ea8b58cb6 clang-tidy - silence static analyzer getAs<> null dereference warnings. NFCI.
The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

llvm-svn: 375102
2019-10-17 11:12:53 +00:00
Joel E. Denny d3dd489b9a [lit] Fix another test case that r374652 missed
llvm-svn: 375058
2019-10-16 23:58:58 +00:00
Michael Liao b4874226de [clangd] Add the missing dependency on `clangLex`.
llvm-svn: 375039
2019-10-16 20:22:54 +00:00
Utkarsh Saxena b62b454121 [clangd] Add RemoveUsingNamespace tweak.
Summary:
Removes the 'using namespace' under the cursor and qualifies all accesses in the current file.
E.g.:
  using namespace std;
  vector<int> foo(std::map<int, int>);
Would become:
  std::vector<int> foo(std::map<int, int>);

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

Tags: #clang

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

llvm-svn: 374982
2019-10-16 09:53:59 +00:00
Kadir Cetinkaya b18170660e [clangd][NFC] Update comments to use triple-slashes
llvm-svn: 374901
2019-10-15 14:59:08 +00:00
Kadir Cetinkaya 9d66247e9b [clangd] Propagate main context into ClangdServer
Summary:
Currently clangd initializes the ClangdServer lazily during
onInitialize request, and it results in propagation of caller's context rather
than the main context created ClangdLSPServer.

This patch changes the logic to store main context that created ClangdLSPServer
and pass it onto to ClangdServer and other objects like CDBs.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 374892
2019-10-15 14:20:52 +00:00
Michal Gorny 9c9bd1657c [clang-tools-extra] Fix overzealous linking of dylib to clangTidy
Fix accidentally making clangTidy library link to dylib.  This causes
libclang.so to also link to dylib which results in duplicate symbols
from shared and static libraries, and effectively to registering
command-line options twice.

Thanks to Sylvestre Ledru for noticing this and tracking it down
to r373786.  Fixes PR#43589.

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

llvm-svn: 374885
2019-10-15 13:05:38 +00:00
Jan Korous c5d14b5c6f [clang-scan-deps] Support for clang --analyze in clang-scan-deps
The goal is to have 100% fidelity in clang-scan-deps behavior when
--analyze is present in compilation command.

At the same time I don't want to break clang-tidy which expects
__static_analyzer__ macro defined as built-in.

I introduce new cc1 options (-setup-static-analyzer) that controls
the macro definition and is conditionally set in driver.

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

llvm-svn: 374815
2019-10-14 20:15:01 +00:00
Nathan Ridge 37e31e629d [clangd] Improve semantic highlighting in dependent contexts (fixes #154)
Reviewers: hokein

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

Tags: #clang

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

llvm-svn: 374799
2019-10-14 18:26:13 +00:00
Nico Weber eecef1e5a5 clangd tests: use extended regex with sed
The escaped parens seem to confuse the combination of lit, cygwin
quoting, and cygwin's sed. unxutils sed in cmd.exe is fine with both
forms, so use the extended regex form that doesn't need an escaped
paren.

llvm-svn: 374753
2019-10-14 03:44:47 +00:00
Nico Weber 282b36c1ce convert another test to unix line endings
llvm-svn: 374752
2019-10-14 02:21:12 +00:00
Nico Weber 61d2655690 convert a test to unix line endings
llvm-svn: 374751
2019-10-14 02:14:18 +00:00
Nico Weber a05d254b82 fix typo in 374747
llvm-svn: 374750
2019-10-14 01:44:29 +00:00
Nico Weber 1f1703f5c7 Prefer 'env not' over 'not env' in tests.
That way, lit's builtin 'env' command can be used for the 'env' bit.

Also it's clearer that way that the 'not' shouldn't cover 'env'
failures.

llvm-svn: 374749
2019-10-14 01:41:56 +00:00
Nico Weber 9f1bb5b9a8 Make symbols.test pass on Windows.
See commit message of r374746 for details.

Hopefully final bit of PR43592.

llvm-svn: 374747
2019-10-14 01:19:53 +00:00
Nico Weber 3e54997e77 Make code-action-request.test and request-reply.test pass on Windows.
clangd's test:// scheme expands to /clangd-test on non-Win and to
C:/clang-test on Win, so it can't be mixed freely with
file:///clangd-test since that's wrong on Windows. This makes both
tests consistenly use the test:// scheme. (Alternatively, we could use
the //INPUT_DIR pattern used in a few other tests.)

Part of PR43592.

llvm-svn: 374746
2019-10-14 01:00:33 +00:00
Nico Weber c445c0cb0a Don't run background-index.test on Windows.
The test had a "UNSUPPORTED: win32" line, but the spelling of that
changed in r339307 a year ago. Finally update this test too.

Part of PR43592.

llvm-svn: 374745
2019-10-14 00:45:02 +00:00
Nico Weber 5d8870bc76 Add missing "REQUIRES: shell" to system-include-extractor.test
Part of PR43592.

llvm-svn: 374730
2019-10-13 17:43:16 +00:00
Nico Weber 9d80a722d7 Make the last to clangd unit tests pass on Windows.
(Some lit tests still fail.)

See FIXME in diff for details.

Part of PR43592.

llvm-svn: 374727
2019-10-13 17:19:00 +00:00
Nico Weber 51fa7409e7 Make most clangd unittests pass on Windows
The Windows triple currently turns on delayed template parsing, which
confuses several unit tests that use templates.

For now, just explicitly disable delayed template parsing. This isn't
ideal, but:

- the Windows triple will soon no longer use delayed template parsing
  by default

- there's precedent for this in the clangd unit tests already

- let's get the clangd tests pass on Windows first before making
  behavioral changes

Part of PR43592.

llvm-svn: 374718
2019-10-13 13:15:27 +00:00
Csaba Dabis d2b790eb68 [clang-tidy] bugprone-not-null-terminated-result: checker adjustments 4
llvm-svn: 374715
2019-10-13 10:59:30 +00:00
Csaba Dabis b56989bcc7 [clang-tidy] bugprone-not-null-terminated-result: checker adjustments 3
On Windows the signed/unsigned int conversions of APInt seems broken, so that
two of the test files marked as unsupported on Windows, as a hotfix.

llvm-svn: 374713
2019-10-13 10:41:13 +00:00
Csaba Dabis 78037577f1 [clang-tidy] bugprone-not-null-terminated-result: checker adjustments 2
llvm-svn: 374712
2019-10-13 10:20:58 +00:00
Csaba Dabis 3965c76abc [clang-tidy] bugprone-not-null-terminated-result: checker adjustments
llvm-svn: 374711
2019-10-13 09:46:56 +00:00
Csaba Dabis adac533d95 [clang-tidy] bugprone-not-null-terminated-result: Sphinx adjustments 2
llvm-svn: 374710
2019-10-13 08:49:43 +00:00