]> granicus.if.org Git - clang/commitdiff
Fixed insidious state propagation bug that would sometimes cause the state
authorTed Kremenek <kremenek@apple.com>
Tue, 4 Mar 2008 00:56:45 +0000 (00:56 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 4 Mar 2008 00:56:45 +0000 (00:56 +0000)
to bifurcate at the wrong places and not propagate at others.

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

Analysis/GRExprEngine.cpp
include/clang/Analysis/PathSensitive/GRExprEngine.h

index 660ed1badba72f700b0c1c2d4aae073497454299..9513deb3f1dd34b69f923ca0781f3d586baa4056 100644 (file)
@@ -437,8 +437,10 @@ GRExprEngine::NodeTy*
 GRExprEngine::Nodify(NodeSet& Dst, Stmt* S, NodeTy* Pred, ValueState* St) {
  
   // If the state hasn't changed, don't generate a new node.
-  if (St == Pred->getState())
+  if (St == Pred->getState()) {
+    Dst.Add(Pred);
     return NULL;
+  }
   
   NodeTy* N = Builder->generateNode(S, St, Pred);
   Dst.Add(N);
@@ -478,11 +480,8 @@ void GRExprEngine::VisitCall(CallExpr* CE, NodeTy* Pred,
   
   if (AI != AE) {
     
-    NodeSet DstTmp;  
-    
-    Visit(*AI, Pred, DstTmp);
-    
-    if (DstTmp.empty()) DstTmp.Add(Pred);
+    NodeSet DstTmp;      
+    Visit(*AI, Pred, DstTmp);  
     
     Expr* CurrentArg = *AI;
     ++AI;
index 3a4e358d66b7c9c28ecea3cf92626235db116bcd..e310bf577fac487140909f0b00028b6ce51621d6 100644 (file)
@@ -33,15 +33,15 @@ public:
   typedef GRSwitchNodeBuilder<GRExprEngine>        SwitchNodeBuilder;
   
   class NodeSet {
-    typedef llvm::SmallVector<NodeTy*,3> ImplTy;
+    typedef llvm::SmallPtrSet<NodeTy*,10> ImplTy;
     ImplTy Impl;
     
   public:
 
-    NodeSet(NodeTy* N) { assert (N && !N->isSink()); Impl.push_back(N); }
+    NodeSet(NodeTy* N) { assert (N && !N->isSink()); Impl.insert(N); }
     NodeSet() {}
     
-    inline void Add(NodeTy* N) { if (N && !N->isSink()) Impl.push_back(N); }
+    inline void Add(NodeTy* N) { if (N && !N->isSink()) Impl.insert(N); }
     
     typedef ImplTy::iterator       iterator;
     typedef ImplTy::const_iterator const_iterator;