]> granicus.if.org Git - clang/commitdiff
We now delay adding nodes created by GRBranchNodeBuilder to the analysis
authorTed Kremenek <kremenek@apple.com>
Wed, 30 Jan 2008 23:24:39 +0000 (23:24 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 30 Jan 2008 23:24:39 +0000 (23:24 +0000)
worklist until the dstor of GRBranchNodeBuilderImpl. This way clients can mark
creates nodes as "sinks" before they are added to the worklist.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46582 91177308-0d34-0410-b5e6-96231b3b80d8

Analysis/GRConstants.cpp
Analysis/GREngine.cpp
include/clang/Analysis/PathSensitive/GREngine.h

index 6d5bdbd1199de47b727309da86a828f808824e14..36ad5fe20a80858e0b0181efc49923b82b72e82a 100644 (file)
@@ -842,6 +842,10 @@ public:
     
     return St;
   }
+  
+  bool isUninitControlFlow(const NodeTy* N) const {
+    return N->isSink() && UninitBranches.count(const_cast<NodeTy*>(N)) != 0;
+  }
 
   /// ProcessStmt - Called by GREngine. Used to generate new successor
   ///  nodes by processing the 'effects' of a block-level statement.
@@ -1474,6 +1478,8 @@ StateTy GRConstants::Assume(StateTy St, NonLValue Cond, bool Assumption,
 //===----------------------------------------------------------------------===//
 
 #ifndef NDEBUG
+static GRConstants* GraphPrintCheckerState;
+
 namespace llvm {
 template<>
 struct VISIBILITY_HIDDEN DOTGraphTraits<GRConstants::NodeTy*> :
@@ -1566,6 +1572,10 @@ struct VISIBILITY_HIDDEN DOTGraphTraits<GRConstants::NodeTy*> :
           
           Out << "\\l";
         }
+        
+        if (GraphPrintCheckerState->isUninitControlFlow(N)) {
+          Out << "\\|Control-flow based on\\lUninitialized value.\\l";
+        }
       }
     }
     
@@ -1587,7 +1597,9 @@ void RunGRConstants(CFG& cfg, FunctionDecl& FD, ASTContext& Ctx) {
   GREngine<GRConstants> Engine(cfg, FD, Ctx);
   Engine.ExecuteWorkList();  
 #ifndef NDEBUG
+  GraphPrintCheckerState = &Engine.getCheckerState();
   llvm::ViewGraph(*Engine.getGraph().roots_begin(),"GRConstants");
+  GraphPrintCheckerState = NULL;
 #endif  
 }
 } // end clang namespace
index 46fbd187f178ff4566702f3baf101090988b4aa4..8e86d08daadebbc44f14d92d054aab60ff27ce4a 100644 (file)
@@ -301,7 +301,7 @@ ExplodedNodeImpl* GRBranchNodeBuilderImpl::generateNodeImpl(void* State,
   else GeneratedFalse = true;  
   
   if (IsNew) {
-    Eng.WList->Enqueue(GRWorkListUnit(Succ));
+    Deferred.push_back(Succ);
     return Succ;
   }
   
@@ -311,4 +311,7 @@ ExplodedNodeImpl* GRBranchNodeBuilderImpl::generateNodeImpl(void* State,
 GRBranchNodeBuilderImpl::~GRBranchNodeBuilderImpl() {
   if (!GeneratedTrue) generateNodeImpl(Pred->State, true);
   if (!GeneratedFalse) generateNodeImpl(Pred->State, false);
+  
+  for (DeferredTy::iterator I=Deferred.begin(), E=Deferred.end(); I!=E; ++I)
+    if (!(*I)->isSink()) Eng.WList->Enqueue(GRWorkListUnit(*I));
 }
index 8c3fc12bb91a8eaaeb7f6a958bcf8ff31b30fb8a..cb3366e3c063c1968b4a79ca470543ff06c21f19 100644 (file)
@@ -167,6 +167,9 @@ class GRBranchNodeBuilderImpl {
   CFGBlock* DstF;
   ExplodedNodeImpl* Pred;
 
+  typedef llvm::SmallVector<ExplodedNodeImpl*,3> DeferredTy;
+  DeferredTy Deferred;
+  
   bool GeneratedTrue;
   bool GeneratedFalse;