================
@@ -130,7 +135,18 @@ const Node *getParentOfRootStmts(const Node *CommonAnc) {
const Node *Parent = nullptr;
switch (CommonAnc->Selected) {
case SelectionTree::Selection::Unselected:
- // Typically a block, with the { and } unselected, could also be ForStmt
etc
+ // Typically a block, with the { and } unselected, could also be ForStmt
+ // etc. However, CommonAnc may instead be a single statement that is
+ // itself Unselected only because all of its own tokens are claimed by
+ // its children (see isUnselectedRootStmtCandidate); in that case it's a
+ // root statement in its own right, and we need its actual parent, same
+ // as in the Complete case below.
+ if (isUnselectedRootStmtCandidate(CommonAnc)) {
+ Parent = CommonAnc->Parent;
+ if (Parent->ASTNode.get<DeclStmt>())
----------------
ckandeler wrote:
Done.
https://github.com/llvm/llvm-project/pull/219945
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits