[cfe-commits] r127387 - /cfe/trunk/lib/Analysis/CFG.cpp

Ted Kremenek kremenek at apple.com
Wed Mar 9 17:14:11 PST 2011


Author: kremenek
Date: Wed Mar  9 19:14:11 2011
New Revision: 127387

URL: http://llvm.org/viewvc/llvm-project?rev=127387&view=rev
Log:
Require AddStmtChoice::alwaysAdd() to take a CFGBuilder& and Stmt*.  Prep for functionality changes.

Modified:
    cfe/trunk/lib/Analysis/CFG.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=127387&r1=127386&r2=127387&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Wed Mar  9 19:14:11 2011
@@ -36,6 +36,8 @@
   return D->getLocation();
 }
 
+class CFGBuilder;
+  
 /// The CFG builder uses a recursive algorithm to build the CFG.  When
 ///  we process an expression, sometimes we know that we must add the
 ///  subexpressions as block-level expressions.  For example:
@@ -55,13 +57,13 @@
 
   AddStmtChoice(Kind a_kind = NotAlwaysAdd) : kind(a_kind) {}
 
-  bool alwaysAdd() const { return kind & AlwaysAdd; }
+  bool alwaysAdd(CFGBuilder &builder,
+                 const Stmt *stmt) const;
 
   /// Return a copy of this object, except with the 'always-add' bit
   ///  set as specified.
   AddStmtChoice withAlwaysAdd(bool alwaysAdd) const {
-    return AddStmtChoice(alwaysAdd ? Kind(kind | AlwaysAdd) :
-                                     Kind(kind & ~AlwaysAdd));
+    return AddStmtChoice(alwaysAdd ? AlwaysAdd : NotAlwaysAdd);
   }
 
 private:
@@ -441,6 +443,11 @@
   
 };
 
+bool AddStmtChoice::alwaysAdd(CFGBuilder &builder,
+                              const Stmt *stmt) const {
+  return kind == AlwaysAdd;
+}
+  
 // FIXME: Add support for dependent-sized array types in C++?
 // Does it even make sense to build a CFG for an uninstantiated template?
 static const VariableArrayType *FindVA(const Type *t) {
@@ -934,7 +941,7 @@
 }
 
 CFGBlock *CFGBuilder::VisitStmt(Stmt *S, AddStmtChoice asc) {
-  if (asc.alwaysAdd()) {
+  if (asc.alwaysAdd(*this, S)) {
     autoCreateBlock();
     appendStmt(Block, S);
   }
@@ -957,7 +964,7 @@
                                          AddStmtChoice asc) {
   AddressTakenLabels.insert(A->getLabel());
 
-  if (asc.alwaysAdd()) {
+  if (asc.alwaysAdd(*this, A)) {
     autoCreateBlock();
     appendStmt(Block, A);
   }
@@ -967,7 +974,7 @@
 
 CFGBlock *CFGBuilder::VisitUnaryOperator(UnaryOperator *U,
            AddStmtChoice asc) {
-  if (asc.alwaysAdd()) {
+  if (asc.alwaysAdd(*this, U)) {
     autoCreateBlock();
     appendStmt(Block, U);
   }
@@ -1030,7 +1037,7 @@
   }
 
   if (B->isAssignmentOp()) {
-    if (asc.alwaysAdd()) {
+    if (asc.alwaysAdd(*this, B)) {
       autoCreateBlock();
       appendStmt(Block, B);
     }
@@ -1038,7 +1045,7 @@
     return Visit(B->getRHS());
   }
 
-  if (asc.alwaysAdd()) {
+  if (asc.alwaysAdd(*this, B)) {
     autoCreateBlock();
     appendStmt(Block, B);
   }
@@ -1052,7 +1059,7 @@
 }
 
 CFGBlock *CFGBuilder::VisitBlockExpr(BlockExpr *E, AddStmtChoice asc) {
-  if (asc.alwaysAdd()) {
+  if (asc.alwaysAdd(*this, E)) {
     autoCreateBlock();
     appendStmt(Block, E);
   }
@@ -1680,7 +1687,7 @@
 }
 
 CFGBlock *CFGBuilder::VisitMemberExpr(MemberExpr *M, AddStmtChoice asc) {
-  if (asc.alwaysAdd()) {
+  if (asc.alwaysAdd(*this, M)) {
     autoCreateBlock();
     appendStmt(Block, M);
   }
@@ -2116,7 +2123,7 @@
 CFGBlock *CFGBuilder::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E,
                                              AddStmtChoice asc) {
 
-  if (asc.alwaysAdd()) {
+  if (asc.alwaysAdd(*this, E)) {
     autoCreateBlock();
     appendStmt(Block, E);
   }
@@ -2134,7 +2141,7 @@
 /// VisitStmtExpr - Utility method to handle (nested) statement
 ///  expressions (a GCC extension).
 CFGBlock* CFGBuilder::VisitStmtExpr(StmtExpr *SE, AddStmtChoice asc) {
-  if (asc.alwaysAdd()) {
+  if (asc.alwaysAdd(*this, SE)) {
     autoCreateBlock();
     appendStmt(Block, SE);
   }
@@ -2471,7 +2478,7 @@
 
 CFGBlock *CFGBuilder::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E,
                                                 AddStmtChoice asc) {
-  if (asc.alwaysAdd()) {
+  if (asc.alwaysAdd(*this, E)) {
     autoCreateBlock();
     appendStmt(Block, E);
 
@@ -2492,7 +2499,7 @@
 
 CFGBlock *CFGBuilder::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E,
                                                  AddStmtChoice asc) {
-  if (asc.alwaysAdd()) {
+  if (asc.alwaysAdd(*this, E)) {
     autoCreateBlock();
     appendStmt(Block, E);
     // We do not want to propagate the AlwaysAdd property.
@@ -2517,7 +2524,7 @@
 
 CFGBlock *CFGBuilder::VisitImplicitCastExpr(ImplicitCastExpr *E,
                                             AddStmtChoice asc) {
-  if (asc.alwaysAdd()) {
+  if (asc.alwaysAdd(*this, E)) {
     autoCreateBlock();
     appendStmt(Block, E);
   }





More information about the cfe-commits mailing list