summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Correct the documentation, NFC.Haojian Wu2019-08-081-1/+1
| | | | llvm-svn: 368277
* [clangd] Fix implicit template instatiations appearing as topLevelDecls.Johan Vikstrom2019-08-086-13/+163
| | | | | | | | | | | | | | Summary: The parser gives implicit template instantiations to the action's HandleTopLevelDecls callback. This makes semantic highlighting highlight these templated functions multiple times. Fixed by filtering on if a Decl is an implicit function/variable/class instantiation. Also added a testcase to semantic highlighting on this. Reviewers: hokein, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65510 llvm-svn: 368261
* Code completion should not ignore default parameters in functions.Sam McCall2019-08-073-0/+61
| | | | | | | | | | | | | | | | | | | | Summary: Inorder to display the default arguments we must process the CK_Optional chunks of CodeCompletionString while creating the Signature. We do not create placeholders for default arguments. Reviewers: sammccall Reviewed By: sammccall Subscribers: jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65866 llvm-svn: 368186
* [clangd] Added a TextMate theme parser to the vscode extension.Johan Vikstrom2019-08-075-1/+167
| | | | | | | | | | | | | | | Summary: Adds a TextMate parser module to the vscode extension. It parses a theme into an array of a pair of TextMate scopes and text colors. Reviewers: hokein, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65738 llvm-svn: 368136
* [clangd] Unfold SourceLocation flattening from findNameLoc in preparation ↵Sam McCall2019-08-067-33/+48
| | | | | | for adding more overloads. NFC llvm-svn: 368083
* Fixed toHalfOpenFileRange assertion failShaurya Gupta2019-08-062-12/+61
| | | | | | | | | | | | | | Summary: - Added new function that gets Expansion range with both ends in the same file. - Fixes the crash at https://github.com/clangd/clangd/issues/113 Subscribers: ilya-biryukov, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65754 llvm-svn: 368058
* [clangd] Compute scopes eagerly in IncludeFixerIlya Biryukov2019-08-063-37/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Computing lazily leads to crashes. In particular, computing scopes may produce diagnostics (from inside template instantiations) and we currently do it when processing another diagnostic, which leads to crashes. Moreover, we remember and access 'Scope*' when computing scopes. This might lead to invalid memory access if the Scope is deleted by the time we run the delayed computation. We did not actually construct an example when this happens, though. From the VCS and review history, it seems the optimization was introduced in the initial version without a mention of any performance benchmarks justifying the performance gains. This led me to a conclusion that the optimization was premature, so removing it to avoid crashes seems like the right trade-off at that point. Reviewers: sammccall Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65796 llvm-svn: 368019
* [clangd] Add a callback mechanism for handling responses from client.Haojian Wu2019-08-056-29/+201
| | | | | | | | | | | | | | | | | | | Summary: The callback will be invoked in clangd when we receive a reply from the client. This is a prerequisite of implementing a generic mechanism for chainable refactorings (e.g. extract variable and rename), this would allow server to trigger a new request to the LSP client after receiving a reply from the client. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65387 llvm-svn: 367845
* [clangd] Expose -offset-encoding=utf-32, which has been implemented for agesSam McCall2019-08-051-1/+3
| | | | llvm-svn: 367812
* [clangd] Fix error message with incorrect ↵Sam McCall2019-08-051-1/+1
| | | | | | TextDocumentcontentChangeEvent.rangeLength llvm-svn: 367811
* [clangd] Fix a crash when presenting values for HoverIlya Biryukov2019-08-022-1/+11
| | | | | | | | | | | | | | | | | | | 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][vscode] clang-format the the extension code.Haojian Wu2019-08-025-99/+105
| | | | | | | | | | | | | | | | | | | | | Summary: As we are going to grow the extension in the near future, it is time to formalize the TS code format/style of our extension (although we'd lose the history). We use default options of clang-format: - 80 max line length - 2 space indent Reviewers: ilya-biryukov, sammccall, jvikstrom Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65657 llvm-svn: 367684
* Fix "not all control paths return a value" warning. NFCI.Simon Pilgrim2019-08-021-0/+1
| | | | llvm-svn: 367678
* [clangd] Remove bad assert: nothing relies on it, and the reasons it was ↵Sam McCall2019-08-021-3/+2
| | | | | | true no longer hold. llvm-svn: 367672
* [clangd] Add new helpers to make tweak tests scale better. Convert most ↵Sam McCall2019-08-024-365/+366
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tests. NFC Summary: TweakTests.cpp has some pretty good helpers added for the first few tweaks, but they have some limitations: - many assertion failures point at the wrong line - need lots of input/output tests, setup code is duplicated across both - local helpers make it hard to split the file as it grows The new helpers in TweakTests.h are based on old ones (same operations) but try to address these issues and generally make tests more terse while improving error messages. This patch converts everything except ExtractVariable (which is complex and has changes in flight, so will be converted later). It's LOC-neutral, despite not being able to get rid of the old helpers until ExtractVariable is done. Reviewers: ilya-biryukov Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65525 llvm-svn: 367667
* [clang-tools-extra] Adopt FileManager's error-returning APIsHarlan Haskins2019-08-013-6/+8
| | | | | | | | 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] Add missing braces to completion tests. NFCIlya Biryukov2019-08-011-0/+4
| | | | llvm-svn: 367541
* [clangd] Fix buildbot failure from ambigous ArrayRef ctorJohan Vikstrom2019-08-011-2/+2
| | | | llvm-svn: 367529
* [clangd] Duplicate lines of semantic highlightings sent removed.Johan Vikstrom2019-08-018-42/+334
| | | | | | | | | | | | | | Summary: Added a class for diffing highlightings and removing duplicate lines. Integrated into the highlighting generation flow. Only works correctly if all tokens are on a single line. Also returns empty lines if the IDE should remove previous highlightings on a line. Reviewers: hokein, sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64475 llvm-svn: 367521
* [clangd] Ignore semicolons, whitespace, and comments in SelectionTree.Sam McCall2019-07-314-73/+124
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Whitespace and comments are a clear bugfix: selecting some comments/space near a statement doesn't mean you're selecting the surrounding block. Semicolons are less obvious, but for similar reasons: these tokens aren't actually claimed by any AST node (usually), so an AST-based model like SelectionTree shouldn't take them into account. Callers may still sometimes care about semis of course: - when the selection is an expr with a non-expr parent, selection of the semicolon indicates intent to select the statement. - when a statement with a trailing semi is selected, we need to know its range to ensure it can be removed. SelectionTree may or may not play a role here, but these are separate questions from its core function of describing which AST nodes were selected. The mechanism here is the TokenBuffer from syntax-trees. We use it in a fairly low-level way (just to get boundaries of raw spelled tokens). The actual mapping of AST nodes to coordinates continues to use the (fairly mature) SourceLocation based logic. TokenBuffer/Syntax trees don't currently offer an alternative to getFileRange(), I think. Reviewers: SureYeaah, kadircet Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov Tags: #clang Differential Revision: https://reviews.llvm.org/D65486 llvm-svn: 367453
* [Clangd] NFC: Added FIXME in ExtractVariable testsShaurya Gupta2019-07-311-2/+7
| | | | llvm-svn: 367406
* [clangd][NFC] Fix typo in commentJan Korous2019-07-301-1/+1
| | | | llvm-svn: 367361
* [clangd][NFC] Typo in commentJan Korous2019-07-301-1/+1
| | | | llvm-svn: 367354
* [clangd] Fix a regression in rL366996.Haojian Wu2019-07-302-7/+16
| | | | | | | | | | | | | | Summary: That patch made the tweak always annotate the whole file by accident. Reviewers: jvikstrom Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65443 llvm-svn: 367313
* [clangd] Ignore diags from builtin filesKadir Cetinkaya2019-07-303-15/+37
| | | | | | | | | | | | | | | | | | Summary: This fixes a case where we show diagnostics on arbitrary lines, in an internal codebase. Open for ideas on unittesting this. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64863 llvm-svn: 367303
* [clangd] Fix NDEBUG build problem introduced by rL366698Bjorn Pettersson2019-07-271-1/+8
| | | | | | | | | | | | Sprinkled some #ifndef NDEBUG in Selection.cpp to make it possible to build with NDEBUG defined. The problem was introduced in rL366698 when using dlog for some debug printouts. The dlog macro expands to DEBUG_WITH_TYPE, which isn't using it's arguments in optimized builds (when NDEBUG is defined). llvm-svn: 367178
* [clangd] Support extraction of binary "subexpressions" like a + [[b + c]].Sam McCall2019-07-265-17/+254
| | | | | | | | | | | | | | | | | | | | | Summary: These aren't formally subexpressions in C++, in this case + is left-associative. However informally +, *, etc are usually (mathematically) associative and users consider these subexpressions. We detect these and in simple cases support extracting the partial expression. As well as builtin associative operators, we assume that overloads of them are associative and support those too. Reviewers: SureYeaah Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65139 llvm-svn: 367121
* [Clangd] Disable ExtractVariable for all types of assignmentsShaurya Gupta2019-07-262-1/+3
| | | | | | | | | | | | Reviewers: sammccall, kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65332 llvm-svn: 367113
* [clangd] Fix background index not triggering on windows due to case mismatch.Sam McCall2019-07-262-37/+61
| | | | | | | | | | | | | | Summary: This isn't a general fix to all paths where we assume case-sensitivity, it's a minimally-invasive fix targeting the llvm 9 branch. Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65320 llvm-svn: 367112
* [clangd] Fix the annotate tweak after rL366893Haojian Wu2019-07-252-17/+34
| | | | | | | | | | | | | | | | | | Summary: After rL366893, the annoate tweak is not activated when we select the whole file (the commonAncestor is TUDecl but we intend to return null). This patch fixes this, and also avoid traversing the TUDecl. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65210 llvm-svn: 366996
* [clangd] Provide help text to users who run `clangd` in a terminal.Sam McCall2019-07-251-0/+5
| | | | | | | | | | | | Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65201 llvm-svn: 366992
* [clangd] Also accept flags from CLANGD_FLAGS variable.Sam McCall2019-07-253-10/+26
| | | | | | | | | | | | | | | | 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
* [clangd] Add categories to help options, and only show clangd options.Sam McCall2019-07-241-190/+232
| | | | | | | | | | | | | | | | | | | Summary: Restricting the categories prevents extra unwanted options from creeping into help (D60663), and removes a bunch of noise from --help-hidden. While here, remove `static` from the opts in favor of an anon namespace, to reduce the noise level. Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65200 llvm-svn: 366900
* [clangd] SelectionTree treats TranslationUnitDecl (mostly) consistently with ↵Sam McCall2019-07-245-35/+48
| | | | | | | | | | | | | | | | | | | | | | | other containers. Summary: Previously TranslationUnitDecl would never be selected. This means root() is never null, and returns a reference. commonAncestor() is in principle never null also, but returning TUDecl here requires tweaks to be careful not to traverse it (this was already possible when selecting multiple top-level decls, and there are associated bugs!) Instead, never allow commonAncestor() to return TUDecl, return null instead. Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65101 llvm-svn: 366893
* [clangd] Fix SelectionTree traversal of qualified typesSam McCall2019-07-243-20/+39
| | | | | | | | | | | | | | | | | | | | | Summary: QualifiedTypeLoc isn't treated like a regular citizen by RecursiveASTVisitor. This meant we weren't intercepting the traversal of its inner TypeLoc. Most of the changes here are about exposing kind() so we can improve the precision of our tests. This should fix the issue raised in D65067. Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65100 llvm-svn: 366882
* [clangd] Reformat use of cl::opt: use unqualified name and don't bin-pack ↵Sam McCall2019-07-241-175/+225
| | | | | | | | | | | | | | attributes. NFC Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65154 llvm-svn: 366880
* [clangd] Bump vscode-clangd v0.0.16Haojian Wu2019-07-242-345/+376
| | | | | | | | CHANGELOG: - detect C++ language based on some well-known file paths - upgrade the lsp-client and lsp-server dependencies llvm-svn: 366877
* [clangd] Update a stale comment, NFC.Haojian Wu2019-07-241-1/+1
| | | | llvm-svn: 366875
* [clangd] Implement "prepareRename"Haojian Wu2019-07-248-15/+98
| | | | | | | | | | | | | | | | | | Summary: - "prepareRename" request is added in LSP v3.12.0 - also update the vscode-client dependency to pick-up the rename bug fix[1] [1]: https://github.com/microsoft/vscode-languageserver-node/issues/447 Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63126 llvm-svn: 366873
* [Clangd] Fixed ExtractVariable for certain types of ExprsShaurya Gupta2019-07-242-57/+148
| | | | | | | | | | | | | | | | | | Summary: - Modified ExtractVariable for extraction of MemberExpr, DeclRefExpr and Assignment Expr - Removed extraction from label statements. - Fixed unittests Reviewers: sammccall, kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64717 llvm-svn: 366869
* [clangd] Log version, cwd, args, and transport on startup. NFCSam McCall2019-07-231-0/+13
| | | | | | | | | | | | Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65146 llvm-svn: 366811
* [clangd] Add dlog()s for SelectionTree, enabling -debug-only=SelectionTree.cppSam McCall2019-07-222-29/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: SelectionTree is a RecursiveASTVisitor which processes getSourceRange() for every node. This is a lot of surface area with the AST, as getSourceRange() is specialized for *many* node types. And the resulting SelectionTree depends on the source ranges of many visited nodes, and the order of traversal. Put together, this means we really need a traversal log to debug when we get an unexpected SelectionTree. I've built this ad-hoc a few times, now it's time to check it in. Example output: ``` D[14:07:44.184] Computing selection for </usr/local/google/home/sammccall/test.cc:1:7, col:8> D[14:07:44.184] push: VarDecl const auto x = 42 D[14:07:44.184] claimRange: </usr/local/google/home/sammccall/test.cc:1:12, col:13> D[14:07:44.184] push: NestedNameSpecifierLoc (empty NestedNameSpecifierLoc) D[14:07:44.184] pop: NestedNameSpecifierLoc (empty NestedNameSpecifierLoc) D[14:07:44.184] push: QualifiedTypeLoc const auto D[14:07:44.184] pop: QualifiedTypeLoc const auto D[14:07:44.184] claimRange: </usr/local/google/home/sammccall/test.cc:1:7, col:11> D[14:07:44.184] hit selection: </usr/local/google/home/sammccall/test.cc:1:7, col:8> D[14:07:44.184] skip: IntegerLiteral 42 D[14:07:44.184] skipped range = </usr/local/google/home/sammccall/test.cc:1:16> D[14:07:44.184] pop: VarDecl const auto x = 42 D[14:07:44.184] claimRange: </usr/local/google/home/sammccall/test.cc:1:1, col:18> D[14:07:44.184] skip: VarDecl int y = 43 D[14:07:44.184] skipped range = </usr/local/google/home/sammccall/test.cc:2:1, col:9> D[14:07:44.184] Built selection tree TranslationUnitDecl VarDecl const auto x = 42 .QualifiedTypeLoc const auto ``` Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65073 llvm-svn: 366698
* [clangd] Set buffer name for main file. NFCISam McCall2019-07-221-5/+6
| | | | llvm-svn: 366675
* [clangd] Log input code of failed highlighting tests. NFCIlya Biryukov2019-07-221-1/+2
| | | | llvm-svn: 366674
* [clangd] Provide a way to publish highlightings in non-racy mannerIlya Biryukov2019-07-194-47/+77
| | | | | | | | | | | | | | | | | | Summary: By exposing a callback that can guard code publishing results of 'onMainAST' callback in the same manner we guard diagnostics. Reviewers: sammccall Reviewed By: sammccall Subscribers: javed.absar, MaskRay, jkorous, arphaman, kadircet, hokein, jvikstrom, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64985 llvm-svn: 366577
* [clangd] Disable background-index on lit-tests by defaultKadir Cetinkaya2019-07-191-1/+5
| | | | | | | | | | | | | | | | Summary: Since background-index can perform disk writes, we don't want to turn it on tests that won't clear it. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64990 llvm-svn: 366575
* [Clangd] Fixed ExtractVariable testShaurya Gupta2019-07-191-9/+15
| | | | llvm-svn: 366568
* [Clangd] Fixed SelectionTree bug for macrosShaurya Gupta2019-07-193-26/+45
| | | | | | | | | | | | | | | | | | Summary: Fixed SelectionTree bug for macros - Fixed SelectionTree claimRange for macros and template instantiations - Fixed SelectionTree unit tests - Changed a breaking test in TweakTests Reviewers: sammccall, kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64329 llvm-svn: 366566
* Revert "Revert r366458, r366467 and r366468"Kadir Cetinkaya2019-07-1915-225/+359
| | | | | | | | | | | | | | | | | | | | | | 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-1915-367/+225
| | | | | | | | | | | 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
OpenPOWER on IntegriCloud