зеркало из https://github.com/microsoft/clang-1.git
Move clients over from using GRStateManager::BindXXX and friends to
GRState->bindXXX and friends (and constify some arguments along the way). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73740 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
f1b8227d75
Коммит
23ec48cd33
|
@ -35,7 +35,7 @@ private:
|
|||
friend class EnvironmentManager;
|
||||
|
||||
// Type definitions.
|
||||
typedef llvm::ImmutableMap<Stmt*,SVal> BindingsTy;
|
||||
typedef llvm::ImmutableMap<const Stmt*,SVal> BindingsTy;
|
||||
|
||||
// Data.
|
||||
BindingsTy SubExprBindings;
|
||||
|
@ -54,25 +54,25 @@ public:
|
|||
beb_iterator beb_begin() const { return BlkExprBindings.begin(); }
|
||||
beb_iterator beb_end() const { return BlkExprBindings.end(); }
|
||||
|
||||
SVal LookupSubExpr(Stmt* E) const {
|
||||
SVal LookupSubExpr(const Stmt* E) const {
|
||||
const SVal* X = SubExprBindings.lookup(cast<Expr>(E));
|
||||
return X ? *X : UnknownVal();
|
||||
}
|
||||
|
||||
SVal LookupBlkExpr(Stmt* E) const {
|
||||
SVal LookupBlkExpr(const Stmt* E) const {
|
||||
const SVal* X = BlkExprBindings.lookup(E);
|
||||
return X ? *X : UnknownVal();
|
||||
}
|
||||
|
||||
SVal LookupExpr(Stmt* E) const {
|
||||
SVal LookupExpr(const Stmt* E) const {
|
||||
const SVal* X = SubExprBindings.lookup(E);
|
||||
if (X) return *X;
|
||||
X = BlkExprBindings.lookup(E);
|
||||
return X ? *X : UnknownVal();
|
||||
}
|
||||
|
||||
SVal GetSVal(Stmt* Ex, BasicValueFactory& BasicVals) const;
|
||||
SVal GetBlkExprSVal(Stmt* Ex, BasicValueFactory& BasicVals) const;
|
||||
SVal GetSVal(const Stmt* Ex, BasicValueFactory& BasicVals) const;
|
||||
SVal GetBlkExprSVal(const Stmt* Ex, BasicValueFactory& BasicVals) const;
|
||||
|
||||
/// Profile - Profile the contents of an Environment object for use
|
||||
/// in a FoldingSet.
|
||||
|
@ -108,19 +108,19 @@ public:
|
|||
/// 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, Stmt* E) {
|
||||
Environment RemoveBlkExpr(const Environment& Env, const Stmt* E) {
|
||||
return Environment(Env.SubExprBindings, F.Remove(Env.BlkExprBindings, E));
|
||||
}
|
||||
|
||||
Environment RemoveSubExpr(const Environment& Env, Stmt* E) {
|
||||
Environment RemoveSubExpr(const Environment& Env, const Stmt* E) {
|
||||
return Environment(F.Remove(Env.SubExprBindings, E), Env.BlkExprBindings);
|
||||
}
|
||||
|
||||
Environment AddBlkExpr(const Environment& Env, Stmt* E, SVal V) {
|
||||
Environment AddBlkExpr(const Environment& Env, const Stmt *E, SVal V) {
|
||||
return Environment(Env.SubExprBindings, F.Add(Env.BlkExprBindings, E, V));
|
||||
}
|
||||
|
||||
Environment AddSubExpr(const Environment& Env, Stmt* E, SVal V) {
|
||||
Environment AddSubExpr(const Environment& Env, const Stmt *E, SVal V) {
|
||||
return Environment(F.Add(Env.SubExprBindings, E, V), Env.BlkExprBindings);
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ public:
|
|||
return Environment(F.GetEmptyMap(), F.GetEmptyMap());
|
||||
}
|
||||
|
||||
Environment BindExpr(const Environment& Env, Stmt* E, SVal V,
|
||||
Environment BindExpr(const Environment& Env, const Stmt* E, SVal V,
|
||||
bool isBlkExpr, bool Invalidate);
|
||||
|
||||
Environment
|
||||
|
|
|
@ -202,10 +202,10 @@ public:
|
|||
// Binding and retrieving values to/from the environment and symbolic store.
|
||||
//==---------------------------------------------------------------------==//
|
||||
|
||||
const GRState *bindExpr(Stmt* Ex, SVal V, bool isBlkExpr,
|
||||
const GRState *bindExpr(const Stmt* Ex, SVal V, bool isBlkExpr,
|
||||
bool Invalidate) const;
|
||||
|
||||
const GRState *bindExpr(Stmt* Ex, SVal V, bool Invalidate = true) const;
|
||||
const GRState *bindExpr(const Stmt* Ex, SVal V, bool Invalidate = true) const;
|
||||
|
||||
const GRState *bindLoc(Loc location, SVal V) const;
|
||||
|
||||
|
@ -217,11 +217,11 @@ public:
|
|||
|
||||
const llvm::APSInt *getSymVal(SymbolRef sym) const;
|
||||
|
||||
SVal getSVal(Expr* Ex) const;
|
||||
SVal getSVal(const Stmt* Ex) const;
|
||||
|
||||
SVal getBlkExprSVal(Expr* Ex) const;
|
||||
SVal getBlkExprSVal(const Stmt* Ex) const;
|
||||
|
||||
SVal getSValAsScalarOrLoc(const Expr *Ex) const;
|
||||
SVal getSValAsScalarOrLoc(const Stmt *Ex) const;
|
||||
|
||||
SVal getSVal(Loc LV, QualType T = QualType()) const;
|
||||
|
||||
|
@ -511,6 +511,7 @@ public:
|
|||
return StoreMgr->getSelfRegion(state->getStore());
|
||||
}
|
||||
|
||||
private:
|
||||
// Get the lvalue for a variable reference.
|
||||
SVal GetLValue(const GRState* St, const VarDecl* D) {
|
||||
return StoreMgr->getLValueVar(St, D);
|
||||
|
@ -541,8 +542,7 @@ public:
|
|||
}
|
||||
|
||||
// Methods that query & manipulate the Environment.
|
||||
|
||||
SVal GetSVal(const GRState* St, Stmt* Ex) {
|
||||
SVal GetSVal(const GRState* St, const Stmt* Ex) {
|
||||
return St->getEnvironment().GetSVal(Ex, getBasicVals());
|
||||
}
|
||||
|
||||
|
@ -556,16 +556,11 @@ public:
|
|||
return UnknownVal();
|
||||
}
|
||||
|
||||
|
||||
SVal GetSVal(const GRState* St, const Stmt* Ex) {
|
||||
return St->getEnvironment().GetSVal(const_cast<Stmt*>(Ex), getBasicVals());
|
||||
}
|
||||
|
||||
SVal GetBlkExprSVal(const GRState* St, Stmt* Ex) {
|
||||
SVal GetBlkExprSVal(const GRState* St, const Stmt* Ex) {
|
||||
return St->getEnvironment().GetBlkExprSVal(Ex, getBasicVals());
|
||||
}
|
||||
|
||||
const GRState* BindExpr(const GRState* St, Stmt* Ex, SVal V,
|
||||
const GRState* BindExpr(const GRState* St, const Stmt* Ex, SVal V,
|
||||
bool isBlkExpr, bool Invalidate) {
|
||||
|
||||
const Environment& OldEnv = St->getEnvironment();
|
||||
|
@ -579,7 +574,7 @@ public:
|
|||
return getPersistentState(NewSt);
|
||||
}
|
||||
|
||||
const GRState* BindExpr(const GRState* St, Stmt* Ex, SVal V,
|
||||
const GRState* BindExpr(const GRState* St, const Stmt* Ex, SVal V,
|
||||
bool Invalidate = true) {
|
||||
|
||||
bool isBlkExpr = false;
|
||||
|
@ -596,6 +591,8 @@ public:
|
|||
return BindExpr(St, Ex, V, isBlkExpr, Invalidate);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
SVal ArrayToPointer(Loc Array) {
|
||||
return StoreMgr->ArrayToPointer(Array);
|
||||
}
|
||||
|
@ -743,12 +740,12 @@ inline const GRState *GRState::assumeInBound(SVal Idx, SVal UpperBound,
|
|||
return Mgr->ConstraintMgr->AssumeInBound(this, Idx, UpperBound, Assumption);
|
||||
}
|
||||
|
||||
inline const GRState *GRState::bindExpr(Stmt* Ex, SVal V, bool isBlkExpr,
|
||||
inline const GRState *GRState::bindExpr(const Stmt* Ex, SVal V, bool isBlkExpr,
|
||||
bool Invalidate) const {
|
||||
return Mgr->BindExpr(this, Ex, V, isBlkExpr, Invalidate);
|
||||
}
|
||||
|
||||
inline const GRState *GRState::bindExpr(Stmt* Ex, SVal V,
|
||||
inline const GRState *GRState::bindExpr(const Stmt* Ex, SVal V,
|
||||
bool Invalidate) const {
|
||||
return Mgr->BindExpr(this, Ex, V, Invalidate);
|
||||
}
|
||||
|
@ -769,15 +766,15 @@ inline const llvm::APSInt *GRState::getSymVal(SymbolRef sym) const {
|
|||
return Mgr->getSymVal(this, sym);
|
||||
}
|
||||
|
||||
inline SVal GRState::getSVal(Expr* Ex) const {
|
||||
inline SVal GRState::getSVal(const Stmt* Ex) const {
|
||||
return Mgr->GetSVal(this, Ex);
|
||||
}
|
||||
|
||||
inline SVal GRState::getBlkExprSVal(Expr* Ex) const {
|
||||
inline SVal GRState::getBlkExprSVal(const Stmt* Ex) const {
|
||||
return Mgr->GetBlkExprSVal(this, Ex);
|
||||
}
|
||||
|
||||
inline SVal GRState::getSValAsScalarOrLoc(const Expr *Ex) const {
|
||||
inline SVal GRState::getSValAsScalarOrLoc(const Stmt *Ex) const {
|
||||
return Mgr->GetSValAsScalarOrLoc(this, Ex);
|
||||
}
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ public:
|
|||
|
||||
static NonLoc MakeVal(BasicValueFactory& BasicVals, uint64_t X, QualType T);
|
||||
|
||||
static NonLoc MakeVal(BasicValueFactory& BasicVals, IntegerLiteral* I);
|
||||
static NonLoc MakeVal(BasicValueFactory& BasicVals, const IntegerLiteral *I);
|
||||
|
||||
static NonLoc MakeVal(BasicValueFactory& BasicVals, const llvm::APInt& I,
|
||||
bool isUnsigned);
|
||||
|
@ -212,7 +212,7 @@ public:
|
|||
|
||||
static Loc MakeVal(const MemRegion* R);
|
||||
|
||||
static Loc MakeVal(AddrLabelExpr* E);
|
||||
static Loc MakeVal(const AddrLabelExpr* E);
|
||||
|
||||
static Loc MakeNull(BasicValueFactory &BasicVals);
|
||||
|
||||
|
|
|
@ -66,9 +66,6 @@ class VISIBILITY_HIDDEN BasicObjCFoundationChecks : public GRSimpleAPICheck {
|
|||
APIMisuse *BT;
|
||||
BugReporter& BR;
|
||||
ASTContext &Ctx;
|
||||
GRStateManager* VMgr;
|
||||
|
||||
SVal GetSVal(const GRState* St, Expr* E) { return VMgr->GetSVal(St, E); }
|
||||
|
||||
bool isNSString(ObjCInterfaceType* T, const char* suffix);
|
||||
bool AuditNSString(NodeTy* N, ObjCMessageExpr* ME);
|
||||
|
@ -79,9 +76,8 @@ class VISIBILITY_HIDDEN BasicObjCFoundationChecks : public GRSimpleAPICheck {
|
|||
bool CheckNilArg(NodeTy* N, unsigned Arg);
|
||||
|
||||
public:
|
||||
BasicObjCFoundationChecks(ASTContext& ctx, GRStateManager* vmgr,
|
||||
BugReporter& br)
|
||||
: BT(0), BR(br), Ctx(ctx), VMgr(vmgr) {}
|
||||
BasicObjCFoundationChecks(ASTContext& ctx, BugReporter& br)
|
||||
: BT(0), BR(br), Ctx(ctx) {}
|
||||
|
||||
bool Audit(ExplodedNode<GRState>* N, GRStateManager&);
|
||||
|
||||
|
@ -106,10 +102,8 @@ private:
|
|||
|
||||
|
||||
GRSimpleAPICheck*
|
||||
clang::CreateBasicObjCFoundationChecks(ASTContext& Ctx,
|
||||
GRStateManager* VMgr, BugReporter& BR) {
|
||||
|
||||
return new BasicObjCFoundationChecks(Ctx, VMgr, BR);
|
||||
clang::CreateBasicObjCFoundationChecks(ASTContext& Ctx, BugReporter& BR) {
|
||||
return new BasicObjCFoundationChecks(Ctx, BR);
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,7 +151,7 @@ bool BasicObjCFoundationChecks::CheckNilArg(NodeTy* N, unsigned Arg) {
|
|||
|
||||
Expr * E = ME->getArg(Arg);
|
||||
|
||||
if (isNil(GetSVal(N->getState(), E))) {
|
||||
if (isNil(N->getState()->getSVal(E))) {
|
||||
WarnNilArg(N, ME, Arg);
|
||||
return true;
|
||||
}
|
||||
|
@ -259,14 +253,11 @@ class VISIBILITY_HIDDEN AuditCFNumberCreate : public GRSimpleAPICheck {
|
|||
// approach makes this class more stateless.
|
||||
ASTContext& Ctx;
|
||||
IdentifierInfo* II;
|
||||
GRStateManager* VMgr;
|
||||
BugReporter& BR;
|
||||
|
||||
SVal GetSVal(const GRState* St, Expr* E) { return VMgr->GetSVal(St, E); }
|
||||
|
||||
public:
|
||||
AuditCFNumberCreate(ASTContext& ctx, GRStateManager* vmgr, BugReporter& br)
|
||||
: BT(0), Ctx(ctx), II(&Ctx.Idents.get("CFNumberCreate")), VMgr(vmgr), BR(br){}
|
||||
AuditCFNumberCreate(ASTContext& ctx, BugReporter& br)
|
||||
: BT(0), Ctx(ctx), II(&Ctx.Idents.get("CFNumberCreate")), BR(br){}
|
||||
|
||||
~AuditCFNumberCreate() {}
|
||||
|
||||
|
@ -374,14 +365,14 @@ static const char* GetCFNumberTypeStr(uint64_t i) {
|
|||
bool AuditCFNumberCreate::Audit(ExplodedNode<GRState>* N,GRStateManager&){
|
||||
CallExpr* CE = cast<CallExpr>(cast<PostStmt>(N->getLocation()).getStmt());
|
||||
Expr* Callee = CE->getCallee();
|
||||
SVal CallV = GetSVal(N->getState(), Callee);
|
||||
SVal CallV = N->getState()->getSVal(Callee);
|
||||
const FunctionDecl* FD = CallV.getAsFunctionDecl();
|
||||
|
||||
if (!FD || FD->getIdentifier() != II || CE->getNumArgs()!=3)
|
||||
return false;
|
||||
|
||||
// Get the value of the "theType" argument.
|
||||
SVal TheTypeVal = GetSVal(N->getState(), CE->getArg(1));
|
||||
SVal TheTypeVal = N->getState()->getSVal(CE->getArg(1));
|
||||
|
||||
// FIXME: We really should allow ranges of valid theType values, and
|
||||
// bifurcate the state appropriately.
|
||||
|
@ -400,7 +391,7 @@ bool AuditCFNumberCreate::Audit(ExplodedNode<GRState>* N,GRStateManager&){
|
|||
// Look at the value of the integer being passed by reference. Essentially
|
||||
// we want to catch cases where the value passed in is not equal to the
|
||||
// size of the type being created.
|
||||
SVal TheValueExpr = GetSVal(N->getState(), CE->getArg(2));
|
||||
SVal TheValueExpr = N->getState()->getSVal(CE->getArg(2));
|
||||
|
||||
// FIXME: Eventually we should handle arbitrary locations. We can do this
|
||||
// by having an enhanced memory model that does low-level typing.
|
||||
|
@ -469,9 +460,8 @@ void AuditCFNumberCreate::AddError(const TypedRegion* R, Expr* Ex,
|
|||
}
|
||||
|
||||
GRSimpleAPICheck*
|
||||
clang::CreateAuditCFNumberCreate(ASTContext& Ctx,
|
||||
GRStateManager* VMgr, BugReporter& BR) {
|
||||
return new AuditCFNumberCreate(Ctx, VMgr, BR);
|
||||
clang::CreateAuditCFNumberCreate(ASTContext& Ctx, BugReporter& BR) {
|
||||
return new AuditCFNumberCreate(Ctx, BR);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -479,13 +469,12 @@ clang::CreateAuditCFNumberCreate(ASTContext& Ctx,
|
|||
|
||||
void clang::RegisterAppleChecks(GRExprEngine& Eng) {
|
||||
ASTContext& Ctx = Eng.getContext();
|
||||
GRStateManager* VMgr = &Eng.getStateManager();
|
||||
BugReporter &BR = Eng.getBugReporter();
|
||||
|
||||
Eng.AddCheck(CreateBasicObjCFoundationChecks(Ctx, VMgr, BR),
|
||||
Eng.AddCheck(CreateBasicObjCFoundationChecks(Ctx, BR),
|
||||
Stmt::ObjCMessageExprClass);
|
||||
|
||||
Eng.AddCheck(CreateAuditCFNumberCreate(Ctx, VMgr, BR),
|
||||
Eng.AddCheck(CreateAuditCFNumberCreate(Ctx, BR),
|
||||
Stmt::CallExprClass);
|
||||
|
||||
RegisterNSErrorChecks(BR, Eng);
|
||||
|
|
|
@ -33,11 +33,9 @@ class BugReporter;
|
|||
class GRExprEngine;
|
||||
|
||||
GRSimpleAPICheck* CreateBasicObjCFoundationChecks(ASTContext& Ctx,
|
||||
GRStateManager* VMgr,
|
||||
BugReporter& BR);
|
||||
|
||||
GRSimpleAPICheck* CreateAuditCFNumberCreate(ASTContext& Ctx,
|
||||
GRStateManager* VMgr,
|
||||
BugReporter& BR);
|
||||
|
||||
void RegisterNSErrorChecks(BugReporter& BR, GRExprEngine &Eng);
|
||||
|
|
|
@ -336,7 +336,7 @@ GetMostRecentVarDeclBinding(const ExplodedNode<GRState>* N,
|
|||
if (!DR)
|
||||
continue;
|
||||
|
||||
SVal Y = VMgr.GetSVal(N->getState(), DR);
|
||||
SVal Y = N->getState()->getSVal(DR);
|
||||
|
||||
if (X != Y)
|
||||
continue;
|
||||
|
|
|
@ -3056,7 +3056,7 @@ void CFRefCount::EvalObjCMessageExpr(ExplodedNodeSet<GRState>& Dst,
|
|||
// FIXME: Is this really working as expected? There are cases where
|
||||
// we just use the 'ID' from the message expression.
|
||||
const GRState* St = Builder.GetState(Pred);
|
||||
SVal V = Eng.getStateManager().GetSValAsScalarOrLoc(St, Receiver);
|
||||
SVal V = St->getSValAsScalarOrLoc(Receiver);
|
||||
|
||||
SymbolRef Sym = V.getAsLocSymbol();
|
||||
if (Sym) {
|
||||
|
@ -3089,7 +3089,7 @@ void CFRefCount::EvalObjCMessageExpr(ExplodedNodeSet<GRState>& Dst,
|
|||
// This is a hack. When we have full-IP this should be removed.
|
||||
if (isa<ObjCMethodDecl>(&Eng.getGraph().getCodeDecl())) {
|
||||
if (Expr* Receiver = ME->getReceiver()) {
|
||||
SVal X = Eng.getStateManager().GetSValAsScalarOrLoc(St, Receiver);
|
||||
SVal X = St->getSValAsScalarOrLoc(Receiver);
|
||||
if (loc::MemRegionVal* L = dyn_cast<loc::MemRegionVal>(&X))
|
||||
if (L->getRegion() == Eng.getStateManager().getSelfRegion(St)) {
|
||||
// Update the summary to make the default argument effect
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
using namespace clang;
|
||||
|
||||
SVal Environment::GetSVal(Stmt* E, BasicValueFactory& BasicVals) const {
|
||||
SVal Environment::GetSVal(const Stmt *E, BasicValueFactory& BasicVals) const {
|
||||
|
||||
for (;;) {
|
||||
|
||||
|
@ -34,7 +34,7 @@ SVal Environment::GetSVal(Stmt* E, BasicValueFactory& BasicVals) const {
|
|||
continue;
|
||||
|
||||
case Stmt::CharacterLiteralClass: {
|
||||
CharacterLiteral* C = cast<CharacterLiteral>(E);
|
||||
const CharacterLiteral* C = cast<CharacterLiteral>(E);
|
||||
return NonLoc::MakeVal(BasicVals, C->getValue(), C->getType());
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ SVal Environment::GetSVal(Stmt* E, BasicValueFactory& BasicVals) const {
|
|||
|
||||
case Stmt::ImplicitCastExprClass:
|
||||
case Stmt::CStyleCastExprClass: {
|
||||
CastExpr* C = cast<CastExpr>(E);
|
||||
const CastExpr* C = cast<CastExpr>(E);
|
||||
QualType CT = C->getType();
|
||||
|
||||
if (CT->isVoidType())
|
||||
|
@ -69,7 +69,8 @@ SVal Environment::GetSVal(Stmt* E, BasicValueFactory& BasicVals) const {
|
|||
return LookupExpr(E);
|
||||
}
|
||||
|
||||
SVal Environment::GetBlkExprSVal(Stmt* E, BasicValueFactory& BasicVals) const {
|
||||
SVal Environment::GetBlkExprSVal(const Stmt *E,
|
||||
BasicValueFactory& BasicVals) const {
|
||||
|
||||
while (1) {
|
||||
switch (E->getStmtClass()) {
|
||||
|
@ -78,7 +79,7 @@ SVal Environment::GetBlkExprSVal(Stmt* E, BasicValueFactory& BasicVals) const {
|
|||
continue;
|
||||
|
||||
case Stmt::CharacterLiteralClass: {
|
||||
CharacterLiteral* C = cast<CharacterLiteral>(E);
|
||||
const CharacterLiteral* C = cast<CharacterLiteral>(E);
|
||||
return NonLoc::MakeVal(BasicVals, C->getValue(), C->getType());
|
||||
}
|
||||
|
||||
|
@ -92,8 +93,9 @@ SVal Environment::GetBlkExprSVal(Stmt* E, BasicValueFactory& BasicVals) const {
|
|||
}
|
||||
}
|
||||
|
||||
Environment EnvironmentManager::BindExpr(const Environment& Env, Stmt* E,SVal V,
|
||||
bool isBlkExpr, bool Invalidate) {
|
||||
Environment EnvironmentManager::BindExpr(const Environment& Env, const Stmt* E,
|
||||
SVal V, bool isBlkExpr,
|
||||
bool Invalidate) {
|
||||
assert (E);
|
||||
|
||||
if (V.isUnknown()) {
|
||||
|
@ -136,7 +138,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) {
|
||||
Stmt* BlkExpr = I.getKey();
|
||||
const Stmt *BlkExpr = I.getKey();
|
||||
|
||||
if (SymReaper.isLive(Loc, BlkExpr)) {
|
||||
SVal X = I.getData();
|
||||
|
|
|
@ -644,7 +644,7 @@ static SVal RecoverCastedSymbol(GRStateManager& StateMgr, const GRState* state,
|
|||
if (!bitsInit || !T->isIntegerType() || Ctx.getTypeSize(T) > bits)
|
||||
return UnknownVal();
|
||||
|
||||
return StateMgr.GetSVal(state, Ex);
|
||||
return state->getSVal(Ex);
|
||||
}
|
||||
|
||||
void GRExprEngine::ProcessBranch(Stmt* Condition, Stmt* Term,
|
||||
|
@ -1284,10 +1284,9 @@ static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet<GRState>& Dst,
|
|||
const void *OSAtomicStoreTag = &magic_store;
|
||||
|
||||
// Load 'theValue'.
|
||||
GRStateManager &StateMgr = Engine.getStateManager();
|
||||
const GRState *state = Pred->getState();
|
||||
ExplodedNodeSet<GRState> Tmp;
|
||||
SVal location = StateMgr.GetSVal(state, theValueExpr);
|
||||
SVal location = state->getSVal(theValueExpr);
|
||||
Engine.EvalLoad(Tmp, theValueExpr, Pred, state, location, OSAtomicLoadTag);
|
||||
|
||||
for (ExplodedNodeSet<GRState>::iterator I = Tmp.begin(), E = Tmp.end();
|
||||
|
@ -1310,8 +1309,7 @@ static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet<GRState>& Dst,
|
|||
// Perform the store.
|
||||
ExplodedNodeSet<GRState> TmpStore;
|
||||
Engine.EvalStore(TmpStore, theValueExpr, N, stateEqual, location,
|
||||
StateMgr.GetSVal(stateEqual, newValueExpr),
|
||||
OSAtomicStoreTag);
|
||||
stateEqual->getSVal(newValueExpr), OSAtomicStoreTag);
|
||||
|
||||
// Now bind the result of the comparison.
|
||||
for (ExplodedNodeSet<GRState>::iterator I2 = TmpStore.begin(),
|
||||
|
|
|
@ -347,9 +347,7 @@ public:
|
|||
assert (E && "Return expression cannot be NULL");
|
||||
|
||||
// Get the value associated with E.
|
||||
loc::MemRegionVal V =
|
||||
cast<loc::MemRegionVal>(Eng.getStateManager().GetSVal(N->getState(),
|
||||
E));
|
||||
loc::MemRegionVal V = cast<loc::MemRegionVal>(N->getState()->getSVal(E));
|
||||
|
||||
// Generate a report for this bug.
|
||||
std::string buf;
|
||||
|
@ -427,7 +425,7 @@ class VISIBILITY_HIDDEN UndefBranch : public BuiltinBug {
|
|||
return Ex;
|
||||
}
|
||||
|
||||
bool MatchesCriteria(Expr* Ex) { return VM.GetSVal(St, Ex).isUndef(); }
|
||||
bool MatchesCriteria(Expr* Ex) { return St->getSVal(Ex).isUndef(); }
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -519,8 +517,7 @@ public:
|
|||
"variable-length array (VLA) '"
|
||||
<< VD->getNameAsString() << "' evaluates to ";
|
||||
|
||||
bool isUndefined = Eng.getStateManager().GetSVal(N->getState(),
|
||||
SizeExpr).isUndef();
|
||||
bool isUndefined = N->getState()->getSVal(SizeExpr).isUndef();
|
||||
|
||||
if (isUndefined)
|
||||
os << "an undefined or garbage value.";
|
||||
|
@ -563,7 +560,7 @@ public:
|
|||
CallExpr* CE = cast<CallExpr>(cast<PostStmt>(N->getLocation()).getStmt());
|
||||
const GRState* state = N->getState();
|
||||
|
||||
SVal X = VMgr.GetSVal(state, CE->getCallee());
|
||||
SVal X = state->getSVal(CE->getCallee());
|
||||
|
||||
const FunctionDecl* FD = X.getAsFunctionDecl();
|
||||
if (!FD)
|
||||
|
@ -888,7 +885,7 @@ static void registerTrackNullOrUndefValue(BugReporterContext& BRC,
|
|||
StateMgr.getRegionManager().getVarRegion(VD);
|
||||
|
||||
// What did we load?
|
||||
SVal V = StateMgr.GetSVal(state, S);
|
||||
SVal V = state->getSVal(S);
|
||||
|
||||
if (isa<loc::ConcreteInt>(V) || isa<nonloc::ConcreteInt>(V)
|
||||
|| V.isUndef()) {
|
||||
|
@ -897,7 +894,7 @@ static void registerTrackNullOrUndefValue(BugReporterContext& BRC,
|
|||
}
|
||||
}
|
||||
|
||||
SVal V = StateMgr.GetSValAsScalarOrLoc(state, S);
|
||||
SVal V = state->getSValAsScalarOrLoc(S);
|
||||
|
||||
// Uncomment this to find cases where we aren't properly getting the
|
||||
// base value that was dereferenced.
|
||||
|
|
|
@ -363,7 +363,7 @@ void GRSimpleVals::EvalCall(ExplodedNodeSet<GRState>& Dst,
|
|||
for (CallExpr::arg_iterator I = CE->arg_begin(), E = CE->arg_end();
|
||||
I != E; ++I) {
|
||||
|
||||
SVal V = StateMgr.GetSVal(St, *I);
|
||||
SVal V = St->getSVal(*I);
|
||||
|
||||
if (isa<loc::MemRegionVal>(V)) {
|
||||
const MemRegion *R = cast<loc::MemRegionVal>(V).getRegion();
|
||||
|
@ -382,7 +382,7 @@ void GRSimpleVals::EvalCall(ExplodedNodeSet<GRState>& Dst,
|
|||
if (Loc::IsLocType(T) || (T->isIntegerType() && T->isScalarType())) {
|
||||
unsigned Count = Builder.getCurrentBlockCount();
|
||||
SVal X = Eng.getValueManager().getConjuredSymbolVal(CE, Count);
|
||||
St = StateMgr.BindExpr(St, CE, X, Eng.getCFG().isBlkExpr(CE), false);
|
||||
St = St->bindExpr(CE, X, Eng.getCFG().isBlkExpr(CE), false);
|
||||
}
|
||||
|
||||
Builder.MakeNode(Dst, CE, Pred, St);
|
||||
|
@ -401,17 +401,15 @@ void GRSimpleVals::EvalObjCMessageExpr(ExplodedNodeSet<GRState>& Dst,
|
|||
|
||||
// The basic transfer function logic for message expressions does nothing.
|
||||
// We just invalidate all arguments passed in by references.
|
||||
|
||||
GRStateManager& StateMgr = Eng.getStateManager();
|
||||
const GRState *St = Builder.GetState(Pred);
|
||||
|
||||
for (ObjCMessageExpr::arg_iterator I = ME->arg_begin(), E = ME->arg_end();
|
||||
I != E; ++I) {
|
||||
|
||||
SVal V = StateMgr.GetSVal(St, *I);
|
||||
SVal V = St->getSVal(*I);
|
||||
|
||||
if (isa<Loc>(V))
|
||||
St = StateMgr.BindLoc(St, cast<Loc>(V), UnknownVal());
|
||||
St = St->bindLoc(cast<Loc>(V), UnknownVal());
|
||||
}
|
||||
|
||||
Builder.MakeNode(Dst, ME, Pred, St);
|
||||
|
|
|
@ -23,6 +23,5 @@ void GRTransferFuncs::EvalBinOpNN(GRStateSet& OStates,
|
|||
BinaryOperator::Opcode Op,
|
||||
NonLoc L, NonLoc R, QualType T) {
|
||||
|
||||
OStates.Add(Eng.getStateManager().BindExpr(St, Ex,
|
||||
DetermEvalBinOpNN(Eng, Op, L, R, T)));
|
||||
OStates.Add(St->bindExpr(Ex, DetermEvalBinOpNN(Eng, Op, L, R, T)));
|
||||
}
|
||||
|
|
|
@ -294,7 +294,7 @@ NonLoc NonLoc::MakeVal(BasicValueFactory& BasicVals, uint64_t X, QualType T) {
|
|||
return nonloc::ConcreteInt(BasicVals.getValue(X, T));
|
||||
}
|
||||
|
||||
NonLoc NonLoc::MakeVal(BasicValueFactory& BasicVals, IntegerLiteral* I) {
|
||||
NonLoc NonLoc::MakeVal(BasicValueFactory& BasicVals, const IntegerLiteral* I) {
|
||||
|
||||
return nonloc::ConcreteInt(BasicVals.getValue(APSInt(I->getValue(),
|
||||
I->getType()->isUnsignedIntegerType())));
|
||||
|
@ -402,7 +402,9 @@ nonloc::LocAsInteger nonloc::LocAsInteger::Make(BasicValueFactory& Vals, Loc V,
|
|||
|
||||
Loc Loc::MakeVal(const MemRegion* R) { return loc::MemRegionVal(R); }
|
||||
|
||||
Loc Loc::MakeVal(AddrLabelExpr* E) { return loc::GotoLabel(E->getLabel()); }
|
||||
Loc Loc::MakeVal(const AddrLabelExpr *E) {
|
||||
return loc::GotoLabel(E->getLabel());
|
||||
}
|
||||
|
||||
Loc Loc::MakeNull(BasicValueFactory &BasicVals) {
|
||||
return loc::ConcreteInt(BasicVals.getZeroWithPtrWidth());
|
||||
|
|
Загрузка…
Ссылка в новой задаче