From f1b9209a34aa5e22b8c7943f54cb77ccf52d42d6 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 28 Aug 2008 18:43:46 +0000 Subject: [PATCH] Fixed analyzer caching bug involving the transfer function for loads. llvm-svn: 55494 --- .../include/clang/Analysis/PathSensitive/GRCoreEngine.h | 5 +++-- .../include/clang/Analysis/PathSensitive/GRExprEngine.h | 5 +++-- clang/lib/Analysis/GRExprEngine.cpp | 9 +++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/clang/include/clang/Analysis/PathSensitive/GRCoreEngine.h b/clang/include/clang/Analysis/PathSensitive/GRCoreEngine.h index 4f09c9089bb0..2211f3a4d933 100644 --- a/clang/include/clang/Analysis/PathSensitive/GRCoreEngine.h +++ b/clang/include/clang/Analysis/PathSensitive/GRCoreEngine.h @@ -230,7 +230,8 @@ public: } NodeTy* MakeNode(ExplodedNodeSet& Dst, Stmt* S, - NodeTy* Pred, const StateTy* St) { + NodeTy* Pred, const StateTy* St, + ProgramPoint::Kind K = ProgramPoint::PostStmtKind) { const StateTy* PredState = GetState(Pred); @@ -240,7 +241,7 @@ public: return NULL; } - NodeTy* N = generateNode(S, St, Pred); + NodeTy* N = generateNode(S, St, Pred, K); if (N) { if (BuildSinks) diff --git a/clang/include/clang/Analysis/PathSensitive/GRExprEngine.h b/clang/include/clang/Analysis/PathSensitive/GRExprEngine.h index 7cd345d2338d..b1f4e70d39b8 100644 --- a/clang/include/clang/Analysis/PathSensitive/GRExprEngine.h +++ b/clang/include/clang/Analysis/PathSensitive/GRExprEngine.h @@ -442,9 +442,10 @@ protected: return StateMgr.Assume(St, Cond, Assumption, isFeasible); } - NodeTy* MakeNode(NodeSet& Dst, Stmt* S, NodeTy* Pred, const GRState* St) { + NodeTy* MakeNode(NodeSet& Dst, Stmt* S, NodeTy* Pred, const GRState* St, + ProgramPoint::Kind K = ProgramPoint::PostStmtKind) { assert (Builder && "GRStmtNodeBuilder not present."); - return Builder->MakeNode(Dst, S, Pred, St); + return Builder->MakeNode(Dst, S, Pred, St, K); } /// Visit - Transfer function logic for all statements. Dispatches to diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp index 75ba46051ffd..affb02a962a7 100644 --- a/clang/lib/Analysis/GRExprEngine.cpp +++ b/clang/lib/Analysis/GRExprEngine.cpp @@ -954,22 +954,23 @@ void GRExprEngine::EvalLoad(NodeSet& Dst, Expr* Ex, NodeTy* Pred, return; // Proceed with the load. + ProgramPoint::Kind K = ProgramPoint::PostLoadKind; // FIXME: Currently symbolic analysis "generates" new symbols // for the contents of values. We need a better approach. // FIXME: The "CheckOnly" option exists only because Array and Field // loads aren't fully implemented. Eventually this option will go away. - + if (CheckOnly) - MakeNode(Dst, Ex, Pred, St); + MakeNode(Dst, Ex, Pred, St, K); else if (location.isUnknown()) { // This is important. We must nuke the old binding. - MakeNode(Dst, Ex, Pred, SetRVal(St, Ex, UnknownVal())); + MakeNode(Dst, Ex, Pred, SetRVal(St, Ex, UnknownVal()), K); } else MakeNode(Dst, Ex, Pred, SetRVal(St, Ex, GetRVal(St, cast(location), - Ex->getType()))); + Ex->getType())), K); } const GRState* GRExprEngine::EvalLocation(Expr* Ex, NodeTy* Pred,