From: Ted Kremenek Date: Thu, 18 Jun 2009 23:58:37 +0000 (+0000) Subject: Move clients over from using GRStateManager::BindXXX and friends to X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=23ec48cd3369c8d7d1ab3c3f2226cfcffd2cd3d3;p=clang 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 --- diff --git a/include/clang/Analysis/PathSensitive/Environment.h b/include/clang/Analysis/PathSensitive/Environment.h index f94792a0cb..0fc49f5a58 100644 --- a/include/clang/Analysis/PathSensitive/Environment.h +++ b/include/clang/Analysis/PathSensitive/Environment.h @@ -35,7 +35,7 @@ private: friend class EnvironmentManager; // Type definitions. - typedef llvm::ImmutableMap BindingsTy; + typedef llvm::ImmutableMap 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(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 diff --git a/include/clang/Analysis/PathSensitive/GRState.h b/include/clang/Analysis/PathSensitive/GRState.h index 5c151efc34..57963ab816 100644 --- a/include/clang/Analysis/PathSensitive/GRState.h +++ b/include/clang/Analysis/PathSensitive/GRState.h @@ -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); @@ -540,9 +541,8 @@ public: return StoreMgr->getLValueElement(St, ElementType, Base, Idx); } - // Methods that query & manipulate the Environment. - - SVal GetSVal(const GRState* St, Stmt* Ex) { + // Methods that query & manipulate the Environment. + SVal GetSVal(const GRState* St, const Stmt* Ex) { return St->getEnvironment().GetSVal(Ex, getBasicVals()); } @@ -555,17 +555,12 @@ public: return UnknownVal(); } - - SVal GetSVal(const GRState* St, const Stmt* Ex) { - return St->getEnvironment().GetSVal(const_cast(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, - bool Invalidate) const { +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); } diff --git a/include/clang/Analysis/PathSensitive/SVals.h b/include/clang/Analysis/PathSensitive/SVals.h index ee6d4dcf1f..c9d1e25da7 100644 --- a/include/clang/Analysis/PathSensitive/SVals.h +++ b/include/clang/Analysis/PathSensitive/SVals.h @@ -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); diff --git a/lib/Analysis/BasicObjCFoundationChecks.cpp b/lib/Analysis/BasicObjCFoundationChecks.cpp index 98e9551d4b..aa85769157 100644 --- a/lib/Analysis/BasicObjCFoundationChecks.cpp +++ b/lib/Analysis/BasicObjCFoundationChecks.cpp @@ -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* 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* N,GRStateManager&){ CallExpr* CE = cast(cast(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* 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); diff --git a/lib/Analysis/BasicObjCFoundationChecks.h b/lib/Analysis/BasicObjCFoundationChecks.h index 6c594ea721..5c9701ecdd 100644 --- a/lib/Analysis/BasicObjCFoundationChecks.h +++ b/lib/Analysis/BasicObjCFoundationChecks.h @@ -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); diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp index 32998e1c42..5dbbfc33e4 100644 --- a/lib/Analysis/BugReporter.cpp +++ b/lib/Analysis/BugReporter.cpp @@ -336,7 +336,7 @@ GetMostRecentVarDeclBinding(const ExplodedNode* N, if (!DR) continue; - SVal Y = VMgr.GetSVal(N->getState(), DR); + SVal Y = N->getState()->getSVal(DR); if (X != Y) continue; diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp index 9cdc769431..c58ceb4193 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -3056,7 +3056,7 @@ void CFRefCount::EvalObjCMessageExpr(ExplodedNodeSet& 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& Dst, // This is a hack. When we have full-IP this should be removed. if (isa(&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(&X)) if (L->getRegion() == Eng.getStateManager().getSelfRegion(St)) { // Update the summary to make the default argument effect diff --git a/lib/Analysis/Environment.cpp b/lib/Analysis/Environment.cpp index 1276cbf1d3..7ada6d809b 100644 --- a/lib/Analysis/Environment.cpp +++ b/lib/Analysis/Environment.cpp @@ -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(E); + const CharacterLiteral* C = cast(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(E); + const CastExpr* C = cast(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(E); + const CharacterLiteral* C = cast(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(); diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index c43c83b259..728ac93f63 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -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& Dst, const void *OSAtomicStoreTag = &magic_store; // Load 'theValue'. - GRStateManager &StateMgr = Engine.getStateManager(); const GRState *state = Pred->getState(); ExplodedNodeSet Tmp; - SVal location = StateMgr.GetSVal(state, theValueExpr); + SVal location = state->getSVal(theValueExpr); Engine.EvalLoad(Tmp, theValueExpr, Pred, state, location, OSAtomicLoadTag); for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); @@ -1310,8 +1309,7 @@ static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet& Dst, // Perform the store. ExplodedNodeSet 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::iterator I2 = TmpStore.begin(), diff --git a/lib/Analysis/GRExprEngineInternalChecks.cpp b/lib/Analysis/GRExprEngineInternalChecks.cpp index 838cb9867b..7f7270d40d 100644 --- a/lib/Analysis/GRExprEngineInternalChecks.cpp +++ b/lib/Analysis/GRExprEngineInternalChecks.cpp @@ -347,9 +347,7 @@ public: assert (E && "Return expression cannot be NULL"); // Get the value associated with E. - loc::MemRegionVal V = - cast(Eng.getStateManager().GetSVal(N->getState(), - E)); + loc::MemRegionVal V = cast(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(cast(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(V) || isa(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. diff --git a/lib/Analysis/GRSimpleVals.cpp b/lib/Analysis/GRSimpleVals.cpp index d8d312f23f..7e54f1ad68 100644 --- a/lib/Analysis/GRSimpleVals.cpp +++ b/lib/Analysis/GRSimpleVals.cpp @@ -363,7 +363,7 @@ void GRSimpleVals::EvalCall(ExplodedNodeSet& 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(V)) { const MemRegion *R = cast(V).getRegion(); @@ -382,7 +382,7 @@ void GRSimpleVals::EvalCall(ExplodedNodeSet& 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); @@ -400,18 +400,16 @@ void GRSimpleVals::EvalObjCMessageExpr(ExplodedNodeSet& 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); + // We just invalidate all arguments passed in by references. + 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(V)) - St = StateMgr.BindLoc(St, cast(V), UnknownVal()); + St = St->bindLoc(cast(V), UnknownVal()); } Builder.MakeNode(Dst, ME, Pred, St); diff --git a/lib/Analysis/GRTransferFuncs.cpp b/lib/Analysis/GRTransferFuncs.cpp index 69c09d9a2e..3c14ee9ab5 100644 --- a/lib/Analysis/GRTransferFuncs.cpp +++ b/lib/Analysis/GRTransferFuncs.cpp @@ -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))); } diff --git a/lib/Analysis/SVals.cpp b/lib/Analysis/SVals.cpp index 285d51e506..37f9ac7cad 100644 --- a/lib/Analysis/SVals.cpp +++ b/lib/Analysis/SVals.cpp @@ -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());