forked from OSchip/llvm-project
[clangd] Fix a crash in Selection
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
This commit is contained in:
parent
656b6698be
commit
fc83aea6a9
|
@ -198,11 +198,10 @@ private:
|
|||
auto E = SM.getDecomposedLoc(R.getEnd());
|
||||
if (B.first != SelFile || E.first != SelFile)
|
||||
continue;
|
||||
assert(R.isTokenRange());
|
||||
// Try to cover up to the next token, spaces between children don't count.
|
||||
if (auto Tok = Lexer::findNextToken(R.getEnd(), SM, LangOpts))
|
||||
E.second = SM.getFileOffset(Tok->getLocation());
|
||||
else
|
||||
else if (R.isTokenRange())
|
||||
E.second += Lexer::MeasureTokenLength(R.getEnd(), SM, LangOpts);
|
||||
ChildRanges.push_back({B.second, E.second});
|
||||
}
|
||||
|
|
|
@ -232,6 +232,11 @@ TEST(SelectionTest, Selected) {
|
|||
}]]]]
|
||||
}
|
||||
)cpp",
|
||||
R"cpp(
|
||||
template <class T>
|
||||
struct unique_ptr {};
|
||||
void foo(^$C[[unique_ptr<unique_ptr<$C[[int]]>>]]^ a) {}
|
||||
)cpp",
|
||||
};
|
||||
for (const char *C : Cases) {
|
||||
Annotations Test(C);
|
||||
|
|
Loading…
Reference in New Issue