summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/XRefs.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Add Value field to HoverInfoKadir Cetinkaya2019-06-261-0/+15
| | | | | | | | | | | | | | | | 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] Cleanup the duplicated getTokenRange.Haojian Wu2019-06-251-38/+32
| | | | | | | | | | | | | | | | Summary: Also lift it to SourceCode.h, so that it can be used in other places (semantic code highlighting). Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63714 llvm-svn: 364280
* [clangd] Type hierarchy subtypesNathan Ridge2019-06-161-3/+51
| | | | | | | | | | | | | | | | | Summary: This builds on the relations support added in D59407, D62459, D62471, and D62839 to implement type hierarchy subtypes. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, mgrang, arphaman, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58880 llvm-svn: 363506
* [clangd] Treat lambdas as functions when preparing hover responseKadir Cetinkaya2019-06-131-14/+33
| | | | | | | | | | | | 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-15/+10
| | | | | | | | | | | | | | 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] Add SourceManager accessor to ParsedAST. NFCSam McCall2019-05-281-12/+9
| | | | llvm-svn: 361883
* [clangd] Introduce a structured hover responseKadir Cetinkaya2019-05-281-108/+316
| | | | | | | | | | | | | | | | 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
* [clangd] Also perform merging for symbol definitionsKadir Cetinkaya2019-05-031-12/+15
| | | | | | | | | | | | | | | | | | 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] Support dependent bases in type hierarchyFangrui Song2019-04-221-8/+37
| | | | | | | | | | | | Patch by Nathan Ridge! Dependent bases are handled heuristically, by replacing them with the class template that they are a specialization of, where possible. Care is taken to avoid infinite recursion. Differential Revision: https://reviews.llvm.org/D59756 llvm-svn: 358866
* [clangd] Add support for type hierarchy (super types only for now)Kadir Cetinkaya2019-03-191-0/+133
| | | | | | | | | | | | | | | | | | | | | | | Summary: Patch by Nathan Ridge(@nridge)! This is an LSP extension proposed here: https://github.com/Microsoft/vscode-languageserver-node/pull/426 An example client implementation can be found here: https://github.com/theia-ide/theia/pull/3802 Reviewers: kadircet, sammccall Reviewed By: kadircet Subscribers: jdoerfert, sammccall, cfe-commits, mgorny, dschaefer, simark, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet Tags: #clang Differential Revision: https://reviews.llvm.org/D56370 llvm-svn: 356445
* [clangd] Make sure constructors do not reference classKadir Cetinkaya2019-03-081-0/+5
| | | | | | | | | | | | Reviewers: gribozavr Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58815 llvm-svn: 355679
* Moved SymbolLocation into its own header and implementation fileDmitri Gribenko2019-02-281-1/+1
| | | | | | | | | | | | Reviewers: ioeric Subscribers: mgorny, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58768 llvm-svn: 355082
* [clangd] Enhance macro hover to see full definitionMarc-Andre Laperle2019-02-241-7/+24
| | | | | | | | | | | | | | | | Summary: Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com> Reviewers: simark, ilya-biryukov, sammccall, ioeric, hokein Reviewed By: ilya-biryukov Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D55250 llvm-svn: 354761
* [clangd] Only report explicitly typed symbols during code navigationKadir Cetinkaya2019-02-211-51/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Clangd was reporting implicit symbols, like results of implicit cast expressions during code navigation, which is not desired. For example: ``` struct Foo{ Foo(int); }; void bar(Foo); vod foo() { int x; bar(^x); } ``` Performing a GoTo on the point specified by ^ would give two results one pointing to line `int x` and the other for definition of `Foo(int);` Reviewers: ilya-biryukov, sammccall Subscribers: ioeric, MaskRay, jkorous, mgrang, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58495 llvm-svn: 354585
* [clangd] Enable indexing of template type parametersKadir Cetinkaya2019-02-211-1/+4
| | | | | | | | | | | | | | Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=36285 Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58294 llvm-svn: 354561
* [clangd] Fix use-after-free in XRefsSam McCall2019-02-121-8/+8
| | | | llvm-svn: 353821
* [clangd] Prefer location from codegen files when merging symbols.Eric Liu2019-02-111-3/+42
| | | | | | | | | | | | | | | | | | | Summary: For example, if an index symbol has location in a .proto file and an AST symbol has location in a generated .proto.h file, then we prefer location in .proto which is more meaningful to users. Also use `mergeSymbols` to get the preferred location between AST location and index location in go-to-def. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58037 llvm-svn: 353708
* [clangd] Index parameters in function declsKadir Cetinkaya2019-02-111-0/+2
| | | | | | | | | | | | Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57950 llvm-svn: 353696
* [clangd] Implement textDocument/declaration from LSP 3.14Sam McCall2019-02-011-97/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clangd] Make USRs for macros to be position independentKadir Cetinkaya2019-01-291-1/+2
| | | | | | | | | | | | | | 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
* [clangd] NFC: fix clang-tidy warnings.Haojian Wu2019-01-251-2/+2
| | | | | | | Most are about llvm code style violation (found via readability-identifier-naming check). llvm-svn: 352205
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | 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
* [clangd] Add Limit parameter for xref.Haojian Wu2019-01-141-20/+26
| | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D56597 llvm-svn: 351081
* [clangd] Remove 'using namespace llvm' from .cpp files. NFCIlya Biryukov2019-01-071-26/+26
| | | | | | | | The new guideline is to qualify with 'llvm::' explicitly both in '.h' and '.cpp' files. This simplifies moving the code between header and source files and is easier to keep consistent. llvm-svn: 350531
* [clangd] clang-format everything. NFCIlya Biryukov2019-01-031-4/+2
| | | | llvm-svn: 350303
* [clangd] Unify path canonicalizations in the codebaseKadir Cetinkaya2018-12-191-4/+6
| | | | | | | | | | | | | | Summary: There were a few different places where we canonicalized paths, each one had its own flavor. This patch tries to unify them all under one place. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D55818 llvm-svn: 349618
* [clangd] Refine the way of checking a declaration is referenced by the ↵Haojian Wu2018-12-131-12/+10
| | | | | | | | | | | | | | | | | written code. Summary: The previous solution (checking the AST) is not a reliable way to determine whether a declaration is explicitly referenced by the source code, we are still missing a few cases. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D55191 llvm-svn: 349033
* [clangd] Canonicalize file path in URIForFile.Eric Liu2018-11-281-23/+31
| | | | | | | | | | | | | | | | | | | Summary: File paths in URIForFile can come from index or local AST. Path from index goes through URI transformation and the final path is resolved by URI scheme and could be potentially different from the original path. Hence, we should do the same transformation for all paths. We do this in URIForFile, which now converts a path to URI and back to a canonicalized path. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54845 llvm-svn: 347739
* [clangd] textDocument/SymbolInfo extensionJan Korous2018-11-271-0/+43
| | | | | | | | | | New method returning symbol info for given source position. Differential Revision: https://reviews.llvm.org/D54799 rdar://problem/46050281 llvm-svn: 347675
* [clangd] Fix crash hovering on non-decltype trailing returnMarc-Andre Laperle2018-11-171-2/+4
| | | | | | | | | | | | | | | | | | | | Summary: More specifically, hovering on "auto" in auto main() -> int { return 0; } Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com> Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54553 llvm-svn: 347119
* [clangd] Initial clang-tidy diagnostics support.Sam McCall2018-11-161-2/+1
| | | | | | | | | | | | | | | | | | | | | Summary: This runs checks over a restricted subset of the TU: - preprocessor callbacks just receive the truncated PP events that occur when a preamble is used. - ASTMatchers run only over the top-level decls in the main-file This patch just turns on one simple check (bugprone-sizeof-expression) with no configuration. Configuration is complex enough to warrant a separate patch This depends on a patch allowing traversal to be restricted to a scope. Reviewers: hokein Subscribers: srhines, mgorny, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54204 llvm-svn: 347036
* [clangd] Simplify auto hoverIlya Biryukov2018-10-241-27/+9
| | | | | | | | | | | | | | | | Summary: Use helper from clang. Also fixes some weird corner cases, e.g. auto (*foo)() = bar; Reviewers: kadircet, hokein Reviewed By: kadircet, hokein Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53347 llvm-svn: 345128
* [clangd] Namespace style cleanup in cpp files. NFC.Sam McCall2018-10-201-30/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Standardize on the most common namespace setup in our *.cpp files: using namespace llvm; namespace clang { namespace clangd { void foo(StringRef) { ... } And remove redundant llvm:: qualifiers. (Except for cases like make_unique where this causes problems with std:: and ADL). This choice is pretty arbitrary, but some broad consistency is nice. This is going to conflict with everything. Sorry :-/ Squash the other configurations: A) using namespace llvm; using namespace clang; using namespace clangd; void clangd::foo(StringRef); This is in some of the older files. (It prevents accidentally defining a new function instead of one in the header file, for what that's worth). B) namespace clang { namespace clangd { void foo(llvm::StringRef) { ... } This is fine, but in practice the using directive often gets added over time. C) namespace clang { namespace clangd { using namespace llvm; // inside the namespace This was pretty common, but is a bit misleading: name lookup preferrs clang::clangd::foo > clang::foo > llvm:: foo (no matter where the using directive is). llvm-svn: 344850
* [clangd] Remove the overflow log.Haojian Wu2018-10-191-0/+6
| | | | | | | | | | | | | | Summary: LLVM codebase has generated files (all are build/Target/XXX/*.inc) that exceed the MaxLine & MaxColumn. Printing these log would be noisy. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53400 llvm-svn: 344777
* [clangd] Encode Line/Column as a 32-bits integer.Haojian Wu2018-10-181-4/+4
| | | | | | | | | | | | | | | | | | | | | | Summary: This would buy us more memory. Using a 32-bits integer is enough for most human-readable source code (up to 4M lines and 4K columns). Previsouly, we used 8 bytes for a position, now 4 bytes, it would save us 8 bytes for each Ref and each Symbol instance. For LLVM-project binary index file, we save ~13% memory. | Before | After | | 412MB | 355MB | Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53363 llvm-svn: 344735
* [clangd] Support hover on "aut^o *".Haojian Wu2018-10-121-10/+14
| | | | | | | | | | Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53186 llvm-svn: 344330
* [clangd] Migrate to LLVM STLExtras range APIFangrui Song2018-10-071-5/+4
| | | | llvm-svn: 343946
* [clangd] NFC: Migrate to LLVM STLExtras API where possibleKirill Bobyrev2018-10-071-10/+8
| | | | | | | | | | | | | | This patch improves readability by migrating `std::function(ForwardIt start, ForwardIt end, ...)` to LLVM's STLExtras range-based equivalent `llvm::function(RangeT &&Range, ...)`. Similar change in Clang: D52576. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D52650 llvm-svn: 343937
* [clangd] Use canonical declarations in ReferenceFinder.Haojian Wu2018-10-041-12/+14
| | | | | | | | | | | | | | | | | | Summary: handleDeclOccurrencce reports a canonical declartion, so stick to use canonical declarations to determine whether a declaration is in the target set. Also fix a previous ref test which misses a matched label (it fails without this patch). Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52871 llvm-svn: 343763
* [clangd] Adapt API change after 342451.Eric Liu2018-09-181-4/+4
| | | | llvm-svn: 342452
* [clangd] Sort GoToDefinition results.Haojian Wu2018-09-051-33/+86
| | | | | | | | | | | | | | | | | | | | | | | Summary: GoToDefinition returns all declaration results (implicit/explicit) that are in the same location, and the results are returned in arbitrary order. Some LSP clients defaultly take the first result as the final result, which might present a bad result (implicit decl) to users. This patch ranks the result based on whether the declarations are referenced explicitly/implicitly. We put explicit declarations first. This also improves the "hover" (which just take the first result) feature in some cases. Reviewers: ilya-biryukov Subscribers: kadircet, ioeric, MaskRay, jkorous, mgrang, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50438 llvm-svn: 341463
* [clangd] Add xrefs LSP boilerplate implementation.Sam McCall2018-09-051-0/+1
| | | | | | | | | | Reviewers: ilya-biryukov, ioeric Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50896 llvm-svn: 341462
* [clangd] Implement findReferences functionSam McCall2018-09-051-78/+123
| | | | | | clangd will use findReferences to provide LSP's reference feature. llvm-svn: 341458
* [clangd] Remove unused parameter. NFCIlya Biryukov2018-08-281-6/+5
| | | | llvm-svn: 340816
* [clangd] Check for include overlapping looks for only the line now.Kadir Cetinkaya2018-08-231-1/+1
| | | | | | | | | | | | | | | | Summary: Currently we match an include only if we are inside filename, with this patch we will match whenever we are on the starting line of the include. Reviewers: ilya-biryukov, hokein, ioeric Reviewed By: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D51163 llvm-svn: 340539
* NFC: Enforce good formatting across multiple clang-tools-extra filesKirill Bobyrev2018-08-141-2/+2
| | | | | | | | | | | This patch improves readability of multiple files in clang-tools-extra and enforces LLVM Coding Guidelines. Reviewed by: ioeric Differential Revision: https://reviews.llvm.org/D50707 llvm-svn: 339687
* [clangd] Avoid duplicates in findDefinitions responseSimon Marchi2018-08-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When compile_commands.json contains some source files expressed as relative paths, we can get duplicate responses to findDefinitions. The responses only differ by the URI, which are different versions of the same file: "result": [ { ... "uri": "file:///home/emaisin/src/ls-interact/cpp-test/build/../src/first.h" }, { ... "uri": "file:///home/emaisin/src/ls-interact/cpp-test/src/first.h" } ] In getAbsoluteFilePath, we try to obtain the realpath of the FileEntry by calling tryGetRealPathName. However, this can fail and return an empty string. It may be bug a bug in clang, but in any case we should fall back to computing it ourselves if it happens. I changed getAbsoluteFilePath so that if tryGetRealPathName succeeds, we return right away (a real path is always absolute). Otherwise, we try to build an absolute path, as we did before, but we also call VFS->getRealPath to make sure to get the canonical path (e.g. without any ".." in it). Reviewers: malaperle Subscribers: hokein, ilya-biryukov, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48687 llvm-svn: 339483
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-1/+1
| | | | | | | | | | Reviewers: javed.absar Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50354 llvm-svn: 339400
* [clangd] Share getSymbolID implementation.Haojian Wu2018-08-071-9/+0
| | | | | | | | | | | | Summary: And remove all duplicated implementation. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50375 llvm-svn: 339116
* [clangd] Fix (most) naming warnings from clang-tidy. NFCIlya Biryukov2018-07-261-16/+16
| | | | llvm-svn: 338021
OpenPOWER on IntegriCloud