diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/BasicConstraintManager.cpp | 64 | ||||
-rw-r--r-- | lib/Analysis/BasicObjCFoundationChecks.cpp | 22 | ||||
-rw-r--r-- | lib/Analysis/BasicStore.cpp | 122 | ||||
-rw-r--r-- | lib/Analysis/BasicValueFactory.cpp | 48 | ||||
-rw-r--r-- | lib/Analysis/BugReporter.cpp | 18 | ||||
-rw-r--r-- | lib/Analysis/CFRefCount.cpp | 106 | ||||
-rw-r--r-- | lib/Analysis/CheckNSError.cpp | 10 | ||||
-rw-r--r-- | lib/Analysis/Environment.cpp | 30 | ||||
-rw-r--r-- | lib/Analysis/GRExprEngine.cpp | 258 | ||||
-rw-r--r-- | lib/Analysis/GRExprEngineInternalChecks.cpp | 12 | ||||
-rw-r--r-- | lib/Analysis/GRSimpleVals.cpp | 198 | ||||
-rw-r--r-- | lib/Analysis/GRSimpleVals.h | 28 | ||||
-rw-r--r-- | lib/Analysis/GRState.cpp | 20 | ||||
-rw-r--r-- | lib/Analysis/GRTransferFuncs.cpp | 8 | ||||
-rw-r--r-- | lib/Analysis/RValues.cpp | 244 | ||||
-rw-r--r-- | lib/Analysis/RegionStore.cpp | 18 |
16 files changed, 603 insertions, 603 deletions
diff --git a/lib/Analysis/BasicConstraintManager.cpp b/lib/Analysis/BasicConstraintManager.cpp index 8d391bbb58..aab1f5e7eb 100644 --- a/lib/Analysis/BasicConstraintManager.cpp +++ b/lib/Analysis/BasicConstraintManager.cpp @@ -33,19 +33,19 @@ class VISIBILITY_HIDDEN BasicConstraintManager : public ConstraintManager { public: BasicConstraintManager(GRStateManager& statemgr) : StateMgr(statemgr) {} - virtual const GRState* Assume(const GRState* St, RVal Cond, + virtual const GRState* Assume(const GRState* St, SVal Cond, bool Assumption, bool& isFeasible); - const GRState* Assume(const GRState* St, LVal Cond, bool Assumption, + const GRState* Assume(const GRState* St, Loc Cond, bool Assumption, bool& isFeasible); - const GRState* AssumeAux(const GRState* St, LVal Cond,bool Assumption, + const GRState* AssumeAux(const GRState* St, Loc Cond,bool Assumption, bool& isFeasible); - const GRState* Assume(const GRState* St, NonLVal Cond, bool Assumption, + const GRState* Assume(const GRState* St, NonLoc Cond, bool Assumption, bool& isFeasible); - const GRState* AssumeAux(const GRState* St, NonLVal Cond, bool Assumption, + const GRState* AssumeAux(const GRState* St, NonLoc Cond, bool Assumption, bool& isFeasible); const GRState* AssumeSymInt(const GRState* St, bool Assumption, @@ -92,52 +92,52 @@ ConstraintManager* clang::CreateBasicConstraintManager(GRStateManager& StateMgr) return new BasicConstraintManager(StateMgr); } -const GRState* BasicConstraintManager::Assume(const GRState* St, RVal Cond, +const GRState* BasicConstraintManager::Assume(const GRState* St, SVal Cond, bool Assumption, bool& isFeasible) { if (Cond.isUnknown()) { isFeasible = true; return St; } - if (isa<NonLVal>(Cond)) - return Assume(St, cast<NonLVal>(Cond), Assumption, isFeasible); + if (isa<NonLoc>(Cond)) + return Assume(St, cast<NonLoc>(Cond), Assumption, isFeasible); else - return Assume(St, cast<LVal>(Cond), Assumption, isFeasible); + return Assume(St, cast<Loc>(Cond), Assumption, isFeasible); } -const GRState* BasicConstraintManager::Assume(const GRState* St, LVal Cond, +const GRState* BasicConstraintManager::Assume(const GRState* St, Loc Cond, bool Assumption, bool& isFeasible) { St = AssumeAux(St, Cond, Assumption, isFeasible); // TF->EvalAssume(*this, St, Cond, Assumption, isFeasible) return St; } -const GRState* BasicConstraintManager::AssumeAux(const GRState* St, LVal Cond, +const GRState* BasicConstraintManager::AssumeAux(const GRState* St, Loc Cond, bool Assumption, bool& isFeasible) { BasicValueFactory& BasicVals = StateMgr.getBasicVals(); switch (Cond.getSubKind()) { default: - assert (false && "'Assume' not implemented for this LVal."); + assert (false && "'Assume' not implemented for this Loc."); return St; - case lval::SymbolValKind: + case loc::SymbolValKind: if (Assumption) - return AssumeSymNE(St, cast<lval::SymbolVal>(Cond).getSymbol(), + return AssumeSymNE(St, cast<loc::SymbolVal>(Cond).getSymbol(), BasicVals.getZeroWithPtrWidth(), isFeasible); else - return AssumeSymEQ(St, cast<lval::SymbolVal>(Cond).getSymbol(), + return AssumeSymEQ(St, cast<loc::SymbolVal>(Cond).getSymbol(), BasicVals.getZeroWithPtrWidth(), isFeasible); - case lval::MemRegionKind: - case lval::FuncValKind: - case lval::GotoLabelKind: - case lval::StringLiteralValKind: + case loc::MemRegionKind: + case loc::FuncValKind: + case loc::GotoLabelKind: + case loc::StringLiteralValKind: isFeasible = Assumption; return St; - case lval::ConcreteIntKind: { - bool b = cast<lval::ConcreteInt>(Cond).getValue() != 0; + case loc::ConcreteIntKind: { + bool b = cast<loc::ConcreteInt>(Cond).getValue() != 0; isFeasible = b ? Assumption : !Assumption; return St; } @@ -145,7 +145,7 @@ const GRState* BasicConstraintManager::AssumeAux(const GRState* St, LVal Cond, } const GRState* -BasicConstraintManager::Assume(const GRState* St, NonLVal Cond, bool Assumption, +BasicConstraintManager::Assume(const GRState* St, NonLoc Cond, bool Assumption, bool& isFeasible) { St = AssumeAux(St, Cond, Assumption, isFeasible); // TF->EvalAssume() does nothing now. @@ -153,17 +153,17 @@ BasicConstraintManager::Assume(const GRState* St, NonLVal Cond, bool Assumption, } const GRState* -BasicConstraintManager::AssumeAux(const GRState* St,NonLVal Cond, +BasicConstraintManager::AssumeAux(const GRState* St,NonLoc Cond, bool Assumption, bool& isFeasible) { BasicValueFactory& BasicVals = StateMgr.getBasicVals(); SymbolManager& SymMgr = StateMgr.getSymbolManager(); switch (Cond.getSubKind()) { default: - assert(false && "'Assume' not implemented for this NonLVal"); + assert(false && "'Assume' not implemented for this NonLoc"); - case nonlval::SymbolValKind: { - nonlval::SymbolVal& SV = cast<nonlval::SymbolVal>(Cond); + case nonloc::SymbolValKind: { + nonloc::SymbolVal& SV = cast<nonloc::SymbolVal>(Cond); SymbolID sym = SV.getSymbol(); if (Assumption) @@ -174,20 +174,20 @@ BasicConstraintManager::AssumeAux(const GRState* St,NonLVal Cond, isFeasible); } - case nonlval::SymIntConstraintValKind: + case nonloc::SymIntConstraintValKind: return AssumeSymInt(St, Assumption, - cast<nonlval::SymIntConstraintVal>(Cond).getConstraint(), + cast<nonloc::SymIntConstraintVal>(Cond).getConstraint(), isFeasible); - case nonlval::ConcreteIntKind: { - bool b = cast<nonlval::ConcreteInt>(Cond).getValue() != 0; + case nonloc::ConcreteIntKind: { + bool b = cast<nonloc::ConcreteInt>(Cond).getValue() != 0; isFeasible = b ? Assumption : !Assumption; return St; } - case nonlval::LValAsIntegerKind: - return AssumeAux(St, cast<nonlval::LValAsInteger>(Cond).getLVal(), + case nonloc::LocAsIntegerKind: + return AssumeAux(St, cast<nonloc::LocAsInteger>(Cond).getLoc(), Assumption, isFeasible); } // end switch } diff --git a/lib/Analysis/BasicObjCFoundationChecks.cpp b/lib/Analysis/BasicObjCFoundationChecks.cpp index b3f534d1af..8e322189e6 100644 --- a/lib/Analysis/BasicObjCFoundationChecks.cpp +++ b/lib/Analysis/BasicObjCFoundationChecks.cpp @@ -118,7 +118,7 @@ class VISIBILITY_HIDDEN BasicObjCFoundationChecks : public GRSimpleAPICheck { typedef std::vector<BugReport*> ErrorsTy; ErrorsTy Errors; - RVal GetRVal(const GRState* St, Expr* E) { return VMgr->GetRVal(St, E); } + 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); @@ -193,8 +193,8 @@ bool BasicObjCFoundationChecks::Audit(ExplodedNode<GRState>* N, return false; } -static inline bool isNil(RVal X) { - return isa<lval::ConcreteInt>(X); +static inline bool isNil(SVal X) { + return isa<loc::ConcreteInt>(X); } //===----------------------------------------------------------------------===// @@ -214,7 +214,7 @@ bool BasicObjCFoundationChecks::CheckNilArg(NodeTy* N, unsigned Arg) { Expr * E = ME->getArg(Arg); - if (isNil(GetRVal(N->getState(), E))) { + if (isNil(GetSVal(N->getState(), E))) { WarnNilArg(N, ME, Arg); return true; } @@ -350,7 +350,7 @@ class VISIBILITY_HIDDEN AuditCFNumberCreate : public GRSimpleAPICheck { IdentifierInfo* II; GRStateManager* VMgr; - RVal GetRVal(const GRState* St, Expr* E) { return VMgr->GetRVal(St, E); } + SVal GetSVal(const GRState* St, Expr* E) { return VMgr->GetSVal(St, E); } public: @@ -468,18 +468,18 @@ 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(); - RVal CallV = GetRVal(N->getState(), Callee); - lval::FuncVal* FuncV = dyn_cast<lval::FuncVal>(&CallV); + SVal CallV = GetSVal(N->getState(), Callee); + loc::FuncVal* FuncV = dyn_cast<loc::FuncVal>(&CallV); if (!FuncV || FuncV->getDecl()->getIdentifier() != II || CE->getNumArgs()!=3) return false; // Get the value of the "theType" argument. - RVal TheTypeVal = GetRVal(N->getState(), CE->getArg(1)); + SVal TheTypeVal = GetSVal(N->getState(), CE->getArg(1)); // FIXME: We really should allow ranges of valid theType values, and // bifurcate the state appropriately. - nonlval::ConcreteInt* V = dyn_cast<nonlval::ConcreteInt>(&TheTypeVal); + nonloc::ConcreteInt* V = dyn_cast<nonloc::ConcreteInt>(&TheTypeVal); if (!V) return false; @@ -494,11 +494,11 @@ 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. - RVal TheValueExpr = GetRVal(N->getState(), CE->getArg(2)); + SVal TheValueExpr = GetSVal(N->getState(), 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. - lval::MemRegionVal* LV = dyn_cast<lval::MemRegionVal>(&TheValueExpr); + loc::MemRegionVal* LV = dyn_cast<loc::MemRegionVal>(&TheValueExpr); if (!LV) return false; diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp index 9d8a9acda5..7998ef4613 100644 --- a/lib/Analysis/BasicStore.cpp +++ b/lib/Analysis/BasicStore.cpp @@ -19,7 +19,7 @@ using namespace clang; -typedef llvm::ImmutableMap<const VarDecl*,RVal> VarBindingsTy; +typedef llvm::ImmutableMap<const VarDecl*,SVal> VarBindingsTy; namespace { @@ -34,23 +34,23 @@ public: virtual ~BasicStoreManager() {} - virtual RVal GetRVal(Store St, LVal LV, QualType T); - virtual Store SetRVal(Store St, LVal LV, RVal V); - virtual Store Remove(Store St, LVal LV); + virtual SVal GetSVal(Store St, Loc LV, QualType T); + virtual Store SetSVal(Store St, Loc LV, SVal V); + virtual Store Remove(Store St, Loc LV); virtual Store getInitialStore(); virtual MemRegionManager& getRegionManager() { return MRMgr; } // FIXME: Investigate what is using this. This method should be removed. - virtual LVal getLVal(const VarDecl* VD) { - return lval::MemRegionVal(MRMgr.getVarRegion(VD)); + virtual Loc getLoc(const VarDecl* VD) { + return loc::MemRegionVal(MRMgr.getVarRegion(VD)); } - RVal getLValueVar(const GRState* St, const VarDecl* VD); - RVal getLValueIvar(const GRState* St, const ObjCIvarDecl* D, RVal Base); - RVal getLValueField(const GRState* St, const FieldDecl* D, RVal Base); - RVal getLValueElement(const GRState* St, RVal Base, RVal Offset); + SVal getLValueVar(const GRState* St, const VarDecl* VD); + SVal getLValueIvar(const GRState* St, const ObjCIvarDecl* D, SVal Base); + SVal getLValueField(const GRState* St, const FieldDecl* D, SVal Base); + SVal getLValueElement(const GRState* St, SVal Base, SVal Offset); virtual Store RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live, @@ -61,7 +61,7 @@ public: virtual Store AddDecl(Store store, const VarDecl* VD, Expr* Ex, - RVal InitVal = UndefinedVal(), unsigned Count = 0); + SVal InitVal = UndefinedVal(), unsigned Count = 0); static inline VarBindingsTy GetVarBindings(Store store) { return VarBindingsTy(static_cast<const VarBindingsTy::TreeTy*>(store)); @@ -78,27 +78,27 @@ public: StoreManager* clang::CreateBasicStoreManager(GRStateManager& StMgr) { return new BasicStoreManager(StMgr); } -RVal BasicStoreManager::getLValueVar(const GRState* St, const VarDecl* VD) { - return lval::MemRegionVal(MRMgr.getVarRegion(VD)); +SVal BasicStoreManager::getLValueVar(const GRState* St, const VarDecl* VD) { + return loc::MemRegionVal(MRMgr.getVarRegion(VD)); } -RVal BasicStoreManager::getLValueIvar(const GRState* St, const ObjCIvarDecl* D, - RVal Base) { +SVal BasicStoreManager::getLValueIvar(const GRState* St, const ObjCIvarDecl* D, + SVal Base) { return UnknownVal(); } -RVal BasicStoreManager::getLValueField(const GRState* St, const FieldDecl* D, - RVal Base) { +SVal BasicStoreManager::getLValueField(const GRState* St, const FieldDecl* D, + SVal Base) { return UnknownVal(); } -RVal BasicStoreManager::getLValueElement(const GRState* St, RVal Base, - RVal Offset) { +SVal BasicStoreManager::getLValueElement(const GRState* St, SVal Base, + SVal Offset) { return UnknownVal(); } -RVal BasicStoreManager::GetRVal(Store St, LVal LV, QualType T) { +SVal BasicStoreManager::GetSVal(Store St, Loc LV, QualType T) { if (isa<UnknownVal>(LV)) return UnknownVal(); @@ -107,9 +107,9 @@ RVal BasicStoreManager::GetRVal(Store St, LVal LV, QualType T) { switch (LV.getSubKind()) { - case lval::MemRegionKind: { + case loc::MemRegionKind: { VarRegion* R = - dyn_cast<VarRegion>(cast<lval::MemRegionVal>(LV).getRegion()); + dyn_cast<VarRegion>(cast<loc::MemRegionVal>(LV).getRegion()); if (!R) return UnknownVal(); @@ -119,34 +119,34 @@ RVal BasicStoreManager::GetRVal(Store St, LVal LV, QualType T) { return T ? *T : UnknownVal(); } - case lval::SymbolValKind: + case loc::SymbolValKind: return UnknownVal(); - case lval::ConcreteIntKind: - // Some clients may call GetRVal with such an option simply because - // they are doing a quick scan through their LVals (potentially to + case loc::ConcreteIntKind: + // Some clients may call GetSVal with such an option simply because + // they are doing a quick scan through their Locs (potentially to // invalidate their bindings). Just return Undefined. return UndefinedVal(); - case lval::FuncValKind: + case loc::FuncValKind: return LV; - case lval::StringLiteralValKind: + case loc::StringLiteralValKind: // FIXME: Implement better support for fetching characters from strings. return UnknownVal(); default: - assert (false && "Invalid LVal."); + assert (false && "Invalid Loc."); break; } return UnknownVal(); } -Store BasicStoreManager::SetRVal(Store store, LVal LV, RVal V) { +Store BasicStoreManager::SetSVal(Store store, Loc LV, SVal V) { switch (LV.getSubKind()) { - case lval::MemRegionKind: { + case loc::MemRegionKind: { VarRegion* R = - dyn_cast<VarRegion>(cast<lval::MemRegionVal>(LV).getRegion()); + dyn_cast<VarRegion>(cast<loc::MemRegionVal>(LV).getRegion()); if (!R) return store; @@ -157,16 +157,16 @@ Store BasicStoreManager::SetRVal(Store store, LVal LV, RVal V) { : VBFactory.Add(B, R->getDecl(), V).getRoot(); } default: - assert ("SetRVal for given LVal type not yet implemented."); + assert ("SetSVal for given Loc type not yet implemented."); return store; } } -Store BasicStoreManager::Remove(Store store, LVal LV) { +Store BasicStoreManager::Remove(Store store, Loc LV) { switch (LV.getSubKind()) { - case lval::MemRegionKind: { + case loc::MemRegionKind: { VarRegion* R = - dyn_cast<VarRegion>(cast<lval::MemRegionVal>(LV).getRegion()); + dyn_cast<VarRegion>(cast<loc::MemRegionVal>(LV).getRegion()); if (!R) return store; @@ -175,7 +175,7 @@ Store BasicStoreManager::Remove(Store store, LVal LV) { return VBFactory.Remove(B,R->getDecl()).getRoot(); } default: - assert ("Remove for given LVal type not yet implemented."); + assert ("Remove for given Loc type not yet implemented."); return store; } } @@ -187,13 +187,13 @@ BasicStoreManager::RemoveDeadBindings(Store store, Stmt* Loc, LiveSymbolsTy& LSymbols, DeadSymbolsTy& DSymbols) { VarBindingsTy B = GetVarBindings(store); - typedef RVal::symbol_iterator symbol_iterator; + typedef SVal::symbol_iterator symbol_iterator; // Iterate over the variable bindings. for (VarBindingsTy::iterator I=B.begin(), E=B.end(); I!=E ; ++I) if (Liveness.isLive(Loc, I.getKey())) { RegionRoots.push_back(MRMgr.getVarRegion(I.getKey())); - RVal X = I.getData(); + SVal X = I.getData(); for (symbol_iterator SI=X.symbol_begin(), SE=X.symbol_end(); SI!=SE; ++SI) LSymbols.insert(*SI); @@ -212,15 +212,15 @@ BasicStoreManager::RemoveDeadBindings(Store store, Stmt* Loc, Marked.insert(R); // FIXME: Do we need the QualType here, since regions are partially // typed? - RVal X = GetRVal(store, lval::MemRegionVal(R), QualType()); + SVal X = GetSVal(store, loc::MemRegionVal(R), QualType()); for (symbol_iterator SI=X.symbol_begin(), SE=X.symbol_end(); SI!=SE; ++SI) LSymbols.insert(*SI); - if (!isa<lval::MemRegionVal>(X)) + if (!isa<loc::MemRegionVal>(X)) continue; - const lval::MemRegionVal& LVD = cast<lval::MemRegionVal>(X); + const loc::MemRegionVal& LVD = cast<loc::MemRegionVal>(X); RegionRoots.push_back(cast<VarRegion>(LVD.getRegion())); } @@ -229,8 +229,8 @@ BasicStoreManager::RemoveDeadBindings(Store store, Stmt* Loc, const VarRegion* R = cast<VarRegion>(MRMgr.getVarRegion(I.getKey())); if (!Marked.count(R)) { - store = Remove(store, lval::MemRegionVal(R)); - RVal X = I.getData(); + store = Remove(store, loc::MemRegionVal(R)); + SVal X = I.getData(); for (symbol_iterator SI=X.symbol_begin(), SE=X.symbol_end(); SI!=SE; ++SI) if (!LSymbols.count(*SI)) DSymbols.insert(*SI); @@ -260,15 +260,15 @@ Store BasicStoreManager::getInitialStore() { // Only handle pointers and integers for now. QualType T = VD->getType(); - if (LVal::IsLValType(T) || T->isIntegerType()) { + if (Loc::IsLocType(T) || T->isIntegerType()) { // Initialize globals and parameters to symbolic values. // Initialize local variables to undefined. - RVal X = (VD->hasGlobalStorage() || isa<ParmVarDecl>(VD) || + SVal X = (VD->hasGlobalStorage() || isa<ParmVarDecl>(VD) || isa<ImplicitParamDecl>(VD)) - ? RVal::GetSymbolValue(StateMgr.getSymbolManager(), VD) + ? SVal::GetSymbolValue(StateMgr.getSymbolManager(), VD) : UndefinedVal(); - St = SetRVal(St, lval::MemRegionVal(MRMgr.getVarRegion(VD)), X); + St = SetSVal(St, loc::MemRegionVal(MRMgr.getVarRegion(VD)), X); } } } @@ -277,7 +277,7 @@ Store BasicStoreManager::getInitialStore() { Store BasicStoreManager::AddDecl(Store store, const VarDecl* VD, Expr* Ex, - RVal InitVal, unsigned Count) { + SVal InitVal, unsigned Count) { BasicValueFactory& BasicVals = StateMgr.getBasicVals(); SymbolManager& SymMgr = StateMgr.getSymbolManager(); @@ -307,35 +307,35 @@ Store BasicStoreManager::AddDecl(Store store, // unsigned) zero; if (!Ex) { QualType T = VD->getType(); - if (LVal::IsLValType(T)) - store = SetRVal(store, getLVal(VD), - lval::ConcreteInt(BasicVals.getValue(0, T))); + if (Loc::IsLocType(T)) + store = SetSVal(store, getLoc(VD), + loc::ConcreteInt(BasicVals.getValue(0, T))); else if (T->isIntegerType()) - store = SetRVal(store, getLVal(VD), - nonlval::ConcreteInt(BasicVals.getValue(0, T))); + store = SetSVal(store, getLoc(VD), + nonloc::ConcreteInt(BasicVals.getValue(0, T))); else { // assert(0 && "ignore other types of variables"); } } else { - store = SetRVal(store, getLVal(VD), InitVal); + store = SetSVal(store, getLoc(VD), InitVal); } } } else { // Process local scalar variables. QualType T = VD->getType(); - if (LVal::IsLValType(T) || T->isIntegerType()) { - RVal V = Ex ? InitVal : UndefinedVal(); + if (Loc::IsLocType(T) || T->isIntegerType()) { + SVal V = Ex ? InitVal : UndefinedVal(); if (Ex && InitVal.isUnknown()) { // EXPERIMENTAL: "Conjured" symbols. SymbolID Sym = SymMgr.getConjuredSymbol(Ex, Count); - V = LVal::IsLValType(Ex->getType()) - ? cast<RVal>(lval::SymbolVal(Sym)) - : cast<RVal>(nonlval::SymbolVal(Sym)); + V = Loc::IsLocType(Ex->getType()) + ? cast<SVal>(loc::SymbolVal(Sym)) + : cast<SVal>(nonloc::SymbolVal(Sym)); } - store = SetRVal(store, getLVal(VD), V); + store = SetSVal(store, getLoc(VD), V); } } diff --git a/lib/Analysis/BasicValueFactory.cpp b/lib/Analysis/BasicValueFactory.cpp index a9bb2cec4b..e20cf16789 100644 --- a/lib/Analysis/BasicValueFactory.cpp +++ b/lib/Analysis/BasicValueFactory.cpp @@ -18,31 +18,31 @@ using namespace clang; -typedef std::pair<RVal, uintptr_t> RValData; -typedef std::pair<RVal, RVal> RValPair; +typedef std::pair<SVal, uintptr_t> SValData; +typedef std::pair<SVal, SVal> SValPair; namespace llvm { -template<> struct FoldingSetTrait<RValData> { - static inline void Profile(const RValData& X, llvm::FoldingSetNodeID& ID) { +template<> struct FoldingSetTrait<SValData> { + static inline void Profile(const SValData& X, llvm::FoldingSetNodeID& ID) { X.first.Profile(ID); ID.AddPointer( (void*) X.second); } }; -template<> struct FoldingSetTrait<RValPair> { - static inline void Profile(const RValPair& X, llvm::FoldingSetNodeID& ID) { +template<> struct FoldingSetTrait<SValPair> { + static inline void Profile(const SValPair& X, llvm::FoldingSetNodeID& ID) { X.first.Profile(ID); X.second.Profile(ID); } }; } -typedef llvm::FoldingSet<llvm::FoldingSetNodeWrapper<RValData> > - PersistentRValsTy; +typedef llvm::FoldingSet<llvm::FoldingSetNodeWrapper<SValData> > + PersistentSValsTy; -typedef llvm::FoldingSet<llvm::FoldingSetNodeWrapper<RValPair> > - PersistentRValPairsTy; +typedef llvm::FoldingSet<llvm::FoldingSetNodeWrapper<SValPair> > + PersistentSValPairsTy; BasicValueFactory::~BasicValueFactory() { // Note that the dstor for the contents of APSIntSet will never be called, @@ -51,8 +51,8 @@ BasicValueFactory::~BasicValueFactory() { for (APSIntSetTy::iterator I=APSIntSet.begin(), E=APSIntSet.end(); I!=E; ++I) I->getValue().~APSInt(); - delete (PersistentRValsTy*) PersistentRVals; - delete (PersistentRValPairsTy*) PersistentRValPairs; + delete (PersistentSValsTy*) PersistentSVals; + delete (PersistentSValPairsTy*) PersistentSValPairs; } const llvm::APSInt& BasicValueFactory::getValue(const llvm::APSInt& X) { @@ -197,20 +197,20 @@ BasicValueFactory::EvaluateAPSInt(BinaryOperator::Opcode Op, } -const std::pair<RVal, uintptr_t>& -BasicValueFactory::getPersistentRValWithData(const RVal& V, uintptr_t Data) { +const std::pair<SVal, uintptr_t>& +BasicValueFactory::getPersistentSValWithData(const SVal& V, uintptr_t Data) { // Lazily create the folding set. - if (!PersistentRVals) PersistentRVals = new PersistentRValsTy(); + if (!PersistentSVals) PersistentSVals = new PersistentSValsTy(); llvm::FoldingSetNodeID ID; void* InsertPos; V.Profile(ID); ID.AddPointer((void*) Data); - PersistentRValsTy& Map = *((PersistentRValsTy*) PersistentRVals); + PersistentSValsTy& Map = *((PersistentSValsTy*) PersistentSVals); - typedef llvm::FoldingSetNodeWrapper<RValData> FoldNodeTy; + typedef llvm::FoldingSetNodeWrapper<SValData> FoldNodeTy; FoldNodeTy* P = Map.FindNodeOrInsertPos(ID, InsertPos); if (!P) { @@ -222,20 +222,20 @@ BasicValueFactory::getPersistentRValWithData(const RVal& V, uintptr_t Data) { return P->getValue(); } -const std::pair<RVal, RVal>& -BasicValueFactory::getPersistentRValPair(const RVal& V1, const RVal& V2) { +const std::pair<SVal, SVal>& +BasicValueFactory::getPersistentSValPair(const SVal& V1, const SVal& V2) { // Lazily create the folding set. - if (!PersistentRValPairs) PersistentRValPairs = new PersistentRValPairsTy(); + if (!PersistentSValPairs) PersistentSValPairs = new PersistentSValPairsTy(); llvm::FoldingSetNodeID ID; void* InsertPos; V1.Profile(ID); V2.Profile(ID); - PersistentRValPairsTy& Map = *((PersistentRValPairsTy*) PersistentRValPairs); + PersistentSValPairsTy& Map = *((PersistentSValPairsTy*) PersistentSValPairs); - typedef llvm::FoldingSetNodeWrapper<RValPair> FoldNodeTy; + typedef llvm::FoldingSetNodeWrapper<SValPair> FoldNodeTy; FoldNodeTy* P = Map.FindNodeOrInsertPos(ID, InsertPos); if (!P) { @@ -247,8 +247,8 @@ BasicValueFactory::getPersistentRValPair(const RVal& V1, const RVal& V2) { return P->getValue(); } -const RVal* BasicValueFactory::getPersistentRVal(RVal X) { - return &getPersistentRValWithData(X, 0).first; +const SVal* BasicValueFactory::getPersistentSVal(SVal X) { + return &getPersistentSValWithData(X, 0).first; } diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp index 834567136f..0663ddde41 100644 --- a/lib/Analysis/BugReporter.cpp +++ b/lib/Analysis/BugReporter.cpp @@ -292,7 +292,7 @@ MakeReportGraph(ExplodedGraph<GRState>* G, ExplodedNode<GRState>* N) { static VarDecl* GetMostRecentVarDeclBinding(ExplodedNode<GRState>* N, GRStateManager& VMgr, - RVal X) { + SVal X) { for ( ; N ; N = N->pred_empty() ? 0 : *N->pred_begin()) { @@ -306,7 +306,7 @@ static VarDecl* GetMostRecentVarDeclBinding(ExplodedNode<GRState>* N, if (!DR) continue; - RVal Y = VMgr.GetRVal(N->getState(), DR); + SVal Y = VMgr.GetSVal(N->getState(), DR); if (X != Y) continue; @@ -341,13 +341,13 @@ public: PathDiagnostic& pd, BugReporter& br) : Sym(sym), PrevSt(prevst), S(s), VMgr(vmgr), Pred(pred), PD(pd), BR(br) {} - bool HandleBinding(StoreManager& SMgr, Store store, MemRegion* R, RVal V) { + bool HandleBinding(StoreManager& SMgr, Store store, MemRegion* R, SVal V) { SymbolID ScanSym; - if (lval::SymbolVal* SV = dyn_cast<lval::SymbolVal>(&V)) + if (loc::SymbolVal* SV = dyn_cast<loc::SymbolVal>(&V)) ScanSym = SV->getSymbol(); - else if (nonlval::SymbolVal* SV = dyn_cast<nonlval::SymbolVal>(&V)) + else if (nonloc::SymbolVal* SV = dyn_cast<nonloc::SymbolVal>(&V)) ScanSym = SV->getSymbol(); else return true; @@ -356,7 +356,7 @@ public: return true; // Check if the previous state has this binding. - RVal X = VMgr.GetRVal(PrevSt, lval::MemRegionVal(R)); + SVal X = VMgr.GetSVal(PrevSt, loc::MemRegionVal(R)); if (X == V) // Same binding? return true; @@ -443,12 +443,12 @@ public: PathDiagnostic& pd) : N(n), S(s), BR(br), PD(pd) {} - bool HandleBinding(StoreManager& SMgr, Store store, MemRegion* R, RVal V) { + bool HandleBinding(StoreManager& SMgr, Store store, MemRegion* R, SVal V) { SymbolID ScanSym; - if (lval::SymbolVal* SV = dyn_cast<lval::SymbolVal>(&V)) + if (loc::SymbolVal* SV = dyn_cast<loc::SymbolVal>(&V)) ScanSym = SV->getSymbol(); - else if (nonlval::SymbolVal* SV = dyn_cast<nonlval::SymbolVal>(&V)) + else if (nonloc::SymbolVal* SV = dyn_cast<nonloc::SymbolVal>(&V)) ScanSym = SV->getSymbol(); else return true; diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp index c63529aa05..9d632314b2 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -1297,7 +1297,7 @@ public: virtual void EvalCall(ExplodedNodeSet<GRState>& Dst, GRExprEngine& Eng, GRStmtNodeBuilder<GRState>& Builder, - CallExpr* CE, RVal L, + CallExpr* CE, SVal L, ExplodedNode<GRState>* Pred); @@ -1319,7 +1319,7 @@ public: GRExprEngine& Engine, GRStmtNodeBuilder<GRState>& Builder, Expr* E, ExplodedNode<GRState>* Pred, - const GRState* St, RVal TargetLV, RVal Val); + const GRState* St, SVal TargetLV, SVal Val); // End-of-path. virtual void EvalEndPath(GRExprEngine& Engine, @@ -1343,7 +1343,7 @@ public: // Assumptions. virtual const GRState* EvalAssume(GRStateManager& VMgr, - const GRState* St, RVal Cond, + const GRState* St, SVal Cond, bool Assumption, bool& isFeasible); // Error iterators. @@ -1473,10 +1473,10 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<GRState>& Dst, SymbolID ErrorSym = 0; for (ExprIterator I = arg_beg; I != arg_end; ++I, ++idx) { - RVal V = state.GetRVal(*I); + SVal V = state.GetSVal(*I); - if (isa<lval::SymbolVal>(V)) { - SymbolID Sym = cast<lval::SymbolVal>(V).getSymbol(); + if (isa<loc::SymbolVal>(V)) { + SymbolID Sym = cast<loc::SymbolVal>(V).getSymbol(); if (RefBindings::data_type* T = state.get<RefBindings>(Sym)) if (Update(state, Sym, *T, GetArgE(Summ, idx), hasErr)) { ErrorExpr = *I; @@ -1484,12 +1484,12 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<GRState>& Dst, break; } } - else if (isa<LVal>(V)) { + else if (isa<Loc>(V)) { #if 0 // Nuke all arguments passed by reference. - StateMgr.Unbind(StVals, cast<LVal>(V)); + StateMgr.Unbind(StVals, cast<Loc>(V)); #else - if (lval::MemRegionVal* MR = dyn_cast<lval::MemRegionVal>(&V)) { + if (loc::MemRegionVal* MR = dyn_cast<loc::MemRegionVal>(&V)) { if (GetArgE(Summ, idx) == DoNothingByRef) continue; @@ -1506,10 +1506,10 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<GRState>& Dst, // disambiguate conjured symbols. // Is the invalidated variable something that we were tracking? - RVal X = state.GetRVal(*MR); + SVal X = state.GetSVal(*MR); - if (isa<lval::SymbolVal>(X)) { - SymbolID Sym = cast<lval::SymbolVal>(X).getSymbol(); + if (isa<loc::SymbolVal>(X)) { + SymbolID Sym = cast<loc::SymbolVal>(X).getSymbol(); state = state.remove<RefBindings>(Sym); } @@ -1521,29 +1521,29 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<GRState>& Dst, SymbolID NewSym = Eng.getSymbolManager().getConjuredSymbol(*I, T, Count); - state = state.SetRVal(*MR, - LVal::IsLValType(T) - ? cast<RVal>(lval::SymbolVal(NewSym)) - : cast<RVal>(nonlval::SymbolVal(NewSym))); + state = state.SetSVal(*MR, + Loc::IsLocType(T) + ? cast<SVal>(loc::SymbolVal(NewSym)) + : cast<SVal>(nonloc::SymbolVal(NewSym))); } else - state = state.SetRVal(*MR, UnknownVal()); + state = state.SetSVal(*MR, UnknownVal()); } else { // Nuke all other arguments passed by reference. - state = state.Unbind(cast<LVal>(V)); + state = state.Unbind(cast<Loc>(V)); } #endif } - else if (isa<nonlval::LValAsInteger>(V)) - state = state.Unbind(cast<nonlval::LValAsInteger>(V).getLVal()); + |