summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/Selection.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [clangd] Fix early selection for non-vardecl declaratorsKadir Cetinkaya2020-06-101-5/+16
| | | | | | | | | | | | | | | | | | | | | | | Summary: Selection tree was performing an early claim only for VarDecls, but there are other cases where we can have declarators, e.g. FieldDecls. This patch extends the early claim logic to all types of declarators. Fixes https://github.com/clangd/clangd/issues/292 Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D75106 (cherry picked from commit e6b8181895b96740dbe54aca036aa237e0a8363d) Modified the cherry-picked test as diagnostics differ on the branch. Fixes https://github.com/clangd/clangd/issues/421
* [clangd] Include expression in DecltypeTypeLoc sourcerange while building ↵Kadir Cetinkaya2020-01-131-0/+13
| | | | | | | | | | | | | | | | | | | | | | | SelectionTree Summary: Currently AST only contains the location for `decltype` keyword, therefore we were skipping expressions inside decltype while building selection tree. This patch extends source range in such cases to contain the expression as well. A proper fix would require changes to Sema and DecltypeTypeLoc to contain these location information. Fixes https://github.com/clangd/clangd/issues/250. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72594
* Revert "[clangd] Reapply b60896fad926 Fall back to selecting ↵Sam McCall2019-12-161-49/+27
| | | | | | | token-before-cursor if token-after-cursor fails." This reverts commit a0ff8cd631add513423fc2d8afa49e9650d01fe3. Buildbot failures I can't chase further tonight.
* [clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor if ↵Sam McCall2019-12-161-27/+49
| | | | | | token-after-cursor fails. This reverts commit 8f876d5105507f874c0fb86bc779c9853eab3fe2.
* Revert "[clangd] Reapply b60896fad926 Fall back to selecting ↵Sam McCall2019-12-161-49/+27
| | | | | | token-before-cursor if token-after-cursor fails." This reverts commit 2500a8d5d8813a3e31fc9ba8dd45e211439a1e3d.
* [clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor if ↵Sam McCall2019-12-161-27/+49
| | | | | | | token-after-cursor fails. This reverts commit f0604e73a4daa35a10eb17a998657d6c4bd0e971 The issue with movability of Tweak::Selection was addressed in 7dc388bd9596bbf42633f8a8e450224e39740b60
* Revert "[clangd] Fall back to selecting token-before-cursor if ↵Nico Weber2019-12-141-49/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | token-after-cursor fails." This reverts commit b60896fad926754f715acc5d771555aaaa577e0f. Breaks building with gcc: /usr/include/c++/7/bits/stl_construct.h:75:7: error: use of deleted function ‘clang::clangd::Tweak::Selection::Selection(const clang::clangd::Tweak::Selection&)’ { ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); } ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/ClangdServer.h:28:0, from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/ClangdServer.cpp:9: /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/refactor/Tweak.h:49:10: note: ‘clang::clangd::Tweak::Selection::Selection(const clang::clangd::Tweak::Selection&)’ is implicitly deleted because the default definition would be ill-formed: struct Selection { ^~~~~~~~~ /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/refactor/Tweak.h:49:10: error: use of deleted function ‘clang::clangd::SelectionTree::SelectionTree(const clang::clangd::SelectionTree&)’ In file included from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/refactor/Tweak.h:25:0, from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/ClangdServer.h:28, from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/ClangdServer.cpp:9: /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/Selection.h:96:3: note: declared here SelectionTree(const SelectionTree &) = delete; ^~~~~~~~~~~~~ e.g. here: http://lab.llvm.org:8011/builders/clang-cmake-armv7-selfhost-neon/builds/2714 http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/41866
* [clangd] Fall back to selecting token-before-cursor if token-after-cursor fails.Sam McCall2019-12-131-27/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The problem: LSP specifies that Positions are between characters. Therefore when a position (or an empty range) is used to target elements of the source code, there is an ambiguity - should we look left or right of the cursor? Until now, SelectionTree resolved this to the right except in trivial cases (where there's whitespace, semicolon, or eof on the right). This meant that it's unable to e.g. out-line `int foo^()` today. Complicating this, LSP notwithstanding the cursor is *on* a character in many editors (mostly terminal-based). In these cases there's no ambiguity - we must "look right" - but there's also no way to tell in LSP. (Several features currently resolve this by using getBeginningOfIdentifier, which tries to rewind and supports end-of-identifier. But this relies on raw lexing and is limited and buggy). Precedent: well - most other languages aren't so full of densely packed symbols that we might want to target. Bias-towards-identifier works well enough. MS C++ for vscode seems to mostly use bias-toward-identifier too. The problem with this solution is it doesn't provide any way to target some things such as the constructor call in Foo^(bar()); Presented solution: When an ambiguous selection is found, we generate *both* possible selection trees. We try to run the feature on the rightward tree first, and then on the leftward tree if it fails. This is basically do-what-I-mean, the main downside is the need to do this on a feature-by-feature basis (because each feature knows what "fail" means). The most complicated instance of this is Tweaks, where the preferred selection may vary tweak-by-tweak. Wrinkles: While production behavior is pretty consistent, this introduces some inconsistency in testing, depending whether the interface we're testing is inside or outside the "retry" wrapper. In particular, for many features like Hover, the unit tests will show production behavior, while for Tweaks the harness would have to run the loop itself if we want this. Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71345
* [clangd] Fix comparator const after c9c714c7054d555398c767cb39d7d97600b3d9d1Sam McCall2019-12-031-1/+1
|
* Reland [clangd] Rethink how SelectionTree deals with macros and #includes.Sam McCall2019-12-031-135/+285
| | | | | | This reverts commit 905b002c139f039a32ab9bf1fad63d745d12423f. Avoid tricky (and invalid) comparator for std::set.
* Revert "[clangd] Rethink how SelectionTree deals with macros and #includes."Sam McCall2019-11-291-279/+135
| | | | | | | | This reverts commit 19daa21f841ad45290c923689ee3d25198651a4c. It causes a bunch of failures on a bot that I've been unable to reproduce so far: http://45.33.8.238/mac/3308/step_7.txt
* [clangd] Rethink how SelectionTree deals with macros and #includes.Sam McCall2019-11-291-135/+279
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The exclusive-claim model is successful at resolving conflicts over tokens between parent/child or siblings. However claims at the spelled-token level do the wrong thing for macro expansions, where siblings can be equally associated with the macro invocation. Moreover, any model that only uses the endpoints in a range can fail when a macro invocation occurs inside the node. To address this, we use the existing TokenBuffer in more depth. Claims are expressed in terms of expanded tokens, so there is no need to worry about macros, includes etc. Once we know which expanded tokens were claimed, they are mapped onto spelled tokens for hit-testing. This mapping is fairly flexible, currently the handling of macros is pretty simple (map macro args onto spellings, other macro expansions onto the macro name token). This mapping is in principle token-by-token for correctness (though there's some batching for performance). The aggregation of the selection enum is now more principled as we need to be able to aggregate several hit-test results together. For simplicity i removed the ability to determine selectedness of TUDecl. (That was originally implemented in 90a5bf92ff97b1, but doesn't seem to be very important or worth the complexity any longer). The expandedTokens(SourceLocation) helper could be added locally, but seems to make sense on TokenBuffer. Fixes https://github.com/clangd/clangd/issues/202 Fixes https://github.com/clangd/clangd/issues/126 Reviewers: hokein Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits, ilya-biryukov Tags: #clang Differential Revision: https://reviews.llvm.org/D70512
* [clangd] Prefer the left character if the character on the right of the ↵Haojian Wu2019-11-281-2/+3
| | | | | | | | | | | | | | cursor is semicolon. Summary: This would make go-to-def works on the cases like int A = abc^; Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70807
* [clangd] Treat UserDefinedLiteral as a leaf in SelectionTree, sidestepping ↵Sam McCall2019-11-201-0/+14
| | | | | | | | | | | | | | tokenization issues Summary: Fixes https://github.com/clangd/clangd/issues/203 Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70446
* [clangd] Fix SelectionTree behavior on constructor init-lists.Sam McCall2019-11-151-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Summary: For the constructor Foo() : classmember(arg) {} The AST looks like: - CXXCtorInitializer classmember(arg) - CXXConstructExpr classmember(arg) - DeclRefExpr: arg We want the 'classmember' to be associated with the CXXCtorInitializer, not the CXXConstructExpr. (CXXConstructExpr is known to have bad ranges). So just early-claim it. Thanks @hokein for tracking down/reducing the bug. Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits, hokein Tags: #clang Differential Revision: https://reviews.llvm.org/D70312
* [clangd] Ignore more implicit nodes in computing selection.Sam McCall2019-11-141-6/+29
| | | | | | | | | | | | | | | | | | | | | | Summary: The DeclRefExpr for the callee of overloaded `operator()` and `operator[]` are assigned the range of the paren/bracket lists in the AST. These are better thought of as implicit (at least `()` - `[] is murkier). But there's no bit on Expr for implicit, so just ignore them on our side. While here, deal with the case where an implicit stmt (e.g. implicit-this) is wrapped in an implicit cast. Previously we ignored the statement but not the cast, and so the cast ended up being selected. Fixes https://github.com/clangd/clangd/issues/195 Reviewers: kadircet, lh123 Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70194
* [clangd] SelectionTree should mark a node as fully-selected if the only ↵Sam McCall2019-10-021-17/+23
| | | | | | | | | | | | | | | | | | | claimed tokens were early-claimed. Summary: Previously they would be marked as partially-selected based on the early claim, and never updated as no more tokens were claimed. This affects simple VarDecls like "int x". Reviewers: SureYeaah Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66872 llvm-svn: 373442
* [clangd] Fix SelectionTree behavior on implicit 'this'Sam McCall2019-09-041-0/+6
| | | | llvm-svn: 370884
* [clangd] Move getBeginningOfIdentifier from ClangdUnit to SourceCode. Drop ↵Sam McCall2019-09-031-1/+1
| | | | | | dependencies on ClangdUnit from some headers. NFC llvm-svn: 370768
* [clangd] Fix SelectionTree to allow selection range expression in foreach loops.Sam McCall2019-08-281-0/+10
| | | | | | | | | | | | Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66869 llvm-svn: 370191
* [clangd] Disallow extraction of expression-statements.Sam McCall2019-08-091-0/+6
| | | | | | | | | | | | | | | | | | | | | Summary: I split out the "extract parent instead of this" logic from the "this isn't worth extracting" logic (now in eligibleForExtraction()), because I found it hard to reason about. While here, handle overloaded as well as builtin assignment operators. Also this uncovered a bug in getCallExpr() which I fixed. Reviewers: SureYeaah Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65337 llvm-svn: 368500
* [clangd] Ignore semicolons, whitespace, and comments in SelectionTree.Sam McCall2019-07-311-65/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] 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-261-0/+7
| | | | | | | | | | | | | | | | | | | | | 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] SelectionTree treats TranslationUnitDecl (mostly) consistently with ↵Sam McCall2019-07-241-5/+12
| | | | | | | | | | | | | | | | | | | | | | | 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-241-8/+23
| | | | | | | | | | | | | | | | | | | | | 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] Add dlog()s for SelectionTree, enabling -debug-only=SelectionTree.cppSam McCall2019-07-221-28/+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] Fixed SelectionTree bug for macrosShaurya Gupta2019-07-191-11/+11
| | | | | | | | | | | | | | | | | | 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
* [clangd] Implementation of auto type expansion.Sam McCall2019-07-111-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Fix an assertion crash in "ExtractVariable" tweakHaojian Wu2019-07-111-7/+4
| | | | | | | | | | | | | | | | 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] Add a missing "return nullptr;" to the SelectionTree::commonAncestor.Haojian Wu2019-07-111-0/+1
| | | | | | This would fix some mysterious crashes on codeAction in clangd. llvm-svn: 365751
* [clangd] Address limitations in SelectionTree:Sam McCall2019-06-271-49/+105
| | | | | | | | | | | | | | | | | | 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
* [clangd] Fix NestedNameSpecifierLoc in SelectionTreeSam McCall2019-06-251-1/+1
| | | | | | | | | | | | Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63708 llvm-svn: 364284
* [clangd] Improve SelectionTree string representationSam McCall2019-06-241-1/+12
| | | | llvm-svn: 364180
* [clangd] Add hidden tweaks to dump AST/selection.Sam McCall2019-06-181-0/+3
| | | | | | | | | | | | | | | | | | | | | | | Summary: This introduces a few new concepts: - tweaks have an Intent (they don't all advertise as refactorings) - tweaks may produce messages (for ShowMessage notification). Generalized Replacements -> Effect. - tweaks (and other features) may be hidden (clangd -hidden-features flag). We may choose to promote these one day. I'm not sure they're worth their own feature flags though. Verified it in vim-clangd (not yet open source), curious if the UI is ok in VSCode. Reviewers: ilya-biryukov Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62538 llvm-svn: 363680
* [clangd] Fix a crash in SelectionIlya Biryukov2019-02-201-2/+1
| | | | | | | | | | | | | | | | | | | Summary: The assertion checking that a range of a node is a token range does not hold in case of "split" tokens, e.g. between two closing template argument lists (`vector<vector<int>>`). Reviewers: kadircet, sammccall Reviewed By: kadircet Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58447 llvm-svn: 354507
* [clangd] Fix an assertion failure in Selection.Haojian Wu2019-02-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The assertion is triggered when the Decl is null. Details for the assertion: F0207 09:55:09.069385 47308 logging.cc:84] assert.h assertion failed at llvm/include/llvm/Support/Casting.h:105 in static bool llvm::isa_impl_cl<clang::TranslationUnitDecl, const clang:: Decl *>::doit(const From *) [To = clang::TranslationUnitDecl, From = const clang::Decl *]: Val && "isa<> used on a null pointer" 15 *** Check failure stack trace: *** 19 @ 0x55615c1f7e06 __assert_fail 20 @ 0x55615a6297d8 clang::clangd::(anonymous namespace)::SelectionVisitor::TraverseDecl() 21 @ 0x55615a62f48d clang::RecursiveASTVisitor<>::TraverseTemplateTemplateParmDecl() 22 @ 0x55615a62b264 clang::RecursiveASTVisitor<>::TraverseDecl() 23 @ 0x55615a62979c clang::clangd::(anonymous namespace)::SelectionVisitor::TraverseDecl() 24 @ 0x55615a63060c clang::RecursiveASTVisitor<>::TraverseClassTemplatePartialSpecializationDecl() 25 @ 0x55615a62ae45 clang::RecursiveASTVisitor<>::TraverseDecl() Reviewers: sammccall Subscribers: javed.absar, kristof.beyls, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57879 llvm-svn: 353421
* [clangd] Some minor fixes.Haojian Wu2019-02-061-1/+1
| | | | | | | | | | | | Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57755 llvm-svn: 353283
* [clangd] Expose SelectionTree to code tweaks, and use it for swap if branches.Sam McCall2019-02-011-50/+0
| | | | | | | | | | | | | | | | | Summary: This reduces the per-check implementation burden and redundant work. It also makes checks range-aware by default (treating the commonAncestor as if it were a point selection should be good baseline behavior). Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet Tags: #clang Differential Revision: https://reviews.llvm.org/D57570 llvm-svn: 352876
* [clangd] Lib to compute and represent selection under cursor.Sam McCall2019-02-011-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The primary problem this solves is to expose the codeAction selection to AST-based refactorings in a way that makes it easy and efficient for them to bind to the right parts of the AST. It should also allow us to make XRefs based features (textDocument/definition) more robust, more easily implement textDocument/typeDefinition etc. As an example, template parameter references can be identified without special handling. There should be slight speedup too: we can prune most of the AST traversal in most cases. Elephant in the room: this is similar-but-different to Tooling/Refactoring/ASTSelection. That captures a smaller set of AST nodes, has a slightly different way of representing selections, and generally has mare features and does more work. The overall shape is pretty similar, and yet I can't quite get to behave as I expect. Reviewers: ilya-biryukov, kadircet Subscribers: mgorny, ioeric, MaskRay, jkorous, mgrang, arphaman Tags: #clang Differential Revision: https://reviews.llvm.org/D57562 llvm-svn: 352875
* [clangd] Lib to compute and represent selection under cursor.Sam McCall2019-02-011-0/+301
Summary: The primary problem this solves is to expose the codeAction selection to AST-based refactorings in a way that makes it easy and efficient for them to bind to the right parts of the AST. It should also allow us to make XRefs based features (textDocument/definition) more robust, more easily implement textDocument/typeDefinition etc. As an example, template parameter references can be identified without special handling. There should be slight speedup too: we can prune most of the AST traversal in most cases. Elephant in the room: this is similar-but-different to Tooling/Refactoring/ASTSelection. That captures a smaller set of AST nodes, has a slightly different way of representing selections, and generally has mare features and does more work. The overall shape is pretty similar, and yet I can't quite get to behave as I expect. Reviewers: ilya-biryukov, kadircet Subscribers: mgorny, ioeric, MaskRay, jkorous, mgrang, arphaman Tags: #clang Differential Revision: https://reviews.llvm.org/D57562 llvm-svn: 352874
OpenPOWER on IntegriCloud