@@ -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);
@@ -2267,10 +2263,16 @@ CFGBlock *CFGBuilder::Visit(Stmt * S, AddStmtChoice asc,
22672263 asc, ExternallyDestructed);
22682264
22692265 case Stmt::CXXDefaultArgExprClass:
2270- return VisitCXXDefaultArgExpr (cast<CXXDefaultArgExpr>(S), asc);
2271-
22722266 case Stmt::CXXDefaultInitExprClass:
2273- return VisitCXXDefaultInitExpr (cast<CXXDefaultInitExpr>(S), asc);
2267+ // FIXME: The expression inside a CXXDefaultArgExpr is owned by the
2268+ // called function's declaration, not by the caller. If we simply add
2269+ // this expression to the CFG, we could end up with the same Expr
2270+ // appearing multiple times (PR13385).
2271+ //
2272+ // It's likewise possible for multiple CXXDefaultInitExprs for the same
2273+ // expression to be used in the same function (through aggregate
2274+ // initialization).
2275+ return VisitStmt (S, asc);
22742276
22752277 case Stmt::CXXBindTemporaryExprClass:
22762278 return VisitCXXBindTemporaryExpr (cast<CXXBindTemporaryExpr>(S), asc);
@@ -2440,44 +2442,6 @@ CFGBlock *CFGBuilder::VisitChildren(Stmt *S) {
24402442 return B;
24412443}
24422444
2443- CFGBlock *CFGBuilder::VisitCXXDefaultArgExpr (CXXDefaultArgExpr *Arg,
2444- AddStmtChoice asc) {
2445- if (Arg->hasRewrittenInit ()) {
2446- if (asc.alwaysAdd (*this , Arg)) {
2447- autoCreateBlock ();
2448- appendStmt (Block, Arg);
2449- }
2450- return VisitStmt (Arg->getExpr ()->IgnoreParens (), asc);
2451- }
2452-
2453- // We can't add the default argument if it's not rewritten because the
2454- // expression inside a CXXDefaultArgExpr is owned by the called function's
2455- // declaration, not by the caller, we could end up with the same expression
2456- // appearing multiple times.
2457- return VisitStmt (Arg, asc);
2458- }
2459-
2460- CFGBlock *CFGBuilder::VisitCXXDefaultInitExpr (CXXDefaultInitExpr *Init,
2461- AddStmtChoice asc) {
2462- if (Init->hasRewrittenInit ()) {
2463- if (asc.alwaysAdd (*this , Init)) {
2464- autoCreateBlock ();
2465- appendStmt (Block, Init);
2466- }
2467-
2468- // Unlike CXXDefaultArgExpr::getExpr stripped off the top level FullExpr and
2469- // ConstantExpr, CXXDefaultInitExpr::getExpr does not do this, so we don't
2470- // need to ignore ParenExprs, because the top level will not be a ParenExpr.
2471- return VisitStmt (Init->getExpr (), asc);
2472- }
2473-
2474- // We can't add the default initializer if it's not rewritten because multiple
2475- // CXXDefaultInitExprs for the same sub-expression to be used in the same
2476- // function (through aggregate initialization). we could end up with the same
2477- // expression appearing multiple times.
2478- return VisitStmt (Init, asc);
2479- }
2480-
24812445CFGBlock *CFGBuilder::VisitInitListExpr (InitListExpr *ILE, AddStmtChoice asc) {
24822446 if (asc.alwaysAdd (*this , ILE)) {
24832447 autoCreateBlock ();
0 commit comments