summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Trim spaces around parsed include in include extractorKadir Cetinkaya2019-07-101-1/+1
| | | | llvm-svn: 365632
* [clangd] Add a flag to clangdServer rename function to control whether we ↵Haojian Wu2019-07-104-14/+19
| | | | | | | | | | | | | | | | | | | want format the replacements. Summary: This would allow clangd embedders to use the ClangdServer::rename for other purposes (highlighting all the occurrences of the symbol in prepare stage). Reviewers: sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64481 llvm-svn: 365631
* [clangd] Stop recording tokens before running clang-tidyIlya Biryukov2019-07-102-4/+28
| | | | | | | | | modernize-trailing-return-type runs the preprocessor, breaking the token collection logic. This lead to a crash before, see the new test for a repro. llvm-svn: 365607
* [clangd] Consume error to avoid assertion failuresIlya Biryukov2019-07-101-2/+3
| | | | | | | When we fail to calculate #include insertion for a completion item. Note that this change does not add a test, although that would be good. llvm-svn: 365606
* [clangd] Added highlighting for class and enum types.Johan Vikstrom2019-07-104-16/+98
| | | | | | | | | | | | | | Summary: Added highlighting for non-builtin types using VisitTypeLoc. Ignoring namespace qualifiers as for now. Reviewers: hokein, sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64257 llvm-svn: 365602
* [clangd] fix assert in test after r365531.Sam McCall2019-07-091-7/+12
| | | | | | Unverified because CMake/ninja seems to be broken... llvm-svn: 365576
* [clangd] Rewrite of logic to rebuild the background index serving structures.Sam McCall2019-07-0910-102/+330
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously it was rebuilding every 5s by default, which was much too frequent in the long run - the goal was to provide an early build. There were also some bugs. There were also some bugs, and a dedicated thread was used in production but not tested. - rebuilds are triggered by #TUs built, rather than time. This should scale more sensibly to fast vs slow machines. - there are two separate indexed-TU thresholds to trigger index build: 5 TUs for the first build, 100 for subsequent rebuilds. - rebuild is always done on the regular indexing threads, and is affected by blockUntilIdle. This means unit/lit tests run the production configuration. - fixed a bug where we'd rebuild after attempting to load shards, even if there were no shards. - the BackgroundIndexTests don't really test the subtleties of the rebuild policy (for determinism, we call blockUntilIdle, so rebuild-on-idle is enough to pass the tests). Instead, we expose the rebuilder as a separate class and have fine-grained tests for it. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64291 llvm-svn: 365531
* [clangd] Show documentation in hover, and fetch docs from index if needed.Sam McCall2019-07-096-44/+113
| | | | | | | | | | | | | | | | | | | 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
* Fixed assertionShaurya Gupta2019-07-091-1/+1
| | | | llvm-svn: 365460
* dummy variable extraction on a function scopeShaurya Gupta2019-07-093-6/+380
| | | | | | | | | | | | | | | | | | | Summary: - Added extraction to a dummy variable - using auto for the dummy variable type for now - Works on a function scope - Adding braces to create a compound statement not supported yet - added unit tests Reviewers: sammccall, kadircet Subscribers: mgorny, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63773 llvm-svn: 365453
* [clangd] Don't insert absolute paths, give up instead.Sam McCall2019-07-085-19/+46
| | | | | | | | | | | | | | Summary: Also implement resolution of paths relative to mainfile without HeaderSearchInfo. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64293 llvm-svn: 365364
* [clangd] Use -completion-style=bundled by default if signature help is availableSam McCall2019-07-086-5/+19
| | | | | | | | | | | | | | | | Summary: I didn't manage to find something nicer than optional<bool>, but at least I found a sneakier comment. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64216 llvm-svn: 365356
* [clangd] A code tweak to expand a macroIlya Biryukov2019-07-083-0/+231
| | | | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61681 llvm-svn: 365331
* [clangd] Use xxhash instead of SHA1 for background index file digests.Sam McCall2019-07-087-17/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Currently SHA1 is about 10% of our CPU, this patch reduces it to ~1%. xxhash is a well-defined (stable) non-cryptographic hash optimized for fast checksums (like crc32). Collisions shouldn't be a problem, despite the reduced length: - for actual file content (used to invalidate bg index shards), there are only two versions that can collide (new shard and old shard). - for file paths in bg index shard filenames, we would need 2^32 files with the same filename to expect a collision. Imperfect hashing may reduce this a bit but it's well beyond what's plausible. This will invalidate shards on disk (as usual; I bumped the version), but this time the filenames are changing so the old files will stick around :-( So this is more expensive than the usual bump, but would be good to land before the v9 branch when everyone will start using bg index. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64306 llvm-svn: 365311
* [clangd] Avoid slow ostreams in URI conversion.Sam McCall2019-07-081-16/+15
| | | | | | | This speeds up some hot paths significantly (e.g. dex::generateProximityURIs by a third or so) llvm-svn: 365289
* [clangd] Encapsulate fields in dex token. NFCSam McCall2019-07-082-6/+7
| | | | llvm-svn: 365288
* [clangd] Added highlighting for variable references (declrefs)Johan Vikstrom2019-07-052-24/+59
| | | | | | | | | | | | | | Summary: Added highlighting for variable references using VisitDeclRefExpr. Reviewers: hokein, sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64199 llvm-svn: 365205
* [clangd] Deduplicate clang-tidy diagnostic messages.Haojian Wu2019-07-054-230/+48
| | | | | | | | | | | | | | | | | | | | Summary: Clang-tidy checks may emit duplicated messages (clang-tidy tool deduplicate them in its custom diagnostic consumer), and we may show multiple duplicated diagnostics in the UI, which is really bad. This patch makes clangd do the deduplication, and revert the change rL363889. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64127 llvm-svn: 365204
* [clangd] Mark a couple of unimportant flags as hidden. NFCSam McCall2019-07-041-2/+3
| | | | llvm-svn: 365151
* [clangd] Fix breakage on gcc 5.4Kadir Cetinkaya2019-07-041-1/+1
| | | | llvm-svn: 365140
* [clangd] Some tweaks on semantic highlighting lookuptable.Haojian Wu2019-07-044-23/+28
| | | | | | | | | | | | | | | | Summary: - move toTextMateScope to SemanticHighlighting.h; - move the buildLookupTable to LSP layer (as LSP requires such form); Reviewers: sammccall, jvikstrom Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64202 llvm-svn: 365135
* [clangd] Fix a lifetime bug in QueryDriverKadir Cetinkaya2019-07-041-8/+12
| | | | llvm-svn: 365134
* [clangd] Query driver reads stderr and passes driver as first argumentKadir Cetinkaya2019-07-042-18/+17
| | | | | | | | | | | | | | | | | Summary: gcc invokes cc1 through a path deduced from argv[0] therefore it must be correctly set. Also it prints the search path to stderr not stdout, this also applies to clang. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64196 llvm-svn: 365132
* [clangd] Add a hidden tweak to annotate all highlighting tokens of the file.Haojian Wu2019-07-043-0/+91
| | | | | | | | | | | | Reviewers: sammccall, jvikstrom Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64137 llvm-svn: 365130
* [clangd] Turn background-index on by defaultKadir Cetinkaya2019-07-041-1/+1
| | | | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64019 llvm-svn: 365124
* [clangd] Make HadErrors part of background index's internal stateKadir Cetinkaya2019-07-043-68/+101
| | | | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64147 llvm-svn: 365123
* [clangd] Add HadErrors field into shardsKadir Cetinkaya2019-07-047-15/+59
| | | | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64133 llvm-svn: 365122
* [clangd] Store hash of command line in index shards.Kadir Cetinkaya2019-07-045-1/+149
| | | | | | | | | | | | | | Summary: This is to enable cache invalidation when command line flags changes. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64018 llvm-svn: 365121
* [clangd] Also cache failures while indexingKadir Cetinkaya2019-07-045-16/+68
| | | | | | | | | | | | | | | | Summary: Clangd currently doesn't cache any indexing failures, which results in retrying those failed files even if their contents haven't changed. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63986 llvm-svn: 365120
* [clangd] Add missing changes for 365111Johan Vikstrom2019-07-042-45/+4
| | | | llvm-svn: 365112
* [clangd] Emit publishSemanticHighlighting in LSP if enabledJohan Vikstrom2019-07-048-3/+279
| | | | | | | | | | | | | | Summary: Emit publishSemanticHighlighting in LSP if enabled Reviewers: hokein, kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63919 llvm-svn: 365111
* [clang][HeaderSearch] Shorten paths for includes in mainfile's directoryKadir Cetinkaya2019-07-036-18/+24
| | | | | | | | | | | | | | | | | | Summary: Currently HeaderSearch only looks at SearchDir's passed into it, but in addition to those paths headers can be relative to including file's directory. This patch makes sure that is taken into account. Reviewers: gribozavr Subscribers: jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63295 llvm-svn: 365005
* [clangd] Collect the refs when the main file is header.Haojian Wu2019-07-023-6/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, we only collect refs of the symbols which are declared in the preamble and referenced in the main file, it works well when the main file is .cpp file. However, when the main file is .h file (when opening a .h file in the editor), we don't collect refs of the symbol declared in this file, so we miss these refs in our dynamic index. A typical scenario: 1. Open Foo.h (which contains class Foo) 2. Open Foo.cpp, call find references for Foo And we only get refs from Foo.cpp. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63818 llvm-svn: 364893
* Summary: [Clangd] Added hidden command line option -tweaks to specify which ↵Shaurya Gupta2019-07-014-3/+20
| | | | | | | | | | | | | | | | tweaks to enable - Only for development purposes - Disabled tweaks in fixits-duplications test Reviewers: sammccall, kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63989 llvm-svn: 364809
* [clangd] No longer getting template instantiations from header files in Main ↵Johan Vikstrom2019-07-012-1/+22
| | | | | | | | | | | | AST. Previous implementation to filter decls not in the main file did not work in the case where a template was instantiated from a header in the main file. It would than include that function/class in topLevelDecls. Differential Revision: https://reviews.llvm.org/D63817 llvm-svn: 364747
* [clangd] Fix unused var from r364735Sam McCall2019-07-011-5/+4
| | | | llvm-svn: 364741
* [clangd] Make PreambleStatusCache handle filenames more carefullySam McCall2019-07-012-6/+25
| | | | | | | | | | | | | | | | | | | | | Summary: - when we hit the cache, the reported filename should be that of the cache query, not that of the cache store. This matches behaviors of common FSes, and avoids triggering difficult edge cases in FileManager when files are being moved around concurrently. - filename comparisons (both cache queries and == mainfile checks) should fold away . and .. in paths. These can appear when relative paths occur in compile_commands.json. (gn does this). Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63931 llvm-svn: 364740
* [clangd] Show better message when we rename macros.Haojian Wu2019-07-016-64/+105
| | | | | | | | | | | | | | | | | | Summary: Previously, when we rename a macro, we get an error message of "there is no symbol found". This patch improves the message of this case (as we don't support macros). Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63922 llvm-svn: 364735
* [clangd] Make FixIt message be consistent with the clang-tidy diagnostic ↵Haojian Wu2019-07-012-6/+18
| | | | | | | | | | | | | | | | | | message. Summary: We strip the "[clang-tidy-check]" suffix from the clang-tidy diagnostics, we should be consistent with the message in FixIt (strip the suffix as well). Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63926 llvm-svn: 364731
* Cleanup: llvm::bsearch -> llvm::partition_point after r364719Fangrui Song2019-06-301-2/+2
| | | | llvm-svn: 364720
* [ADT] Implement llvm::bsearch() with std::partition_point()Fangrui Song2019-06-301-4/+4
| | | | | | | | | | | | | | | | | | | Summary: Delete the begin-end form because the standard std::partition_point can be easily used as a replacement. The ranges-style llvm::bsearch will be renamed to llvm::partition_point in the next clean-up patch. The name "bsearch" doesn't meet people's expectation because in C: > If two or more members compare equal, which member is returned is unspecified. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D63718 llvm-svn: 364719
* [clangd] Emit semantic highlighting tokens when the main AST is built.Johan Vikstrom2019-06-273-7/+49
| | | | | | Differential Revision: https://reviews.llvm.org/D63821 llvm-svn: 364551
* [clangd] Fix a case where we fail to detect a header-declared symbol in rename.Haojian Wu2019-06-272-28/+38
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Failing case: ``` #include "foo.h" void fo^o() {} ``` getRenameDecl() returns the decl of the symbol under the cursor (which is in the current main file), instead, we use the canonical decl to determine whether a symbol is declared in #included header. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63872 llvm-svn: 364537
* [clangd] No need to setTraversalScope in SemanticHighlighting.Haojian Wu2019-06-272-4/+3
| | | | | | | | | | | | | | | | Summary: We have already set it when the AST is being built, and setting TraversalScope is not free (it will clear the cache, which is expensive to build). Reviewers: jvikstrom Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63874 llvm-svn: 364528
* [clangd] Address limitations in SelectionTree:Sam McCall2019-06-272-51/+164
| | | | | | | | | | | | | | | | | | Summary: - nodes can have special-cased hit ranges including "holes" (FunctionTypeLoc in void foo()) - token conflicts between siblings (int a,b;) are resolved in favor of left sibling - parent/child overlap is handled statefully rather than explicitly by comparing parent/child ranges (this lets us share a mechanism with sibling conflicts) Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63760 llvm-svn: 364519
* BitStream reader: propagate errorsJF Bastien2019-06-264-8/+10
| | | | | | | | | | | | | | | | | | | | | | The bitstream reader handles errors poorly. This has two effects: * Bugs in file handling (especially modules) manifest as an "unexpected end of file" crash * Users of clang as a library end up aborting because the code unconditionally calls `report_fatal_error` The bitstream reader should be more resilient and return Expected / Error as soon as an error is encountered, not way late like it does now. This patch starts doing so and adopting the error handling where I think it makes sense. There's plenty more to do: this patch propagates errors to be minimally useful, and follow-ups will propagate them further and improve diagnostics. https://bugs.llvm.org/show_bug.cgi?id=42311 <rdar://problem/33159405> Differential Revision: https://reviews.llvm.org/D63518 llvm-svn: 364464
* [clangd] Added functionality for getting semantic highlights for variable ↵Johan Vikstrom2019-06-265-0/+186
| | | | | | and function declarations llvm-svn: 364421
* [clangd] Disable failing unittest on non-x86 platformsKadir Cetinkaya2019-06-261-0/+1
| | | | llvm-svn: 364413
* [clangd] Don't rename the namespace.Haojian Wu2019-06-263-10/+34
| | | | | | | | | | | | | | | | | Summary: Also fix a small bug -- the extra argument "-xc++" doesn't overwrite the language if the argument is present after the file name in the compiler command. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63759 llvm-svn: 364392
* [clangd] Add Value field to HoverInfoKadir Cetinkaya2019-06-263-3/+87
| | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud