summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/unittests/XRefsTests.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [clangd] Publish xref for macros from Index and AST.Utkarsh Saxena2020-01-131-3/+46
| | | | | | | | | | | | | | | | | | | Summary: With this patch the `findReferences` API will return Xref for macros. If the symbol under the cursor is a macro then we collect the references to it from: 1. Main file by looking at the ParsedAST. (These were added to the ParsedAST in https://reviews.llvm.org/D70008) 2. Files other than the mainfile by looking at the: * static index (Added in https://reviews.llvm.org/D70489) * file index (Added in https://reviews.llvm.org/D71406) This patch collects all the xref from the above places and outputs it in `findReferences` API. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72395
* [clangd] Heuristically resolve dependent call through smart pointer typeNathan Ridge2020-01-071-2/+2
| | | | | | | | | | | | Summary: Fixes https://github.com/clangd/clangd/issues/227 Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71644
* [clangd] Assert that the testcases in LocateSymbol.All have no diagnosticsNathan Ridge2020-01-071-22/+62
| | | | | | | | | | Summary: Also fix some bugs in the testcases which this exposed. Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72066
* NFC: Fix trivial typos in commentsKazuaki Ishizaki2020-01-041-1/+1
|
* Revert "Revert "[clangd] Implement "textDocument/documentLink" protocol ↵Sam McCall2020-01-021-0/+21
| | | | | | | | | | support"" This reverts commit 079ef783dd5530b5f87beefe624b9179547ded7e. The revert describes a test failure without details, after offline discussion this in in a private/unsupported build system and doesn't seem to reflect a real upstream bug.
* Revert "[clangd] Implement "textDocument/documentLink" protocol support"Dmitri Gribenko2019-12-161-21/+0
| | | | | | This reverts commit d6417f5584aa7673fa0212029a96cc9cacb1aad5. The tests depend on builtin headers, which is not intentionally supported in clangd tests; these tests are broken in some build environments.
* [clangd] Fix Windows test failure by adding -fno-delayed-template-parsing to ↵Nathan Ridge2019-12-121-1/+5
| | | | | | | | | | LocateSymbol.Ambiguous Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71444
* [clangd] Heuristically resolve dependent method callsNathan Ridge2019-12-121-0/+69
| | | | | | | | | | | | | | | | Summary: The heuristic is to look in the definition of the primary template, which is what you want in the vast majority of cases. Fixes https://github.com/clangd/clangd/issues/141 Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71240
* [clangd] Implement "textDocument/documentLink" protocol supportMichael Forster2019-12-121-0/+21
| | | | | | | | | | | | | | | | | | | Summary: This adds an implementation for the "textDocument/documentLink" LSP request. It returns links for all `#include` directives to the resolved target files. Fixes https://github.com/clangd/clangd/issues/217. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70872
* [clangd] Use expansion location when the ref is inside macros.Haojian Wu2019-12-091-0/+13
| | | | | | | | | | | | | | | | | | | | | Summary: Previously, xrefs has inconsistent behavior when the reference is inside macro body: - AST-based xrefs (for main file) uses the expansion location; - our index uses the spelling location; This patch makes our index use file locations for references, which is consistent with AST-based xrefs, and kythe as well. After this patch, memory usage of static index on LLVM increases ~5%. Reviewers: ilya-biryukov Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70480
* [clangd] Navigation from definition of template specialization to primary ↵Nathan Ridge2019-12-081-1/+16
| | | | | | | | | | | | | | template Fixes https://github.com/clangd/clangd/issues/212. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71090
* [clangd] Untangle Hover from XRefs, move into own file.Sam McCall2019-11-191-1339/+0
| | | | | | | | | | | | | | | | | | | | | | | | 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-191-5/+5
| | | | | | | | | | | | 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-191-2/+11
| | | | | | | | | | | | | | 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] Expose the xref's incomplete flag to clangdServer API.Haojian Wu2019-11-181-11/+13
| | | | | | | | | | | | 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] Don't repeat class template args when printing constructor definitionsSam McCall2019-11-151-1/+1
| | | | This fixes part of https://github.com/clangd/clangd/issues/76
* [clangd] Fix typo in symbol kind conversionSam McCall2019-11-151-1/+1
| | | | | | | | | | 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-151-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | 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
* [AST] Use written names instead of `type-param-0-0` in more cases when ↵Sam McCall2019-11-151-0/+11
| | | | | | | | | | | | | | | | | | | 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] Expose value of enumerators to Hover API. (not UI yet)Sam McCall2019-11-141-0/+13
| | | | | | | | | | | | 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] Add bool return type to Index::refs API.Haojian Wu2019-11-131-1/+2
| | | | | | | | | | | | | | | | 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
* Refactor getDeclAtPosition() to use SelectionTree + targetDecl()Nathan Ridge2019-10-311-7/+13
| | | | | | | | | | | | 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] Report declaration references in findExplicitReferences.Haojian Wu2019-10-181-1/+2
| | | | | | | | | | | | Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68977 llvm-svn: 375226
* Make most clangd unittests pass on WindowsNico Weber2019-10-131-1/+8
| | | | | | | | | | | | | | | | | | | | 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
* [clangd] Implement getBeginning for overloaded operators.Haojian Wu2019-10-011-0/+9
| | | | | | | | | | | | | | | | Summary: This will fix some bugs where navigation doesn't work on cases like `std::cout <^< "hello"`. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67695 llvm-svn: 373323
* [clangd] Add a helper for extracting nonlocal decls in a FunctionDeclKadir Cetinkaya2019-09-261-0/+85
| | | | | | | | | | | | | | | | | | | Summary: To be used by define-inline code action to determine whether the function/method body will still be valid in another context. Traverses clang-ast to find all decl nodes under the function decl and stores the non-local ones. Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67748 llvm-svn: 372948
* [clangd] Rename ClangdUnit.h -> ParsedAST.h. NFCSam McCall2019-09-041-1/+1
| | | | | | | | | | This much better reflects what is (now) in this header. Maybe a rename to ParsedTU would be an improvement, but that's a much more invasive change and life is too short. ClangdUnit is dead, long live ClangdUnitTests! llvm-svn: 370862
* [clangd] Ignore implicit conversion-operator nodes in find refs.Haojian Wu2019-08-211-0/+12
| | | | | | | | | | | | Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66478 llvm-svn: 369514
* [clangd] Fix one testcase in XRefsTests.Haojian Wu2019-08-201-9/+11
| | | | | | | | | | | | | | | | | | Summary: The test didn't test anything actually -- it used "[]" as annotation which should be "[[]]". This patch also fixes a bug in XRef where we may return duplicated refs. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66349 llvm-svn: 369387
* [clangd] Fix a crash when presenting values for HoverIlya Biryukov2019-08-021-0/+10
| | | | | | | | | | | | | | | | | | | Summary: We should pass the expression type, not a variable type when printing the resulting value. Variable type may be different from what the pretty-printing function expects, e.g. have references. Reviewers: sammccall Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65655 llvm-svn: 367687
* [clangd] Consume llvm::Error in test after r365792Sam McCall2019-07-111-1/+3
| | | | llvm-svn: 365793
* [clangd] Implementation of auto type expansion.Sam McCall2019-07-111-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add a tweak for clangd to replace an auto keyword to the deduced type. This way a user can declare something with auto and then have the IDE/clangd replace auto with whatever type clangd thinks it is. In case of long/complext types this makes is reduces writing effort for the user. The functionality is similar to the hover over the auto keyword. Example (from the header): ``` /// Before: /// auto x = Something(); /// ^^^^ /// After: /// MyClass x = Something(); /// ^^^^^^^ ``` Patch by kuhnel! (Christian Kühnel) Differential Revision: https://reviews.llvm.org/D62855 llvm-svn: 365792
* [clangd] Show documentation in hover, and fetch docs from index if needed.Sam McCall2019-07-091-10/+41
| | | | | | | | | | | | | | | | | | | Summary: I assume showing docs is going to be part of structured hover rendering, but it's unclear whether that's going to make clangd 9 so this is low-hanging fruit. (Also fixes a bug uncovered in FormattedString's plain text output: need blank lines when text follows codeblocks) Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64296 llvm-svn: 365522
* [clangd] Add Value field to HoverInfoKadir Cetinkaya2019-06-261-3/+70
| | | | | | | | | | | | | | | | Summary: Put a symbols value information which is deduced from initializer expression into HoverInfo struct. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63330 llvm-svn: 364390
* [clangd] Treat lambdas as functions when preparing hover responseKadir Cetinkaya2019-06-131-5/+75
| | | | | | | | | | | | Reviewers: sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62814 llvm-svn: 363237
* [clangd] Represent Hover result using FormattedStringIlya Biryukov2019-05-291-61/+208
| | | | | | | | | | | | | | Reviewers: sammccall, kadircet Reviewed By: kadircet Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61601 llvm-svn: 361940
* [clangd] Introduce a structured hover responseKadir Cetinkaya2019-05-281-26/+327
| | | | | | | | | | | | | | | | Summary: Change ClangdServer layer to output a structured response for Hover, which can be rendered by client according to their needs. Reviewers: sammccall, ilya-biryukov Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61497 llvm-svn: 361803
* [Index] Fix reported references in presence of template type aliasesIlya Biryukov2019-05-231-0/+11
| | | | | | | | | | | | | | | | Summary: See the added test for an example. Reviewers: kadircet Reviewed By: kadircet Subscribers: jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62303 llvm-svn: 361511
* [clangd] Qualify uses of ::testing everywhere. NFCIlya Biryukov2019-05-061-5/+5
| | | | | | | | | Add an initial '::' qualifier to all usages of 'testing' namespace that did not have one. The goal is to make our code style in tests more consistent. llvm-svn: 360026
* [clangd] Also perform merging for symbol definitionsKadir Cetinkaya2019-05-031-5/+18
| | | | | | | | | | | | | | | | | | Summary: clangd currently prefers declarations from codegen files. This patch implements that behavior for definition locations. If we have definiton locations both coming from AST and index, clangd will perform a merging to show the codegen file if that's the case. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61126 llvm-svn: 359874
* [clangd] Move clangd tests to clangd directory. check-clangd is no longer ↵Sam McCall2019-04-291-0/+1504
part of check-clang-tools. Summary: Motivation: - this layout is a pain to work with - without a common root, it's painful to express things like "disable clangd" (D61122) - CMake/lit configs are a maintenance hazard, and the more the one-off hacks for various tools are entangled, the more we see apathy and non-ownership. This attempts to use the bare-minimum configuration needed (while still supporting the difficult cases: windows, standalone clang build, dynamic libs). In particular the lit.cfg.py and lit.site.cfg.py.in are merged into lit.cfg.in. The logic in these files is now minimal. (Much of clang-tools-extra's lit configs can probably be cleaned up by reusing lit.llvm.llvm_config.use_clang(), and every llvm project does its own version of LDPATH mangling. I haven't attempted to fix any of those). Docs are still in clang-tools-extra/docs, I don't have any plans to touch those. Reviewers: gribozavr Subscribers: mgorny, javed.absar, MaskRay, jkorous, arphaman, kadircet, jfb, cfe-commits, ilya-biryukov, thakis Tags: #clang Differential Revision: https://reviews.llvm.org/D61187 llvm-svn: 359424
OpenPOWER on IntegriCloud