From: Ted Kremenek Date: Wed, 5 Mar 2008 22:49:16 +0000 (+0000) Subject: Small bug fix when handling CallExprs that generate sink nodes. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5dc7f8b2d6a4f94ab4d1377912499a23cf8bc024;p=clang Small bug fix when handling CallExprs that generate sink nodes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47970 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Analysis/GRExprEngine.cpp b/Analysis/GRExprEngine.cpp index f8ebbec597..fa623a49e4 100644 --- a/Analysis/GRExprEngine.cpp +++ b/Analysis/GRExprEngine.cpp @@ -501,17 +501,8 @@ void GRExprEngine::VisitCall(CallExpr* CE, NodeTy* Pred, SaveAndRestore OldSink(Builder->BuildSinks); if (isa(L)) - if (cast(L).getDecl()->getAttr()) { - for (NodeSet::iterator I=Dst.begin(), E=Dst.end(); I != E; ++I ) { - - NodeTy* N = *I; - - if (!N->isSink()) - N->markAsSink(); - } - + if (cast(L).getDecl()->getAttr()) Builder->BuildSinks = true; - } // Evaluate the call. @@ -573,7 +564,7 @@ void GRExprEngine::VisitCall(CallExpr* CE, NodeTy* Pred, EvalCall(Dst, CE, cast(L), *DI); - if (Dst.size() == size) + if (!Builder->BuildSinks && Dst.size() == size) Nodify(Dst, CE, *DI, St); } } diff --git a/include/clang/Analysis/PathSensitive/GRCoreEngine.h b/include/clang/Analysis/PathSensitive/GRCoreEngine.h index e38f86e07a..37dddea281 100644 --- a/include/clang/Analysis/PathSensitive/GRCoreEngine.h +++ b/include/clang/Analysis/PathSensitive/GRCoreEngine.h @@ -177,20 +177,23 @@ public: } NodeTy* Nodify(ExplodedNodeSet& Dst, Stmt* S, - NodeTy* Pred, StateTy* St) { + NodeTy* Pred, StateTy* St) { + // If the state hasn't changed, don't generate a new node. - if (St == Pred->getState()) { + if (!BuildSinks && St == Pred->getState()) { Dst.Add(Pred); return NULL; } NodeTy* N = generateNode(S, St, Pred); - if (N && BuildSinks) - N->markAsSink(); - else - Dst.Add(N); + if (N) { + if (BuildSinks) + N->markAsSink(); + else + Dst.Add(N); + } return N; }