summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/unittests
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Added highlighting for the targets in typedefs and using.Johan Vikstrom2019-07-161-1/+14
| | | | | | | | | | | | | | | | | | Summary: In `typedef int A` the `A` was not highlighted previously. This patch gives `A` the same kind of highlighting that the underlying type has (class/enum) (which in this example is no special highlighting because builtins are not handled yet) Will add highlightings for built ins in another patch. Reviewers: hokein, sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64754 llvm-svn: 366207
* [clangd] Don't rebuild background index until we indexed one TU per thread.Sam McCall2019-07-161-5/+5
| | | | | | | | | | | | | | | | | 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 duplicate highlighting tokens appearing in initializer lists.Johan Vikstrom2019-07-151-0/+7
| | | | | | | | | | | | | | Summary: The RecursiveASTVisitor sometimes visits exprs in initializer lists twice. Added deduplication to prevent duplicate highlighting tokens from appearing. Done by sorting and a linear search. Reviewers: hokein, sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64634 llvm-svn: 366070
* [clangd] Added highlighting for members and methods.Johan Vikstrom2019-07-151-9/+35
| | | | | | | | | | | | | | Summary: Added highlighting for members and methods. Reviewers: hokein, sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64617 llvm-svn: 366047
* [clangd] Added highlighting to enum constants.Johan Vikstrom2019-07-151-5/+13
| | | | | | | | | | | | | | Summary: VSCode does not have a scope for enum constants. So they were placed under "constant.other.enum" as that seems to be the most correct scope for enum constants. However, this makes theia color them blue (the same color it uses for keywords). Reviewers: hokein, sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64624 llvm-svn: 366045
* [clangd] Implement typeHierarchy/resolve for subtypesNathan Ridge2019-07-131-1/+45
| | | | | | | | | | | | | | | | | | Summary: This allows the client to resolve subtypes one level at a time. For supertypes, this is not necessary, because we eagerly compute supertypes and return all levels. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64308 llvm-svn: 365986
* Revert "[clangd] Implement typeHierarchy/resolve for subtypes"Russell Gallop2019-07-121-45/+1
| | | | | | | | Causing test failure on Windows bot This reverts commit 5b9484e559d44bd923fc290e335891b1dd2e17c4. llvm-svn: 365899
* [clangd] Fixed toHalfOpenFileRangeShaurya Gupta2019-07-121-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | Summary: - Fixed toHalfOpenFileRange to work for macros as well as template instantiations - Added unit tests Breaking test case for older version of toHalfOpenFileRange: \# define FOO(X) X++ int a = 1; int b = FOO(a); toHalfOpenFileRange for the sourceRange of VarDecl for b returned the wrong Range. Reviewers: sammccall, kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64562 llvm-svn: 365894
* [clangd] Prioritize indexing of files that share a basename with the open file.Sam McCall2019-07-121-0/+35
| | | | | | | | | | | | | | | | | 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] Implement typeHierarchy/resolve for subtypesNathan Ridge2019-07-121-1/+45
| | | | | | | | | | | | | | | | | | Summary: This allows the client to resolve subtypes one level at a time. For supertypes, this is not necessary, because we eagerly compute supertypes and return all levels. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64308 llvm-svn: 365867
* [clangd][NFC] Decrease template depth limit in RecursiveHierarchyUnbounded testJan Korous2019-07-111-0/+1
| | | | | | ...to minimize the chance of stack overflow before reaching the limit. llvm-svn: 365804
* [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-114-0/+213
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Add priorities to background index queue, extract to separate classSam McCall2019-07-111-1/+33
| | | | | | | | | | | | Reviewers: kadircet Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64560 llvm-svn: 365773
* [clangd] Remove the extra ";", NFCHaojian Wu2019-07-111-1/+1
| | | | llvm-svn: 365764
* [clangd] Fix an assertion crash in "ExtractVariable" tweakHaojian Wu2019-07-111-0/+8
| | | | | | | | | | | | | | | | Summary: GetTypePtr requires that the type should not be null, otherwise we hit an assertion, we should use getTypePtrOrNull instead. Reviewers: sammccall, SureYeaah Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64556 llvm-svn: 365763
* [clangd] Fix windows buildbotsKadir Cetinkaya2019-07-111-5/+17
| | | | llvm-svn: 365756
* [clangd] Reland rL365634Kadir Cetinkaya2019-07-114-13/+140
| | | | | | | | | This was reverted in rL365678, the failure was due to YAML parsing of compile_commands.json. Converting backslashes to forward slashes to fix the issue in unittest. llvm-svn: 365748
* [clangd] Added highlightings for namespace specifiers.Johan Vikstrom2019-07-111-5/+29
| | | | | | | | | | | | | | Summary: Added highlightings for namespace specifiers. Reviewers: hokein, sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64492 llvm-svn: 365745
* Revert "[clangd] Filter out non-governed files from broadcast"Matthew Voss2019-07-104-139/+13
| | | | | | | | | | This reverts commit d5214dfa7b5650745eaeb102857c9e90adb16137. It's causing failures, both in our local CI and the PS4 Windows bot. http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/26872/steps/test/logs/stdio llvm-svn: 365678
* [clangd] Filter out non-governed files from broadcastKadir Cetinkaya2019-07-104-13/+139
| | | | | | | | | | | | | | | | Summary: This also turns off implicit discovery of additional compilation databases. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64247 llvm-svn: 365634
* [clangd] Add a flag to clangdServer rename function to control whether we ↵Haojian Wu2019-07-101-1/+1
| | | | | | | | | | | | | | | | | | | 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-101-0/+21
| | | | | | | | | 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] Added highlighting for class and enum types.Johan Vikstrom2019-07-101-11/+43
| | | | | | | | | | | | | | 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-091-36/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-092-15/+53
| | | | | | | | | | | | | | | | | | | 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
* dummy variable extraction on a function scopeShaurya Gupta2019-07-091-6/+136
| | | | | | | | | | | | | | | | | | | 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-081-5/+13
| | | | | | | | | | | | | | 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] A code tweak to expand a macroIlya Biryukov2019-07-081-0/+93
| | | | | | | | | | | | | | 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-081-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Added highlighting for variable references (declrefs)Johan Vikstrom2019-07-051-14/+29
| | | | | | | | | | | | | | 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-051-0/+38
| | | | | | | | | | | | | | | | | | | | 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] Add a hidden tweak to annotate all highlighting tokens of the file.Haojian Wu2019-07-041-0/+8
| | | | | | | | | | | | 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] Make HadErrors part of background index's internal stateKadir Cetinkaya2019-07-041-12/+35
| | | | | | | | | | | | 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-043-5/+19
| | | | | | | | | | | | 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-042-0/+76
| | | | | | | | | | | | | | 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-041-0/+35
| | | | | | | | | | | | | | | | 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] Emit publishSemanticHighlighting in LSP if enabledJohan Vikstrom2019-07-041-1/+25
| | | | | | | | | | | | | | 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-032-12/+11
| | | | | | | | | | | | | | | | | | 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-021-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clangd] No longer getting template instantiations from header files in Main ↵Johan Vikstrom2019-07-011-0/+20
| | | | | | | | | | | | 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] Make PreambleStatusCache handle filenames more carefullySam McCall2019-07-011-2/+10
| | | | | | | | | | | | | | | | | | | | | 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-012-0/+24
| | | | | | | | | | | | | | | | | | 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-011-6/+16
| | | | | | | | | | | | | | | | | | 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
* [clangd] Emit semantic highlighting tokens when the main AST is built.Johan Vikstrom2019-06-271-0/+26
| | | | | | 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-271-16/+25
| | | | | | | | | | | | | | | | | | | | | | | | 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] Address limitations in SelectionTree:Sam McCall2019-06-271-2/+59
| | | | | | | | | | | | | | | | | | 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-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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-262-0/+70
| | | | | | and function declarations llvm-svn: 364421
OpenPOWER on IntegriCloud