summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix unused variable warning. NFCI.Simon Pilgrim2019-11-211-1/+1
|
* [clangd] Reland b5135a86e0476: Fix a crash in expected typesIlya Biryukov2019-11-212-4/+14
| | | | | | | Reverted in 6de45772e0910bf7fa626e5493a2798b071eb26c. With a fix to Windows tests. Differential Revision: https://reviews.llvm.org/D70481
* Revert "[clangd] Fix a crash in expected types"Nico Weber2019-11-202-12/+4
| | | | | This reverts commit b5135a86e04761577494c70e7c0057136cc90b5b. Test fails on Windows.
* [clangd] Fix a crash in expected typesIlya Biryukov2019-11-202-4/+12
| | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70481
* [clangd] Treat UserDefinedLiteral as a leaf in SelectionTree, sidestepping ↵Sam McCall2019-11-202-0/+24
| | | | | | | | | | | | | | tokenization issues Summary: Fixes https://github.com/clangd/clangd/issues/203 Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70446
* [clangd] Show values of more expressions on hoverSam McCall2019-11-192-14/+83
| | | | | | | | | | Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70359
* [clangd] Untangle Hover from XRefs, move into own file.Sam McCall2019-11-1913-1961/+2025
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This is mostly mechanical, with a few exceptions: - getDeducedType moved into AST.h where it belongs. It now takes ASTContext instead of ParsedAST, and avoids using the preprocessor. - hover now uses SelectionTree directly rather than via getDeclAtPosition helper - hover on 'auto' used to find the decl that contained the 'auto' and use that to set Kind and documentation for the hover result. Now we use targetDecl() to find the decl matching the deduced type instead. This changes tests, e.g. 'variable' -> class for auto on lambdas. I think this is better, but the motivation was to avoid depending on the internals of DeducedTypeVisitor. This functionality is removed from the visitor. Reviewers: kadircet Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70357
* [clangd] Fix hover 'local scope' to include class template paramsSam McCall2019-11-192-11/+11
| | | | | | | | | | | | Summary: Fixes the last part of https://github.com/clangd/clangd/issues/76 Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70325
* [clangd] More sensible output for constructors/destructors in hover.Sam McCall2019-11-194-41/+68
| | | | | | | | | | | | | | Summary: Previously: both had type void() and return type void. Now: neither have a type. Constructors return T, destructors return void. Reviewers: hokein Subscribers: merge_guards_bot, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70317
* [clangd] Fix ps4 buildbot failure.Haojian Wu2019-11-191-2/+0
| | | | | dynamic_cast on ps4 buildbot seems relying on rtti flag which is off by default. Remove the dynamic_cast in the tests.
* Reland "[clangd] Implement rename by using SelectionTree and ↵Haojian Wu2019-11-192-48/+459
| | | | | | | | | findExplicitReferences." this reland the commit 4f80fc2491cc35730a9a84b86975278b7daa8522 which has been reverted at f805c60a093325c16ce4200d2615ef48555d9cb8. Fixed windows buildbot failure (by adding -fno-delayed-template-parsing flag).
* Revert "[clangd] Implement rename by using SelectionTree and ↵Wolfgang Pieb2019-11-182-462/+46
| | | | | | | | | findExplicitReferences." This reverts commit 4f80fc2491cc35730a9a84b86975278b7daa8522. Caused buildbot failure at http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/58251
* [clangd] Store xref for Macros in ParsedAST.Utkarsh Saxena2019-11-186-8/+146
| | | | | | | This patch adds the cross references for Macros in the MainFile. We add references for the main file to the ParsedAST. We query the references from it using the SymbolID. Xref outside main file will be added to the index in a separate patch.
* [clangd] Implement rename by using SelectionTree and findExplicitReferences.Haojian Wu2019-11-182-46/+462
| | | | | | | | | | | | | | | | | | | | | | | Summary: With the new implemenation, we will have better coverage of various AST nodes, and fix some known/potential bugs. Also added the existing clang-renamae tests. Known changed behavior: - "~Fo^o()" will not trigger the rename, will fix afterwards - references in macro bodies are not renamed now This fixes: - https://github.com/clangd/clangd/issues/167 - https://github.com/clangd/clangd/issues/169 - https://github.com/clangd/clangd/issues/171 Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69934
* [clangd] Fix some clang-tidy warnings on SourceCodeTests.cpp, NFC.Haojian Wu2019-11-181-9/+8
|
* [clangd] Fix diagnostic warnings in the RenameTests, NFC.Haojian Wu2019-11-181-2/+4
|
* [clangd] Expose the xref's incomplete flag to clangdServer API.Haojian Wu2019-11-186-29/+46
| | | | | | | | | | | | Summary: so that clangd C++ API users (via ClangdServer) can access it. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70380
* [AST] Attach comment in `/** doc */ typedef struct A {} B` to B as well as A.Sam McCall2019-11-181-0/+13
| | | | | | | | | | | | | | | | | | | | | | Summary: Semantically they're the same thing, and it's important when the underlying struct is anonymous. There doesn't seem to be a problem attaching the same comment to multiple things as it already happens with `/** doc */ int a, b;` This affects an Index test but the results look better (name present, USR points to the typedef). Fixes https://github.com/clangd/clangd/issues/189 Reviewers: kadircet, lh123 Subscribers: ilya-biryukov, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70203
* [clangd] Improve long and confusing preamble log message.Sam McCall2019-11-161-2/+3
|
* Avoid including Builtins.h in Preprocessor.hReid Kleckner2019-11-152-0/+2
| | | | | | Builtins are rarely if ever accessed via the Preprocessor. They are typically found on the ASTContext, so there should be no performance penalty to using a pointer indirection to store the builtin context.
* [clangd] Don't repeat class template args when printing constructor definitionsSam McCall2019-11-152-1/+2
| | | | This fixes part of https://github.com/clangd/clangd/issues/76
* [clangd] Fix typo in symbol kind conversionSam McCall2019-11-153-8/+8
| | | | | | | | | | Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70309
* [clangd] Don't consider class template params part of constructor name.Sam McCall2019-11-153-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | 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
* [clangd] Fix SelectionTree behavior on constructor init-lists.Sam McCall2019-11-152-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | 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
* [clangd] Replace getLangOpts().isHeaderFile usage with isHeaderFile helper.Haojian Wu2019-11-155-7/+17
| | | | | | | | | | | | | | | | 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
* [clangd] Add isHeaderFile helper.Haojian Wu2019-11-154-6/+44
| | | | | | | | | | | | | | | | | | | 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
* [AST] Use written names instead of `type-param-0-0` in more cases when ↵Sam McCall2019-11-152-2/+12
| | | | | | | | | | | | | | | | | | | 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
* [clangd] Ignore more implicit nodes in computing selection.Sam McCall2019-11-142-9/+39
| | | | | | | | | | | | | | | | | | | | | | 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
* [clangd] Expose value of enumerators to Hover API. (not UI yet)Sam McCall2019-11-142-0/+17
| | | | | | | | | | | | 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
* [clangd] Simplify the code in Index::refsIlya Biryukov2019-11-143-26/+17
| | | | | | | | | | | | | | | | | 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
* [clangd] Add bool return type to Index::refs API.Haojian Wu2019-11-1312-25/+58
| | | | | | | | | | | | | | | | 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
* [clangd] Fix crash in DefineInline::prepare()Sam McCall2019-11-112-1/+4
|
* [clangd] fixes semantic highlighting testHaojian Wu2019-11-111-21/+29
| | | | | | | | | | | | | | | | 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
* [clangd] Use name of Macro to compute its SymbolID, NFC.Utkarsh Saxena2019-11-114-7/+8
| | | | | | | | | | | | | | | | | | | 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
* [clangd] Fix a regression of not showing documentation from forward ↵Haojian Wu2019-11-112-8/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clangd] Fixes colon escaping on WindowsIlya Biryukov2019-11-113-22/+24
| | | | | | 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
* [clangd] NFC, reuse the source manager variable in the RawStringLiteral ↵Alex Lorenz2019-11-081-2/+1
| | | | | | apply method Differential Revision: https://reviews.llvm.org/D69544
* [clangd] NFC, hide the internal-only utility function lex.Haojian Wu2019-11-071-3/+4
| | | | To avoid any potential ODR violations.
* [clangd] Add unit tests for comments in system headersIlya Biryukov2019-11-071-0/+27
|
* [clangd] Set RetainCommentsFromSystemHeaders to trueIlya Biryukov2019-11-072-0/+2
| | | | | | | | | | 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
* [clangd] Improve the output of rename tests where there are failures.Haojian Wu2019-11-061-64/+54
| | | | | | | | | | | | | | | 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
* [clangd] Implement a function to lex the file to find candidate occurrences.Haojian Wu2019-11-063-17/+56
| | | | | | | | | | | | | | 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
* [clangd] Implement semantic highlightings via findExplicitReferencesIlya Biryukov2019-11-054-151/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Refactor getDeclAtPosition() to use SelectionTree + targetDecl()Nathan Ridge2019-10-314-114/+94
| | | | | | | | | | | | 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
* [clangd] Fix namespace aliases in findExplicitReferencesIlya Biryukov2019-10-312-4/+30
| | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69624
* [clangd] Add fno-delayed-parsing to new define inline testsKadir Cetinkaya2019-10-311-0/+2
| | | | To unbreak windows buildbots.
* [clangd] Add parameter renaming to define-inline code actionKadir Cetinkaya2019-10-312-7/+177
| | | | | | | | | | | | | | | | | 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
* [clangd] Add a hidden tweak to dump symbol under the cursor.Haojian Wu2019-10-292-0/+36
| | | | | | | | | | | | | | 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
* [clangd] NFC, use URI::resolve to simplify the code.Haojian Wu2019-10-291-9/+5
|
* [clangd] Add missing highlights for using decls.Haojian Wu2019-10-292-5/+19
| | | | | | | | | | Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69506
OpenPOWER on IntegriCloud