mirror of
https://github.com/intel/llvm.git
synced 2026-01-27 06:06:34 +08:00
Append CXXDefaultInitExpr's wrapped expression to the CFG when visiting a constructor initializer
Summary: This patch is part of http://llvm-reviews.chandlerc.com/D2181. In-class initializers are appended to the CFG when CFGBuilder::addInitializer is called. Reviewers: jordan_rose, rsmith Reviewed By: jordan_rose Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D2370 llvm-svn: 238913
This commit is contained in:
@@ -738,6 +738,7 @@ public:
|
||||
bool AddTemporaryDtors;
|
||||
bool AddStaticInitBranches;
|
||||
bool AddCXXNewAllocator;
|
||||
bool AddCXXDefaultInitExprInCtors;
|
||||
|
||||
bool alwaysAdd(const Stmt *stmt) const {
|
||||
return alwaysAddMask[stmt->getStmtClass()];
|
||||
@@ -758,7 +759,7 @@ public:
|
||||
PruneTriviallyFalseEdges(true), AddEHEdges(false),
|
||||
AddInitializers(false), AddImplicitDtors(false),
|
||||
AddTemporaryDtors(false), AddStaticInitBranches(false),
|
||||
AddCXXNewAllocator(false) {}
|
||||
AddCXXNewAllocator(false), AddCXXDefaultInitExprInCtors(false) {}
|
||||
};
|
||||
|
||||
/// \brief Provides a custom implementation of the iterator class to have the
|
||||
|
||||
@@ -1095,6 +1095,19 @@ CFGBlock *CFGBuilder::addInitializer(CXXCtorInitializer *I) {
|
||||
// generating destructors for the second time.
|
||||
return Visit(cast<ExprWithCleanups>(Init)->getSubExpr());
|
||||
}
|
||||
if (BuildOpts.AddCXXDefaultInitExprInCtors) {
|
||||
if (CXXDefaultInitExpr *Default = dyn_cast<CXXDefaultInitExpr>(Init)) {
|
||||
// In general, appending the expression wrapped by a CXXDefaultInitExpr
|
||||
// may cause the same Expr to appear more than once in the CFG. Doing it
|
||||
// here is safe because there's only one initializer per field.
|
||||
autoCreateBlock();
|
||||
appendStmt(Block, Default);
|
||||
if (Stmt *Child = Default->getExpr())
|
||||
if (CFGBlock *R = Visit(Child))
|
||||
Block = R;
|
||||
return Block;
|
||||
}
|
||||
}
|
||||
return Visit(Init);
|
||||
}
|
||||
|
||||
|
||||
@@ -1886,6 +1886,7 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P,
|
||||
AC.getCFGBuildOptions().AddImplicitDtors = true;
|
||||
AC.getCFGBuildOptions().AddTemporaryDtors = true;
|
||||
AC.getCFGBuildOptions().AddCXXNewAllocator = false;
|
||||
AC.getCFGBuildOptions().AddCXXDefaultInitExprInCtors = true;
|
||||
|
||||
// Force that certain expressions appear as CFGElements in the CFG. This
|
||||
// is used to speed up various analyses.
|
||||
|
||||
Reference in New Issue
Block a user