mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-22 03:03:43 +00:00
[clangd] Fix a selection tree crash for unmatched-bracket code.
Fixes https://github.com/clangd/clangd/issues/999 Differential Revision: https://reviews.llvm.org/D118322
This commit is contained in:
parent
39057240f5
commit
4cb1686bfe
@ -306,6 +306,14 @@ public:
|
||||
return SelectionTree::Unselected;
|
||||
}
|
||||
|
||||
// The eof token is used as a sentinel.
|
||||
// In general, source range from an AST node should not claim the eof token,
|
||||
// but it could occur for unmatched-bracket cases.
|
||||
// FIXME: fix it in TokenBuffer, expandedTokens(SourceRange) should not
|
||||
// return the eof token.
|
||||
if (ExpandedTokens.back().kind() == tok::eof)
|
||||
ExpandedTokens = ExpandedTokens.drop_back();
|
||||
|
||||
SelectionTree::Selection Result = NoTokens;
|
||||
while (!ExpandedTokens.empty()) {
|
||||
// Take consecutive tokens from the same context together for efficiency.
|
||||
|
@ -523,6 +523,10 @@ TEST(SelectionTest, CommonAncestor) {
|
||||
auto l = [^[[foo = bar]]] { };
|
||||
})cpp",
|
||||
"VarDecl"},
|
||||
{R"cpp(
|
||||
/*error-ok*/
|
||||
void func() [[{^]])cpp",
|
||||
"CompoundStmt"},
|
||||
};
|
||||
|
||||
for (const Case &C : Cases) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user