summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/index
Commit message (Collapse)AuthorAgeFilesLines
* [clangd] Add xref for macros to FileIndex.Utkarsh Saxena2020-01-084-3/+36
| | | | | | | | | | | | | | | Summary: Adds macro references to the dynamic index. Tests added. Also exposed a new API to convert path to URI in URI.h Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71406
* NFC: Fix trivial typos in commentsKazuaki Ishizaki2020-01-042-3/+3
|
* [NFC] Fixes -Wrange-loop-analysis warningsMark de Wever2020-01-011-1/+1
| | | | | | This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall. Differential Revision: https://reviews.llvm.org/D71857
* [NFC] Fix typos in Clangd and ClangKirill Bobyrev2019-12-163-18/+17
| | | | | | Reviewed by: Jim Differential Revision: https://reviews.llvm.org/D71455
* [clangd] Simplify code using findName. NFCIlya Biryukov2019-12-101-3/+3
| | | | | | | | | | | | | `findName` was always used in conjuction with `spellingLocIfSpelled`. This patch replaces patterns of the form: spellingLocIfSpelled(findName(&ND), SM) With a new helper function: nameLocation(ND, SM) And removes `spellingLocIfSpelled` and `findName`. Both are never used anywhere else and the latter is an equivalent of `Decl::getLocation` if we ever need it again.
* [clangd] Use expansion location when the ref is inside macros.Haojian Wu2019-12-091-4/+8
| | | | | | | | | | | | | | | | | | | | | 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] Add xref for macro to static index.Utkarsh Saxena2019-12-052-31/+51
| | | | | | | | | | | | | | Summary: This adds the references for macros to the SymbolCollector (used for static index). Enabled if `CollectMacro` option is set. Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70489
* Revert "Use InitLLVM to setup a pretty stack printer"Nico Weber2019-11-251-2/+1
| | | | | | | This reverts commit 3f76260dc0674cc0acb25f550a0f0c594cf537ea. Breaks at least these tests on Windows: Clang :: Driver/clang-offload-bundler.c Clang :: Driver/clang-offload-wrapper.c
* Use InitLLVM to setup a pretty stack printerRui Ueyama2019-11-261-1/+2
| | | | | | | | | | | | | | InitLLVM does not only save a few lines from main() but also makes the commands do the right thing for multibyte character pathnames on Windows (i.e. canonicalize argv's to UTF-8) because of the code we have in this file: https://github.com/llvm/llvm-project/blob/master/llvm/lib/Support/InitLLVM.cpp#L32 For many LLVM commands, we already have calls of InitLLVM, but there are still remainings. Differential Revision: https://reviews.llvm.org/D70702
* 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] Replace getLangOpts().isHeaderFile usage with isHeaderFile helper.Haojian Wu2019-11-151-1/+2
| | | | | | | | | | | | | | | | 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-151-5/+1
| | | | | | | | | | | | | | | | | | | 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
* [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-138-16/+40
| | | | | | | | | | | | | | | | 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] Use name of Macro to compute its SymbolID, NFC.Utkarsh Saxena2019-11-111-3/+3
| | | | | | | | | | | | | | | | | | | 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-111-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Set RetainCommentsFromSystemHeaders to trueIlya Biryukov2019-11-071-0/+1
| | | | | | | | | | 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] Collect name references in the index.Haojian Wu2019-10-241-4/+0
| | | | | | | | | | | | | | 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
* [clangd] Use our own relation kind.Haojian Wu2019-10-1711-84/+33
| | | | | | | | | | | | | | | | 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
* [clangd] If an undocumented definition exists, don't accept documentation ↵Sam McCall2019-10-071-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | from other forward decls. Summary: This fixes cases like: foo.h class Undocumented{} bar.h // break an include cycle. we should refactor this! class Undocumented; Where the comment doesn't describe the class. Note that a forward decl that is *visible to the definition* will still have its doc comment used, by SymbolCollector: Merge isn't involved here. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68467 llvm-svn: 373892
* [clang-tools-extra] [cmake] Link against libclang-cpp whenever possibleMichal Gorny2019-10-041-1/+4
| | | | | | | | | Use clang_target_link_libraries() in order to support linking against libclang-cpp instead of static libraries. Differential Revision: https://reviews.llvm.org/D68448 llvm-svn: 373786
* [clangd] Simplify the callside of URI::resolve, NFC.Haojian Wu2019-09-232-19/+5
| | | | | | | | | | | | | | | | Summary: - Add a overrloded URI::resolve, which accepts a string URI; - also fixed some callside that don't check the error; Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67916 llvm-svn: 372617
* [Support] Add overload writeFileAtomically(std::function Writer)Jan Korous2019-09-131-31/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D67424 llvm-svn: 371890
* [clangd] Attempt to fix failing Windows buildbots.Ilya Biryukov2019-09-091-3/+6
| | | | | | | | | The assertion is failing on Windows, probably because path separator is different. For the failure see: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/28072/steps/test/logs/stdio llvm-svn: 371422
* [clangd] Use pre-populated mappings for standard symbolsIlya Biryukov2019-09-093-66/+60
| | | | | | | | | | | | | | | | | | | | Summary: This takes ~5% of time when running clangd unit tests. To achieve this, move mapping of system includes out of CanonicalIncludes and into a separate class Reviewers: sammccall, hokein Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67172 llvm-svn: 371408
* [clang][Index][NFC] Put IndexingOptions to a separate headerJan Korous2019-09-062-0/+2
| | | | llvm-svn: 371250
* [clangd] Rename ClangdUnit.h -> ParsedAST.h. NFCSam McCall2019-09-043-3/+3
| | | | | | | | | | 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] Move getBeginningOfIdentifier from ClangdUnit to SourceCode. Drop ↵Sam McCall2019-09-031-1/+2
| | | | | | dependencies on ClangdUnit from some headers. NFC llvm-svn: 370768
* [Index] Added a ShouldSkipFunctionBody callback to libIndex, and refactored ↵Dmitri Gribenko2019-08-291-30/+9
| | | | | | | | | | | | clients to use it instead of inventing their own solution Subscribers: jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66879 llvm-svn: 370338
* [Index] Stopped wrapping FrontendActions in libIndex and its usersDmitri Gribenko2019-08-291-43/+34
| | | | | | | | | Exposed a new function, createIndexingASTConsumer, that creates an ASTConsumer. ASTConsumers compose well. Removed wrapping functionality from createIndexingAction. llvm-svn: 370337
* [clangd] Surface errors from command-line parsingIlya Biryukov2019-08-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Those errors are exposed at the first character of a file, for a lack of a better place. Previously, all errors were stored inside the AST and report accordingly. However, errors in command-line argument parsing could result in failure to produce the AST, so we need an alternative ways to report those errors. We take the following approach in this patch: - buildCompilerInvocation() now requires an explicit DiagnosticConsumer. - TUScheduler and TestTU now collect the diagnostics produced when parsing command line arguments. If pasing of the AST failed, diagnostics are reported via a new ParsingCallbacks::onFailedAST method. If parsing of the AST succeeded, any errors produced during command-line parsing are stored alongside the AST inside the ParsedAST instance and reported as previously by calling the ParsingCallbacks::onMainAST method; - The client code that uses ClangdServer's DiagnosticConsumer does not need to change, it will receive new diagnostics in the onDiagnosticsReady() callback Errors produced when parsing command-line arguments are collected using the same StoreDiags class that is used to collect all other errors. They are recognized by their location being invalid. IIUC, the location is invalid as there is no source manager at this point, it is created at a later stage. Although technically we might also get diagnostics that mention the command-line arguments FileID with after the source manager was created (and they have valid source locations), we choose to not handle those and they are dropped as not coming from the main file. AFAICT, those diagnostics should always be notes, therefore it's safe to drop them without loosing too much information. Reviewers: kadircet Reviewed By: kadircet Subscribers: nridge, javed.absar, MaskRay, jkorous, arphaman, cfe-commits, gribozavr Tags: #clang Differential Revision: https://reviews.llvm.org/D66759 llvm-svn: 370177
* Fix clangd's IndexAction for FileSkipped API updateAlex Lorenz2019-08-271-2/+2
| | | | llvm-svn: 370004
* Fight a bit against global initializers. NFC.Benjamin Kramer2019-08-222-658/+658
| | | | llvm-svn: 369695
* Remove \brief commands from doxygen comments.Dmitri Gribenko2019-08-222-5/+5
| | | | | | | | | | | | | | | | | | | | | | | Summary: We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done [This is analogous to LLVM r331272 and CFE r331834] Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66578 llvm-svn: 369643
* [clangd] Skip function bodies inside processed files while indexingIlya Biryukov2019-08-203-16/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This significantly improves performance of background indexing. We do not collect references and declarations inside the processed files, so this does not affect the final indexing results. The idea is borrowed from libclang, which has a similar optimization in its indexing functionality. Measurements show a nice decrease in indexing time, up to ~40% for building the whole index. These are not proper benchmarks, so one should not rely on these results too much. 1. Rebuilding the whole index for LLVM: - Before. Total time: 14m58s. ./bin/clangd -pch-storage=memory < ./clangd.input 23917.67s user 515.86s system 2718% cpu 14:58.68 total - After. Total time: 8m41s. ./bin/clangd -pch-storage=memory < ./clangd.input 13627.29s user 288.10s system 2672% cpu 8:40.67 total 2. Rebuilding index after removing shards matching '*clangd*' (case-insensitively): - Before. Total time: 30s. ./bin/clangd -pch-storage=memory < ./clangd.input 130.94s user 6.82s system 452% cpu 30.423 total - After. Total time: 26s. ./bin/clangd -pch-storage=memory < ./clangd.input 80.51s user 5.40s system 333% cpu 25.777 total Reviewers: kadircet, sammccall Reviewed By: kadircet Subscribers: MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66226 llvm-svn: 369349
* [clang-tools-extra] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-1411-39/+39
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368944
* [clangd] Unfold SourceLocation flattening from findNameLoc in preparation ↵Sam McCall2019-08-061-3/+3
| | | | | | for adding more overloads. NFC llvm-svn: 368083
* [clang-tools-extra] Adopt FileManager's error-returning APIsHarlan Haskins2019-08-011-3/+4
| | | | | | | | The FileManager has been updated to return llvm::ErrorOr from getFile and getDirectory, this commit updates all the callers of those APIs from clang. llvm-svn: 367617
* [clangd] Also accept flags from CLANGD_FLAGS variable.Sam McCall2019-07-251-2/+2
| | | | | | | | | | | | | | | | This simplifies various workflows, particularly in debugging/development. e.g. editors will tend to propagate flags, so you can run `env CLANGD_FLAGS=-input-mirror-file=/tmp/mirror vim foo.cc` rather than change the configuration in a persistent way. (This also gives us a generic lever when we don't know how to customize the flags in some particular LSP client). While here, add a test for this and other startup logging, and fix a couple of direct writes to errs() that should have been logs. Differential Revision: https://reviews.llvm.org/D65153 llvm-svn: 366991
* Revert "Revert r366458, r366467 and r366468"Kadir Cetinkaya2019-07-197-213/+343
| | | | | | | | | | | | | | | | | | | | | | This reverts commit 9c377105da0be7c2c9a3c70035ce674c71b846af. [clangd][BackgroundIndexLoader] Directly store DependentTU while loading shard Summary: We were deferring the population of DependentTU field in LoadedShard until BackgroundIndexLoader was consumed. This actually triggers a use after free since the shards FileToTU was pointing at could've been moved while consuming the Loader. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64980 llvm-svn: 366559
* Revert r366458, r366467 and r366468Azharuddin Mohammed2019-07-197-351/+213
| | | | | | | | | | | r366458 is causing test failures. r366467 and r366468 had to be reverted as they were casuing conflict while reverting r366458. r366468 [clangd] Remove dead code from BackgroundIndex r366467 [clangd] BackgroundIndex stores shards to the closest project r366458 [clangd] Refactor background-index shard loading llvm-svn: 366551
* [clangd] cleanup: unify the implemenation of checking a location is inside ↵Haojian Wu2019-07-191-2/+1
| | | | | | | | | | | | | | | | main file. Summary: We have variant implementations in the codebase, this patch unifies them. Reviewers: ilya-biryukov, kadircet Subscribers: MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64915 llvm-svn: 366541
* [clangd] Remove dead code from BackgroundIndexKadir Cetinkaya2019-07-181-3/+0
| | | | llvm-svn: 366468
* [clangd] BackgroundIndex stores shards to the closest projectKadir Cetinkaya2019-07-184-65/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Changes persistance logic to store shards at the directory of closest CDB. Previously we were storing all shards to directory of the CDB that triggered indexing, it had its downsides. For example, if you had two TUs coming from a different CDB but depending on the same header foo.h, we will store the foo.h only for the first CDB, and it would be missing for the second and we would never persist it since it was actually present in the memory and persisted before. This patch still stores only a single copy of a shard, but makes the directory a function of the file name. So that the shard place will be unique even with multiple CDBs accessing the file. This directory is determined as the first directory containing a CDB in the file's parent directories, if no such directory exists we make use of the home directory. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64745 llvm-svn: 366467
* [clangd] Refactor background-index shard loadingKadir Cetinkaya2019-07-186-165/+290
| | | | | | | | | | | | Reviewers: sammccall Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64712 llvm-svn: 366458
* [clangd] Don't rebuild background index until we indexed one TU per thread.Sam McCall2019-07-162-7/+9
| | | | | | | | | | | | | | | | | Summary: This increases the odds that the boosted file (cpp file matching header) will be ready. (It always enqueues first, so it'll be present unless another thread indexes *two* files before the first thread indexes one.) Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64682 llvm-svn: 366199
* [clangd] Fix off-by-one in CodeComplete and assertion in DexSam McCall2019-07-121-2/+2
| | | | llvm-svn: 365955
* [clangd] Prioritize indexing of files that share a basename with the open file.Sam McCall2019-07-123-2/+50
| | | | | | | | | | | | | | | | | Summary: In practice, opening Foo.h will still often result in Foo.cpp making the second index build instead of the first, as the rebuild policy doesn't know to wait. Reviewers: kadircet Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64575 llvm-svn: 365888
* [clangd] Avoid template in Task constructor, hopefully fix MSVC buildSam McCall2019-07-111-2/+1
| | | | llvm-svn: 365794
* [clangd] Remove an extra ";", NFCHaojian Wu2019-07-111-1/+1
| | | | llvm-svn: 365778
OpenPOWER on IntegriCloud