@@ -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);
@@ -2258,10 +2254,16 @@ CFGBlock *CFGBuilder::Visit(Stmt * S, AddStmtChoice asc,
22582254 asc, ExternallyDestructed);
22592255
22602256 case Stmt::CXXDefaultArgExprClass:
2261- return VisitCXXDefaultArgExpr (cast<CXXDefaultArgExpr>(S), asc);
2262-
22632257 case Stmt::CXXDefaultInitExprClass:
2264- return VisitCXXDefaultInitExpr (cast<CXXDefaultInitExpr>(S), asc);
2258+ // FIXME: The expression inside a CXXDefaultArgExpr is owned by the
2259+ // called function's declaration, not by the caller. If we simply add
2260+ // this expression to the CFG, we could end up with the same Expr
2261+ // appearing multiple times (PR13385).
2262+ //
2263+ // It's likewise possible for multiple CXXDefaultInitExprs for the same
2264+ // expression to be used in the same function (through aggregate
2265+ // initialization).
2266+ return VisitStmt (S, asc);
22652267
22662268 case Stmt::CXXBindTemporaryExprClass:
22672269 return VisitCXXBindTemporaryExpr (cast<CXXBindTemporaryExpr>(S), asc);
@@ -2431,40 +2433,6 @@ CFGBlock *CFGBuilder::VisitChildren(Stmt *S) {
24312433 return B;
24322434}
24332435
2434- CFGBlock *CFGBuilder::VisitCXXDefaultArgExpr (CXXDefaultArgExpr *Arg,
2435- AddStmtChoice asc) {
2436- if (Arg->hasRewrittenInit ()) {
2437- if (asc.alwaysAdd (*this , Arg)) {
2438- autoCreateBlock ();
2439- appendStmt (Block, Arg);
2440- }
2441- return VisitStmt (Arg->getExpr (), asc);
2442- }
2443-
2444- // We can't add the default argument if it's not rewritten because the
2445- // expression inside a CXXDefaultArgExpr is owned by the called function's
2446- // declaration, not by the caller, we could end up with the same expression
2447- // appearing multiple times.
2448- return VisitStmt (Arg, asc);
2449- }
2450-
2451- CFGBlock *CFGBuilder::VisitCXXDefaultInitExpr (CXXDefaultInitExpr *Init,
2452- AddStmtChoice asc) {
2453- if (Init->hasRewrittenInit ()) {
2454- if (asc.alwaysAdd (*this , Init)) {
2455- autoCreateBlock ();
2456- appendStmt (Block, Init);
2457- }
2458- return VisitStmt (Init->getExpr (), asc);
2459- }
2460-
2461- // We can't add the default initializer if it's not rewritten because multiple
2462- // CXXDefaultInitExprs for the same sub-expression to be used in the same
2463- // function (through aggregate initialization). we could end up with the same
2464- // expression appearing multiple times.
2465- return VisitStmt (Init, asc);
2466- }
2467-
24682436CFGBlock *CFGBuilder::VisitInitListExpr (InitListExpr *ILE, AddStmtChoice asc) {
24692437 if (asc.alwaysAdd (*this , ILE)) {
24702438 autoCreateBlock ();
0 commit comments