From 2a30ea6269086f7604e1d7013c30b1d3948b3d9f Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 4 Mar 2008 00:56:45 +0000 Subject: [PATCH] Fixed insidious state propagation bug that would sometimes cause the state to bifurcate at the wrong places and not propagate at others. llvm-svn: 47876 --- clang/Analysis/GRExprEngine.cpp | 11 +++++------ .../clang/Analysis/PathSensitive/GRExprEngine.h | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/clang/Analysis/GRExprEngine.cpp b/clang/Analysis/GRExprEngine.cpp index 660ed1badba7..9513deb3f1dd 100644 --- a/clang/Analysis/GRExprEngine.cpp +++ b/clang/Analysis/GRExprEngine.cpp @@ -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; diff --git a/clang/include/clang/Analysis/PathSensitive/GRExprEngine.h b/clang/include/clang/Analysis/PathSensitive/GRExprEngine.h index 3a4e358d66b7..e310bf577fac 100644 --- a/clang/include/clang/Analysis/PathSensitive/GRExprEngine.h +++ b/clang/include/clang/Analysis/PathSensitive/GRExprEngine.h @@ -33,15 +33,15 @@ public: typedef GRSwitchNodeBuilder SwitchNodeBuilder; class NodeSet { - typedef llvm::SmallVector ImplTy; + typedef llvm::SmallPtrSet 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; -- GitLab