зеркало из https://github.com/microsoft/clang-1.git
GRStateRef:
- Rename SetSVal to BindLoc - Add BindDecl - Add BindExpr GRState: - Environment now binds to Stmt* instead of Expr*. This is needed for processing ObjCForCollectionStmt (essentially the declaration of the the 'element' variable can have an SVal attached to it). - BindDecl no longer accepts Expr* for the initialization value; use SVal* instead. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59152 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
42577d145e
Коммит
d493163294
|
@ -1,4 +1,4 @@
|
|||
//== Environment.h - Map from Expr* to Locations/Values ---------*- C++ -*--==//
|
||||
//== Environment.h - Map from Stmt* to Locations/Values ---------*- C++ -*--==//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -36,7 +36,7 @@ private:
|
|||
friend class EnvironmentManager;
|
||||
|
||||
// Type definitions.
|
||||
typedef llvm::ImmutableMap<Expr*,SVal> BindingsTy;
|
||||
typedef llvm::ImmutableMap<Stmt*,SVal> BindingsTy;
|
||||
|
||||
// Data.
|
||||
BindingsTy SubExprBindings;
|
||||
|
@ -55,28 +55,25 @@ public:
|
|||
beb_iterator beb_begin() const { return BlkExprBindings.begin(); }
|
||||
beb_iterator beb_end() const { return BlkExprBindings.end(); }
|
||||
|
||||
SVal LookupSubExpr(Expr* E) const {
|
||||
const SVal* X = SubExprBindings.lookup(E);
|
||||
SVal LookupSubExpr(Stmt* E) const {
|
||||
const SVal* X = SubExprBindings.lookup(cast<Expr>(E));
|
||||
return X ? *X : UnknownVal();
|
||||
}
|
||||
|
||||
SVal LookupBlkExpr(Expr* E) const {
|
||||
SVal LookupBlkExpr(Stmt* E) const {
|
||||
const SVal* X = BlkExprBindings.lookup(E);
|
||||
return X ? *X : UnknownVal();
|
||||
}
|
||||
|
||||
SVal LookupExpr(Expr* E) const {
|
||||
SVal LookupExpr(Stmt* E) const {
|
||||
const SVal* X = SubExprBindings.lookup(E);
|
||||
if (X) return *X;
|
||||
X = BlkExprBindings.lookup(E);
|
||||
return X ? *X : UnknownVal();
|
||||
}
|
||||
|
||||
SVal GetSVal(Expr* Ex, BasicValueFactory& BasicVals) const;
|
||||
SVal GetSVal(const Expr* Ex, BasicValueFactory& BasicVals) const {
|
||||
return GetSVal(const_cast<Expr*>(Ex), BasicVals);
|
||||
}
|
||||
SVal GetBlkExprSVal(Expr* Ex, BasicValueFactory& BasicVals) const;
|
||||
SVal GetSVal(Stmt* Ex, BasicValueFactory& BasicVals) const;
|
||||
SVal GetBlkExprSVal(Stmt* Ex, BasicValueFactory& BasicVals) const;
|
||||
|
||||
/// Profile - Profile the contents of an Environment object for use
|
||||
/// in a FoldingSet.
|
||||
|
@ -108,23 +105,23 @@ public:
|
|||
~EnvironmentManager() {}
|
||||
|
||||
/// RemoveBlkExpr - Return a new environment object with the same bindings as
|
||||
/// the provided environment except with any bindings for the provided Expr*
|
||||
/// the provided environment except with any bindings for the provided Stmt*
|
||||
/// removed. This method only removes bindings for block-level expressions.
|
||||
/// Using this method on a non-block level expression will return the
|
||||
/// same environment object.
|
||||
Environment RemoveBlkExpr(const Environment& Env, Expr* E) {
|
||||
Environment RemoveBlkExpr(const Environment& Env, Stmt* E) {
|
||||
return Environment(Env.SubExprBindings, F.Remove(Env.BlkExprBindings, E));
|
||||
}
|
||||
|
||||
Environment RemoveSubExpr(const Environment& Env, Expr* E) {
|
||||
Environment RemoveSubExpr(const Environment& Env, Stmt* E) {
|
||||
return Environment(F.Remove(Env.SubExprBindings, E), Env.BlkExprBindings);
|
||||
}
|
||||
|
||||
Environment AddBlkExpr(const Environment& Env, Expr* E, SVal V) {
|
||||
Environment AddBlkExpr(const Environment& Env, Stmt* E, SVal V) {
|
||||
return Environment(Env.SubExprBindings, F.Add(Env.BlkExprBindings, E, V));
|
||||
}
|
||||
|
||||
Environment AddSubExpr(const Environment& Env, Expr* E, SVal V) {
|
||||
Environment AddSubExpr(const Environment& Env, Stmt* E, SVal V) {
|
||||
return Environment(F.Add(Env.SubExprBindings, E, V), Env.BlkExprBindings);
|
||||
}
|
||||
|
||||
|
@ -139,7 +136,7 @@ public:
|
|||
return Environment(F.GetEmptyMap(), F.GetEmptyMap());
|
||||
}
|
||||
|
||||
Environment BindExpr(const Environment& Env, Expr* E, SVal V,
|
||||
Environment BindExpr(const Environment& Env, Stmt* E, SVal V,
|
||||
bool isBlkExpr, bool Invalidate);
|
||||
|
||||
Environment RemoveDeadBindings(Environment Env, Stmt* Loc,
|
||||
|
|
|
@ -329,7 +329,7 @@ public:
|
|||
|
||||
typedef StoreManager::DeadSymbolsTy DeadSymbolsTy;
|
||||
|
||||
const GRState* BindDecl(const GRState* St, const VarDecl* VD, Expr* Ex,
|
||||
const GRState* BindDecl(const GRState* St, const VarDecl* VD, SVal* IVal,
|
||||
unsigned Count);
|
||||
|
||||
/// BindCompoundLiteral - Return the state that has the bindings currently
|
||||
|
@ -391,19 +391,19 @@ public:
|
|||
|
||||
// Methods that query & manipulate the Environment.
|
||||
|
||||
SVal GetSVal(const GRState* St, Expr* Ex) {
|
||||
SVal GetSVal(const GRState* St, Stmt* Ex) {
|
||||
return St->getEnvironment().GetSVal(Ex, BasicVals);
|
||||
}
|
||||
|
||||
SVal GetSVal(const GRState* St, const Expr* Ex) {
|
||||
return St->getEnvironment().GetSVal(Ex, BasicVals);
|
||||
SVal GetSVal(const GRState* St, const Stmt* Ex) {
|
||||
return St->getEnvironment().GetSVal(const_cast<Stmt*>(Ex), BasicVals);
|
||||
}
|
||||
|
||||
SVal GetBlkExprSVal(const GRState* St, Expr* Ex) {
|
||||
SVal GetBlkExprSVal(const GRState* St, Stmt* Ex) {
|
||||
return St->getEnvironment().GetBlkExprSVal(Ex, BasicVals);
|
||||
}
|
||||
|
||||
const GRState* BindExpr(const GRState* St, Expr* Ex, SVal V,
|
||||
const GRState* BindExpr(const GRState* St, Stmt* Ex, SVal V,
|
||||
bool isBlkExpr, bool Invalidate) {
|
||||
|
||||
const Environment& OldEnv = St->getEnvironment();
|
||||
|
@ -417,7 +417,7 @@ public:
|
|||
return getPersistentState(NewSt);
|
||||
}
|
||||
|
||||
const GRState* BindExpr(const GRState* St, Expr* Ex, SVal V,
|
||||
const GRState* BindExpr(const GRState* St, Stmt* Ex, SVal V,
|
||||
bool Invalidate = true) {
|
||||
|
||||
bool isBlkExpr = false;
|
||||
|
@ -562,20 +562,29 @@ public:
|
|||
return Mgr->GetSVal(St, R);
|
||||
}
|
||||
|
||||
GRStateRef SetSVal(Expr* Ex, SVal V, bool isBlkExpr, bool Invalidate) {
|
||||
GRStateRef BindExpr(Stmt* Ex, SVal V, bool isBlkExpr, bool Invalidate) {
|
||||
return GRStateRef(Mgr->BindExpr(St, Ex, V, isBlkExpr, Invalidate), *Mgr);
|
||||
}
|
||||
|
||||
GRStateRef SetSVal(Expr* Ex, SVal V, bool Invalidate = true) {
|
||||
GRStateRef BindExpr(Stmt* Ex, SVal V, bool Invalidate = true) {
|
||||
return GRStateRef(Mgr->BindExpr(St, Ex, V, Invalidate), *Mgr);
|
||||
}
|
||||
|
||||
GRStateRef BindDecl(const VarDecl* VD, SVal* InitVal, unsigned Count) {
|
||||
return GRStateRef(Mgr->BindDecl(St, VD, InitVal, Count), *Mgr);
|
||||
}
|
||||
|
||||
GRStateRef SetSVal(Loc LV, SVal V) {
|
||||
GRStateRef BindLoc(Loc LV, SVal V) {
|
||||
GRState StImpl = *St;
|
||||
Mgr->BindLoc(StImpl, LV, V);
|
||||
return GRStateRef(Mgr->getPersistentState(StImpl), *Mgr);
|
||||
}
|
||||
|
||||
GRStateRef BindLoc(SVal LV, SVal V) {
|
||||
if (!isa<Loc>(LV)) return *this;
|
||||
return BindLoc(cast<Loc>(LV), V);
|
||||
}
|
||||
|
||||
GRStateRef Unbind(Loc LV) {
|
||||
return GRStateRef(Mgr->Unbind(St, LV), *Mgr);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//== Environment.cpp - Map from Expr* to Locations/Values -------*- C++ -*--==//
|
||||
//== Environment.cpp - Map from Stmt* to Locations/Values -------*- C++ -*--==//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -18,7 +18,7 @@
|
|||
|
||||
using namespace clang;
|
||||
|
||||
SVal Environment::GetSVal(Expr* E, BasicValueFactory& BasicVals) const {
|
||||
SVal Environment::GetSVal(Stmt* E, BasicValueFactory& BasicVals) const {
|
||||
|
||||
for (;;) {
|
||||
|
||||
|
@ -58,7 +58,7 @@ SVal Environment::GetSVal(Expr* E, BasicValueFactory& BasicVals) const {
|
|||
break;
|
||||
}
|
||||
|
||||
// Handle all other Expr* using a lookup.
|
||||
// Handle all other Stmt* using a lookup.
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -70,26 +70,30 @@ SVal Environment::GetSVal(Expr* E, BasicValueFactory& BasicVals) const {
|
|||
return LookupExpr(E);
|
||||
}
|
||||
|
||||
SVal Environment::GetBlkExprSVal(Expr* E, BasicValueFactory& BasicVals) const {
|
||||
SVal Environment::GetBlkExprSVal(Stmt* E, BasicValueFactory& BasicVals) const {
|
||||
|
||||
E = E->IgnoreParens();
|
||||
|
||||
switch (E->getStmtClass()) {
|
||||
case Stmt::CharacterLiteralClass: {
|
||||
CharacterLiteral* C = cast<CharacterLiteral>(E);
|
||||
return NonLoc::MakeVal(BasicVals, C->getValue(), C->getType());
|
||||
while (1) {
|
||||
switch (E->getStmtClass()) {
|
||||
case Stmt::ParenExprClass:
|
||||
E = cast<ParenExpr>(E)->getSubExpr();
|
||||
continue;
|
||||
|
||||
case Stmt::CharacterLiteralClass: {
|
||||
CharacterLiteral* C = cast<CharacterLiteral>(E);
|
||||
return NonLoc::MakeVal(BasicVals, C->getValue(), C->getType());
|
||||
}
|
||||
|
||||
case Stmt::IntegerLiteralClass: {
|
||||
return NonLoc::MakeVal(BasicVals, cast<IntegerLiteral>(E));
|
||||
}
|
||||
|
||||
default:
|
||||
return LookupBlkExpr(E);
|
||||
}
|
||||
|
||||
case Stmt::IntegerLiteralClass: {
|
||||
return NonLoc::MakeVal(BasicVals, cast<IntegerLiteral>(E));
|
||||
}
|
||||
|
||||
default:
|
||||
return LookupBlkExpr(E);
|
||||
}
|
||||
}
|
||||
|
||||
Environment EnvironmentManager::BindExpr(const Environment& Env, Expr* E,SVal V,
|
||||
Environment EnvironmentManager::BindExpr(const Environment& Env, Stmt* E,SVal V,
|
||||
bool isBlkExpr, bool Invalidate) {
|
||||
assert (E);
|
||||
|
||||
|
@ -115,7 +119,7 @@ EnvironmentManager::RemoveDeadBindings(Environment Env, Stmt* Loc,
|
|||
// Iterate over the block-expr bindings.
|
||||
for (Environment::beb_iterator I = Env.beb_begin(), E = Env.beb_end();
|
||||
I != E; ++I) {
|
||||
Expr* BlkExpr = I.getKey();
|
||||
Stmt* BlkExpr = I.getKey();
|
||||
|
||||
if (Liveness.isLive(Loc, BlkExpr)) {
|
||||
SVal X = I.getData();
|
||||
|
|
|
@ -73,15 +73,10 @@ const GRState* GRStateManager::BindLoc(const GRState* St, Loc LV, SVal V) {
|
|||
}
|
||||
|
||||
const GRState* GRStateManager::BindDecl(const GRState* St, const VarDecl* VD,
|
||||
Expr* Ex, unsigned Count) {
|
||||
SVal* InitVal, unsigned Count) {
|
||||
Store OldStore = St->getStore();
|
||||
Store NewStore;
|
||||
Store NewStore = StoreMgr->BindDecl(OldStore, VD, InitVal, Count);
|
||||
|
||||
if (Ex)
|
||||
NewStore = StoreMgr->BindDecl(OldStore, VD, Ex, GetSVal(St, Ex), Count);
|
||||
else
|
||||
NewStore = StoreMgr->BindDecl(OldStore, VD, Ex);
|
||||
|
||||
if (NewStore == OldStore)
|
||||
return St;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче