[PATCH] Append CXXDefaultInitExpr's wrapped expression to the CFG when visiting a constructor initializer
Enrico Pertoso
epertoso at google.com
Thu Feb 6 07:33:58 PST 2014
Hi rsmith, jordan_rose,
http://llvm-reviews.chandlerc.com/D2370
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D2370?vs=6777&id=6921#toc
Files:
include/clang/Analysis/CFG.h
lib/Analysis/CFG.cpp
lib/Sema/AnalysisBasedWarnings.cpp
Index: include/clang/Analysis/CFG.h
===================================================================
--- include/clang/Analysis/CFG.h
+++ include/clang/Analysis/CFG.h
@@ -667,6 +667,7 @@
bool AddTemporaryDtors;
bool AddStaticInitBranches;
bool AddCXXNewAllocator;
+ bool AddCXXDefaultInitExprInCtors;
bool alwaysAdd(const Stmt *stmt) const {
return alwaysAddMask[stmt->getStmtClass()];
@@ -689,7 +690,8 @@
,AddImplicitDtors(false)
,AddTemporaryDtors(false)
,AddStaticInitBranches(false)
- ,AddCXXNewAllocator(false) {}
+ ,AddCXXNewAllocator(false)
+ ,AddCXXDefaultInitExprInCtors(false) {}
};
/// \brief Provides a custom implementation of the iterator class to have the
Index: lib/Analysis/CFG.cpp
===================================================================
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -770,6 +770,19 @@
// 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);
}
Index: lib/Sema/AnalysisBasedWarnings.cpp
===================================================================
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -1731,6 +1731,7 @@
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2370.5.patch
Type: text/x-patch
Size: 2216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140206/3e4284ab/attachment.bin>
More information about the cfe-commits
mailing list