@@ -556,10 +556,6 @@ class CFGBuilder {
556556
557557private:
558558 // Visitors to walk an AST and construct the CFG.
559- CFGBlock *VisitCXXDefaultArgExpr (CXXDefaultArgExpr *Default,
560- AddStmtChoice asc);
561- CFGBlock *VisitCXXDefaultInitExpr (CXXDefaultInitExpr *Default,
562- AddStmtChoice asc);
563559 CFGBlock *VisitInitListExpr (InitListExpr *ILE, AddStmtChoice asc);
564560 CFGBlock *VisitAddrLabelExpr (AddrLabelExpr *A, AddStmtChoice asc);
565561 CFGBlock *VisitAttributedStmt (AttributedStmt *A, AddStmtChoice asc);
@@ -2265,10 +2261,16 @@ CFGBlock *CFGBuilder::Visit(Stmt * S, AddStmtChoice asc,
22652261 asc, ExternallyDestructed);
22662262
22672263 case Stmt::CXXDefaultArgExprClass:
2268- return VisitCXXDefaultArgExpr (cast<CXXDefaultArgExpr>(S), asc);
2269-
22702264 case Stmt::CXXDefaultInitExprClass:
2271- return VisitCXXDefaultInitExpr (cast<CXXDefaultInitExpr>(S), asc);
2265+ // FIXME: The expression inside a CXXDefaultArgExpr is owned by the
2266+ // called function's declaration, not by the caller. If we simply add
2267+ // this expression to the CFG, we could end up with the same Expr
2268+ // appearing multiple times (PR13385).
2269+ //
2270+ // It's likewise possible for multiple CXXDefaultInitExprs for the same
2271+ // expression to be used in the same function (through aggregate
2272+ // initialization).
2273+ return VisitStmt (S, asc);
22722274
22732275 case Stmt::CXXBindTemporaryExprClass:
22742276 return VisitCXXBindTemporaryExpr (cast<CXXBindTemporaryExpr>(S), asc);
@@ -2438,40 +2440,6 @@ CFGBlock *CFGBuilder::VisitChildren(Stmt *S) {
24382440 return B;
24392441}
24402442
2441- CFGBlock *CFGBuilder::VisitCXXDefaultArgExpr (CXXDefaultArgExpr *Arg,
2442- AddStmtChoice asc) {
2443- if (Arg->hasRewrittenInit ()) {
2444- if (asc.alwaysAdd (*this , Arg)) {
2445- autoCreateBlock ();
2446- appendStmt (Block, Arg);
2447- }
2448- return VisitStmt (Arg->getExpr (), asc);
2449- }
2450-
2451- // We can't add the default argument if it's not rewritten because the
2452- // expression inside a CXXDefaultArgExpr is owned by the called function's
2453- // declaration, not by the caller, we could end up with the same expression
2454- // appearing multiple times.
2455- return VisitStmt (Arg, asc);
2456- }
2457-
2458- CFGBlock *CFGBuilder::VisitCXXDefaultInitExpr (CXXDefaultInitExpr *Init,
2459- AddStmtChoice asc) {
2460- if (Init->hasRewrittenInit ()) {
2461- if (asc.alwaysAdd (*this , Init)) {
2462- autoCreateBlock ();
2463- appendStmt (Block, Init);
2464- }
2465- return VisitStmt (Init->getExpr (), asc);
2466- }
2467-
2468- // We can't add the default initializer if it's not rewritten because multiple
2469- // CXXDefaultInitExprs for the same sub-expression to be used in the same
2470- // function (through aggregate initialization). we could end up with the same
2471- // expression appearing multiple times.
2472- return VisitStmt (Init, asc);
2473- }
2474-
24752443CFGBlock *CFGBuilder::VisitInitListExpr (InitListExpr *ILE, AddStmtChoice asc) {
24762444 if (asc.alwaysAdd (*this , ILE)) {
24772445 autoCreateBlock ();
0 commit comments