aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/BasicStore.cpp40
-rw-r--r--lib/Analysis/GRExprEngine.cpp44
-rw-r--r--lib/Analysis/GRState.cpp5
3 files changed, 42 insertions, 47 deletions
diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp
index 64a230975f..15284567e6 100644
--- a/lib/Analysis/BasicStore.cpp
+++ b/lib/Analysis/BasicStore.cpp
@@ -13,6 +13,7 @@
#include "clang/Analysis/Analyses/LiveVariables.h"
#include "clang/Analysis/PathSensitive/BasicStore.h"
+#include "clang/Analysis/PathSensitive/GRState.h"
#include "llvm/ADT/ImmutableMap.h"
#include "llvm/Support/Compiler.h"
@@ -32,9 +33,7 @@ public:
virtual Store SetRVal(Store St, LVal LV, RVal V);
virtual Store Remove(Store St, LVal LV);
- virtual Store getInitialStore() {
- return VBFactory.GetEmptyMap().getRoot();
- }
+ virtual Store getInitialStore(GRStateManager& StateMgr);
virtual Store RemoveDeadBindings(Store store, Stmt* Loc,
const LiveVariables& Live,
@@ -200,3 +199,38 @@ Store BasicStoreManager::RemoveDeadBindings(Store store,
return store;
}
+
+Store BasicStoreManager::getInitialStore(GRStateManager& StateMgr) {
+ // The LiveVariables information already has a compilation of all VarDecls
+ // used in the function. Iterate through this set, and "symbolicate"
+ // any VarDecl whose value originally comes from outside the function.
+
+ typedef LiveVariables::AnalysisDataTy LVDataTy;
+ LVDataTy& D = StateMgr.getLiveVariables().getAnalysisData();
+
+ Store St = VBFactory.GetEmptyMap().getRoot();
+
+ for (LVDataTy::decl_iterator I=D.begin_decl(), E=D.end_decl(); I != E; ++I) {
+ ScopedDecl* SD = const_cast<ScopedDecl*>(I->first);
+
+ if (VarDecl* VD = dyn_cast<VarDecl>(SD)) {
+ // Punt on static variables for now.
+ if (VD->getStorageClass() == VarDecl::Static)
+ continue;
+
+ // Only handle pointers and integers for now.
+ QualType T = VD->getType();
+ if (LVal::IsLValType(T) || T->isIntegerType()) {
+ // Initialize globals and parameters to symbolic values.
+ // Initialize local variables to undefined.
+ RVal X = (VD->hasGlobalStorage() || isa<ParmVarDecl>(VD) ||
+ isa<ImplicitParamDecl>(VD))
+ ? RVal::GetSymbolValue(StateMgr.getSymbolManager(), VD)
+ : UndefinedVal();
+
+ St = SetRVal(St, lval::DeclVal(VD), X);
+ }
+ }
+ }
+ return St;
+}
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index 18c5a5825e..7433509c85 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -121,7 +121,7 @@ GRExprEngine::GRExprEngine(CFG& cfg, Decl& CD, ASTContext& Ctx,
Liveness(L),
Builder(NULL),
StateMgr(G.getContext(), CreateBasicStoreManager(G.getAllocator()),
- G.getAllocator(), G.getCFG()),
+ G.getAllocator(), G.getCFG(), L),
SymMgr(StateMgr.getSymbolManager()),
CurrentStmt(NULL),
NSExceptionII(NULL), NSExceptionInstanceRaiseSelectors(NULL),
@@ -189,47 +189,7 @@ void GRExprEngine::AddCheck(GRSimpleAPICheck* A, Stmt::StmtClass C) {
}
const GRState* GRExprEngine::getInitialState() {
-
- // The LiveVariables information already has a compilation of all VarDecls
- // used in the function. Iterate through this set, and "symbolicate"
- // any VarDecl whose value originally comes from outside the function.
-
- typedef LiveVariables::AnalysisDataTy LVDataTy;
- LVDataTy& D = Liveness.getAnalysisData();
-
- GRState StateImpl = *StateMgr.getInitialState();
-
- for (LVDataTy::decl_iterator I=D.begin_decl(), E=D.end_decl(); I != E; ++I) {
-
- ScopedDecl *SD = const_cast<ScopedDecl*>(I->first);
- if (VarDecl* VD = dyn_cast<VarDecl>(SD)) {
- // Punt on static variables for now.
- if (VD->getStorageClass() == VarDecl::Static)
- continue;
-
- // Only handle pointers and integers for now.
- QualType T = VD->getType();
- if (!(LVal::IsLValType(T) || T->isIntegerType()))
- continue;
-
- // Initialize globals and parameters to symbolic values.
- // Initialize local variables to undefined.
- RVal X = (VD->hasGlobalStorage() || isa<ParmVarDecl>(VD) ||
- isa<ImplicitParamDecl>(VD))
- ? RVal::GetSymbolValue(SymMgr, VD)
- : UndefinedVal();
-
- StateMgr.SetRVal(StateImpl, lval::DeclVal(VD), X);
-
- } else if (ImplicitParamDecl *IPD = dyn_cast<ImplicitParamDecl>(SD)) {
- RVal X = RVal::GetSymbolValue(SymMgr, IPD);
- StateMgr.SetRVal(StateImpl, lval::DeclVal(IPD), X);
- }
-
-
- }
-
- return StateMgr.getPersistentState(StateImpl);
+ return StateMgr.getInitialState();
}
//===----------------------------------------------------------------------===//
diff --git a/lib/Analysis/GRState.cpp b/lib/Analysis/GRState.cpp
index cd81c57f90..e4022a2663 100644
--- a/lib/Analysis/GRState.cpp
+++ b/lib/Analysis/GRState.cpp
@@ -211,9 +211,10 @@ const GRState* GRStateManager::AddEQ(const GRState* St, SymbolID sym,
const GRState* GRStateManager::getInitialState() {
- GRState StateImpl(EnvMgr.getInitialEnvironment(), StMgr->getInitialStore(),
+ GRState StateImpl(EnvMgr.getInitialEnvironment(),
+ StMgr->getInitialStore(*this),
GDMFactory.GetEmptyMap());
-
+
return getPersistentState(StateImpl);
}