[cfe-commits] r46582 - in /cfe/trunk: Analysis/GRConstants.cpp Analysis/GREngine.cpp include/clang/Analysis/PathSensitive/GREngine.h

Ted Kremenek kremenek at apple.com
Wed Jan 30 15:24:40 PST 2008


Author: kremenek
Date: Wed Jan 30 17:24:39 2008
New Revision: 46582

URL: http://llvm.org/viewvc/llvm-project?rev=46582&view=rev
Log:
We now delay adding nodes created by GRBranchNodeBuilder to the analysis
worklist until the dstor of GRBranchNodeBuilderImpl. This way clients can mark
creates nodes as "sinks" before they are added to the worklist.

Modified:
    cfe/trunk/Analysis/GRConstants.cpp
    cfe/trunk/Analysis/GREngine.cpp
    cfe/trunk/include/clang/Analysis/PathSensitive/GREngine.h

Modified: cfe/trunk/Analysis/GRConstants.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRConstants.cpp?rev=46582&r1=46581&r2=46582&view=diff

==============================================================================
--- cfe/trunk/Analysis/GRConstants.cpp (original)
+++ cfe/trunk/Analysis/GRConstants.cpp Wed Jan 30 17:24:39 2008
@@ -842,6 +842,10 @@
     
     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 @@
 //===----------------------------------------------------------------------===//
 
 #ifndef NDEBUG
+static GRConstants* GraphPrintCheckerState;
+
 namespace llvm {
 template<>
 struct VISIBILITY_HIDDEN DOTGraphTraits<GRConstants::NodeTy*> :
@@ -1566,6 +1572,10 @@
           
           Out << "\\l";
         }
+        
+        if (GraphPrintCheckerState->isUninitControlFlow(N)) {
+          Out << "\\|Control-flow based on\\lUninitialized value.\\l";
+        }
       }
     }
     
@@ -1587,7 +1597,9 @@
   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

Modified: cfe/trunk/Analysis/GREngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GREngine.cpp?rev=46582&r1=46581&r2=46582&view=diff

==============================================================================
--- cfe/trunk/Analysis/GREngine.cpp (original)
+++ cfe/trunk/Analysis/GREngine.cpp Wed Jan 30 17:24:39 2008
@@ -301,7 +301,7 @@
   else GeneratedFalse = true;  
   
   if (IsNew) {
-    Eng.WList->Enqueue(GRWorkListUnit(Succ));
+    Deferred.push_back(Succ);
     return Succ;
   }
   
@@ -311,4 +311,7 @@
 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));
 }

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GREngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GREngine.h?rev=46582&r1=46581&r2=46582&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GREngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GREngine.h Wed Jan 30 17:24:39 2008
@@ -167,6 +167,9 @@
   CFGBlock* DstF;
   ExplodedNodeImpl* Pred;
 
+  typedef llvm::SmallVector<ExplodedNodeImpl*,3> DeferredTy;
+  DeferredTy Deferred;
+  
   bool GeneratedTrue;
   bool GeneratedFalse;
   





More information about the cfe-commits mailing list