@@ -433,7 +433,7 @@ class reverse_children {
433
433
ArrayRef<Stmt *> children;
434
434
435
435
public:
436
- reverse_children (Stmt *S, ASTContext &Ctx );
436
+ reverse_children (Stmt *S);
437
437
438
438
using iterator = ArrayRef<Stmt *>::reverse_iterator;
439
439
@@ -443,47 +443,28 @@ class reverse_children {
443
443
444
444
} // namespace
445
445
446
- reverse_children::reverse_children (Stmt *S, ASTContext &Ctx) {
447
- switch (S->getStmtClass ()) {
448
- case Stmt::CallExprClass: {
449
- children = cast<CallExpr>(S)->getRawSubExprs ();
446
+ reverse_children::reverse_children (Stmt *S) {
447
+ if (CallExpr *CE = dyn_cast<CallExpr>(S)) {
448
+ children = CE->getRawSubExprs ();
450
449
return ;
451
450
}
452
-
453
- // Note: Fill in this switch with more cases we want to optimize.
454
- case Stmt::InitListExprClass: {
455
- InitListExpr *IE = cast<InitListExpr>(S);
456
- children = llvm::ArrayRef (reinterpret_cast <Stmt **>(IE->getInits ()),
457
- IE->getNumInits ());
458
- return ;
451
+ switch (S->getStmtClass ()) {
452
+ // Note: Fill in this switch with more cases we want to optimize.
453
+ case Stmt::InitListExprClass: {
454
+ InitListExpr *IE = cast<InitListExpr>(S);
455
+ children = llvm::ArrayRef (reinterpret_cast <Stmt **>(IE->getInits ()),
456
+ IE->getNumInits ());
457
+ return ;
458
+ }
459
+ default :
460
+ break ;
459
461
}
460
- case Stmt::AttributedStmtClass: {
461
- auto *AS = cast<AttributedStmt>(S);
462
462
463
- // for an attributed stmt, the "children()" returns only the NullStmt
464
- // (;) but semantically the "children" are supposed to be the
465
- // expressions _within_ i.e. the two square brackets i.e. [[ HERE ]]
466
- // so we add the subexpressions first, _then_ add the "children"
463
+ // Default case for all other statements.
464
+ llvm::append_range (childrenBuf, S->children ());
467
465
468
- for (const auto *Attr : AS->getAttrs ()) {
469
- if (const auto *AssumeAttr = dyn_cast<CXXAssumeAttr>(Attr)) {
470
- Expr *AssumeExpr = AssumeAttr->getAssumption ();
471
- if (!AssumeExpr->HasSideEffects (Ctx)) {
472
- childrenBuf.push_back (AssumeExpr);
473
- }
474
- }
475
- // Visit the actual children AST nodes.
476
- // For CXXAssumeAttrs, this is always a NullStmt.
477
- llvm::append_range (childrenBuf, AS->children ());
478
- children = childrenBuf;
479
- }
480
- return ;
481
- }
482
- default :
483
- // Default case for all other statements.
484
- llvm::append_range (childrenBuf, S->children ());
485
- children = childrenBuf;
486
- }
466
+ // This needs to be done *after* childrenBuf has been populated.
467
+ children = childrenBuf;
487
468
}
488
469
489
470
namespace {
@@ -2450,7 +2431,7 @@ CFGBlock *CFGBuilder::VisitChildren(Stmt *S) {
2450
2431
2451
2432
// Visit the children in their reverse order so that they appear in
2452
2433
// left-to-right (natural) order in the CFG.
2453
- reverse_children RChildren (S, *Context );
2434
+ reverse_children RChildren (S);
2454
2435
for (Stmt *Child : RChildren) {
2455
2436
if (Child)
2456
2437
if (CFGBlock *R = Visit (Child))
@@ -2466,7 +2447,7 @@ CFGBlock *CFGBuilder::VisitInitListExpr(InitListExpr *ILE, AddStmtChoice asc) {
2466
2447
}
2467
2448
CFGBlock *B = Block;
2468
2449
2469
- reverse_children RChildren (ILE, *Context );
2450
+ reverse_children RChildren (ILE);
2470
2451
for (Stmt *Child : RChildren) {
2471
2452
if (!Child)
2472
2453
continue ;
@@ -2501,14 +2482,6 @@ static bool isFallthroughStatement(const AttributedStmt *A) {
2501
2482
return isFallthrough;
2502
2483
}
2503
2484
2504
- static bool isCXXAssumeAttr (const AttributedStmt *A) {
2505
- bool hasAssumeAttr = hasSpecificAttr<CXXAssumeAttr>(A->getAttrs ());
2506
-
2507
- assert ((!hasAssumeAttr || isa<NullStmt>(A->getSubStmt ())) &&
2508
- " expected [[assume]] not to have children" );
2509
- return hasAssumeAttr;
2510
- }
2511
-
2512
2485
CFGBlock *CFGBuilder::VisitAttributedStmt (AttributedStmt *A,
2513
2486
AddStmtChoice asc) {
2514
2487
// AttributedStmts for [[likely]] can have arbitrary statements as children,
@@ -2524,11 +2497,6 @@ CFGBlock *CFGBuilder::VisitAttributedStmt(AttributedStmt *A,
2524
2497
appendStmt (Block, A);
2525
2498
}
2526
2499
2527
- if (isCXXAssumeAttr (A) && asc.alwaysAdd (*this , A)) {
2528
- autoCreateBlock ();
2529
- appendStmt (Block, A);
2530
- }
2531
-
2532
2500
return VisitChildren (A);
2533
2501
}
2534
2502
0 commit comments