Skip to content

Commit f4307e9

Browse files
committed
NFC Simplify AttributedStmt handling in clang CFG
1 parent 7f1e341 commit f4307e9

File tree

1 file changed

+7
-25
lines changed

1 file changed

+7
-25
lines changed

clang/lib/Analysis/CFG.cpp

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -457,34 +457,16 @@ reverse_children::reverse_children(Stmt *S) {
457457
return;
458458
}
459459
case Stmt::AttributedStmtClass: {
460-
AttributedStmt *attrStmt = cast<AttributedStmt>(S);
461-
assert(attrStmt);
460+
auto Attrs = cast<AttributedStmt>(S)->getAttrs();
462461

463-
{
464-
// for an attributed stmt, the "children()" returns only the NullStmt
465-
// (;) but semantically the "children" are supposed to be the
466-
// expressions _within_ i.e. the two square brackets i.e. [[ HERE ]]
467-
// so we add the subexpressions first, _then_ add the "children"
468-
469-
for (const Attr *attr : attrStmt->getAttrs()) {
470-
471-
// i.e. one `assume()`
472-
CXXAssumeAttr const *assumeAttr = llvm::dyn_cast<CXXAssumeAttr>(attr);
473-
if (!assumeAttr) {
474-
continue;
475-
}
476-
// Only handles [[ assume(<assumption>) ]] right now
477-
Expr *assumption = assumeAttr->getAssumption();
478-
childrenBuf.push_back(assumption);
479-
}
480-
481-
// children() for an AttributedStmt is NullStmt(;)
482-
llvm::append_range(childrenBuf, attrStmt->children());
483-
484-
// This needs to be done *after* childrenBuf has been populated.
462+
// We only handle `[[assume(...)]]` attributes for now.
463+
if (const auto *A = getSpecificAttr<CXXAssumeAttr>(Attrs)) {
464+
childrenBuf.push_back(A->getAssumption());
465+
llvm::append_range(childrenBuf, S->children());
485466
children = childrenBuf;
467+
return;
486468
}
487-
return;
469+
break;
488470
}
489471
default:
490472
break;

0 commit comments

Comments
 (0)