diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2008-10-17 05:57:07 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2008-10-17 05:57:07 +0000 |
commit | 1c96b24285d05c0eac455ae96d7c9ff43d42bc96 (patch) | |
tree | 4d2ab34daff9c66fe996657201955fb24de6cd84 | |
parent | ef8b28e9459e729b7bd8c826d204621b039611fa (diff) |
This patch did the following renaming. There should be no functional changes.
RVal => SVal
LVal => Loc
NonLVal => NonLoc
lval => loc
nonlval => nonloc
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57671 91177308-0d34-0410-b5e6-96231b3b80d8
25 files changed, 870 insertions, 867 deletions
diff --git a/include/clang/Analysis/PathSensitive/BasicValueFactory.h b/include/clang/Analysis/PathSensitive/BasicValueFactory.h index 29957a7996..0edcde35bc 100644 --- a/include/clang/Analysis/PathSensitive/BasicValueFactory.h +++ b/include/clang/Analysis/PathSensitive/BasicValueFactory.h @@ -27,7 +27,7 @@ namespace llvm { namespace clang { -class RVal; +class SVal; class BasicValueFactory { typedef llvm::FoldingSet<llvm::FoldingSetNodeWrapper<llvm::APSInt> > @@ -42,12 +42,12 @@ class BasicValueFactory { APSIntSetTy APSIntSet; SymIntCSetTy SymIntCSet; - void* PersistentRVals; - void* PersistentRValPairs; + void* PersistentSVals; + void* PersistentSValPairs; public: BasicValueFactory(ASTContext& ctx, llvm::BumpPtrAllocator& Alloc) - : Ctx(ctx), BPAlloc(Alloc), PersistentRVals(0), PersistentRValPairs(0) {} + : Ctx(ctx), BPAlloc(Alloc), PersistentSVals(0), PersistentSValPairs(0) {} ~BasicValueFactory(); @@ -72,13 +72,13 @@ public: const llvm::APSInt& V1, const llvm::APSInt& V2); - const std::pair<RVal, uintptr_t>& - getPersistentRValWithData(const RVal& V, uintptr_t Data); + const std::pair<SVal, uintptr_t>& + getPersistentSValWithData(const SVal& V, uintptr_t Data); - const std::pair<RVal, RVal>& - getPersistentRValPair(const RVal& V1, const RVal& V2); + const std::pair<SVal, SVal>& + getPersistentSValPair(const SVal& V1, const SVal& V2); - const RVal* getPersistentRVal(RVal X); + const SVal* getPersistentSVal(SVal X); }; } // end clang namespace diff --git a/include/clang/Analysis/PathSensitive/ConstraintManager.h b/include/clang/Analysis/PathSensitive/ConstraintManager.h index 25c9260a72..71ae247f57 100644 --- a/include/clang/Analysis/PathSensitive/ConstraintManager.h +++ b/include/clang/Analysis/PathSensitive/ConstraintManager.h @@ -25,14 +25,14 @@ namespace clang { class GRState; class GRStateManager; -class RVal; +class SVal; class SymbolID; class ConstraintManager { public: virtual ~ConstraintManager(); - virtual const GRState* Assume(const GRState* St, RVal Cond, bool Assumption, - bool& isFeasible) = 0; + virtual const GRState* Assume(const GRState* St, SVal Cond, + bool Assumption, bool& isFeasible) = 0; virtual const GRState* AddNE(const GRState* St, SymbolID sym, const llvm::APSInt& V) = 0; diff --git a/include/clang/Analysis/PathSensitive/Environment.h b/include/clang/Analysis/PathSensitive/Environment.h index f1556a9be2..c04252e6e8 100644 --- a/include/clang/Analysis/PathSensitive/Environment.h +++ b/include/clang/Analysis/PathSensitive/Environment.h @@ -36,7 +36,7 @@ private: friend class EnvironmentManager; // Type definitions. - typedef llvm::ImmutableMap<Expr*,RVal> BindingsTy; + typedef llvm::ImmutableMap<Expr*,SVal> BindingsTy; // Data. BindingsTy SubExprBindings; @@ -55,28 +55,28 @@ public: beb_iterator beb_begin() const { return BlkExprBindings.begin(); } beb_iterator beb_end() const { return BlkExprBindings.end(); } - RVal LookupSubExpr(Expr* E) const { - const RVal* X = SubExprBindings.lookup(E); + SVal LookupSubExpr(Expr* E) const { + const SVal* X = SubExprBindings.lookup(E); return X ? *X : UnknownVal(); } - RVal LookupBlkExpr(Expr* E) const { - const RVal* X = BlkExprBindings.lookup(E); + SVal LookupBlkExpr(Expr* E) const { + const SVal* X = BlkExprBindings.lookup(E); return X ? *X : UnknownVal(); } - RVal LookupExpr(Expr* E) const { - const RVal* X = SubExprBindings.lookup(E); + SVal LookupExpr(Expr* E) const { + const SVal* X = SubExprBindings.lookup(E); if (X) return *X; X = BlkExprBindings.lookup(E); return X ? *X : UnknownVal(); } - RVal GetRVal(Expr* Ex, BasicValueFactory& BasicVals) const; - RVal GetRVal(const Expr* Ex, BasicValueFactory& BasicVals) const { - return GetRVal(const_cast<Expr*>(Ex), BasicVals); + SVal GetSVal(Expr* Ex, BasicValueFactory& BasicVals) const; + SVal GetSVal(const Expr* Ex, BasicValueFactory& BasicVals) const { + return GetSVal(const_cast<Expr*>(Ex), BasicVals); } - RVal GetBlkExprRVal(Expr* Ex, BasicValueFactory& BasicVals) const; + SVal GetBlkExprSVal(Expr* Ex, BasicValueFactory& BasicVals) const; /// Profile - Profile the contents of an Environment object for use /// in a FoldingSet. @@ -120,11 +120,11 @@ public: return Environment(F.Remove(Env.SubExprBindings, E), Env.BlkExprBindings); } - Environment AddBlkExpr(const Environment& Env, Expr* E, RVal V) { - return Environment(Env.SubExprBindings, F.Add(Env.BlkExprBindings, E, V)); + Environment AddBlkExpr(const Environment& Env, Expr* E, SVal V) { + return Environment(Env.SubExprBindings, F.Add(Env.BlkExprBindings, E, V)); } - Environment AddSubExpr(const Environment& Env, Expr* E, RVal V) { + Environment AddSubExpr(const Environment& Env, Expr* E, SVal V) { return Environment(F.Add(Env.SubExprBindings, E, V), Env.BlkExprBindings); } @@ -139,7 +139,7 @@ public: return Environment(F.GetEmptyMap(), F.GetEmptyMap()); } - Environment SetRVal(const Environment& Env, Expr* E, RVal V, + Environment SetSVal(const Environment& Env, Expr* E, SVal V, bool isBlkExpr, bool Invalidate); Environment RemoveDeadBindings(Environment Env, Stmt* Loc, diff --git a/include/clang/Analysis/PathSensitive/GRExprEngine.h b/include/clang/Analysis/PathSensitive/GRExprEngine.h index 5fc63224d8..8af3593210 100644 --- a/include/clang/Analysis/PathSensitive/GRExprEngine.h +++ b/include/clang/Analysis/PathSensitive/GRExprEngine.h @@ -252,11 +252,11 @@ public: } bool isImplicitBadDivide(const NodeTy* N) const { - return N->isSink() && ImplicitBadDivides.count(const_cast<NodeTy*>(N)) != 0; + return N->isSink() && ImplicitBadDivides.count(const_cast<NodeTy*>(N)) != 0; } bool isExplicitBadDivide(const NodeTy* N) const { - return N->isSink() && ExplicitBadDivides.count(const_cast<NodeTy*>(N)) != 0; + return N->isSink() && ExplicitBadDivides.count(const_cast<NodeTy*>(N)) != 0; } bool isNoReturnCall(const NodeTy* N) const { @@ -402,52 +402,52 @@ protected: public: - const GRState* SetRVal(const GRState* St, Expr* Ex, RVal V) { - return StateMgr.SetRVal(St, Ex, V); + const GRState* SetSVal(const GRState* St, Expr* Ex, SVal V) { + return StateMgr.SetSVal(St, Ex, V); } - const GRState* SetRVal(const GRState* St, const Expr* Ex, RVal V) { - return SetRVal(St, const_cast<Expr*>(Ex), V); + const GRState* SetSVal(const GRState* St, const Expr* Ex, SVal V) { + return SetSVal(St, const_cast<Expr*>(Ex), V); } protected: - const GRState* SetBlkExprRVal(const GRState* St, Expr* Ex, RVal V) { - return StateMgr.SetRVal(St, Ex, V, true, false); + const GRState* SetBlkExprSVal(const GRState* St, Expr* Ex, SVal V) { + return StateMgr.SetSVal(St, Ex, V, true, false); } - const GRState* SetRVal(const GRState* St, LVal LV, RVal V) { - return StateMgr.SetRVal(St, LV, V); + const GRState* SetSVal(const GRState* St, Loc LV, SVal V) { + return StateMgr.SetSVal(St, LV, V); } - RVal GetRVal(const GRState* St, Expr* Ex) { - return StateMgr.GetRVal(St, Ex); + SVal GetSVal(const GRState* St, Expr* Ex) { + return StateMgr.GetSVal(St, Ex); } - RVal GetRVal(const GRState* St, const Expr* Ex) { - return GetRVal(St, const_cast<Expr*>(Ex)); + SVal GetSVal(const GRState* St, const Expr* Ex) { + return GetSVal(St, const_cast<Expr*>(Ex)); } - RVal GetBlkExprRVal(const GRState* St, Expr* Ex) { - return StateMgr.GetBlkExprRVal(St, Ex); + SVal GetBlkExprSVal(const GRState* St, Expr* Ex) { + return StateMgr.GetBlkExprSVal(St, Ex); } - RVal GetRVal(const GRState* St, LVal LV, QualType T = QualType()) { - return StateMgr.GetRVal(St, LV, T); + SVal GetSVal(const GRState* St, Loc LV, QualType T = QualType()) { + return StateMgr.GetSVal(St, LV, T); } - inline NonLVal MakeConstantVal(uint64_t X, Expr* Ex) { - return NonLVal::MakeVal(getBasicVals(), X, Ex->getType()); + inline NonLoc MakeConstantVal(uint64_t X, Expr* Ex) { + return NonLoc::MakeVal(getBasicVals(), X, Ex->getType()); } /// Assume - Create new state by assuming that a given expression /// is true or false. - const GRState* Assume(const GRState* St, RVal Cond, bool Assumption, + const GRState* Assume(const GRState* St, SVal Cond, bool Assumption, bool& isFeasible) { return StateMgr.Assume(St, Cond, Assumption, isFeasible); } - const GRState* Assume(const GRState* St, LVal Cond, bool Assumption, + const GRState* Assume(const GRState* St, Loc Cond, bool Assumption, bool& isFeasible) { return StateMgr.Assume(St, Cond, Assumption, isFeasible); } @@ -539,44 +539,44 @@ protected: bool asLValue); bool CheckDivideZero(Expr* Ex, const GRState* St, NodeTy* Pred, - RVal Denom); + SVal Denom); - RVal EvalCast(RVal X, QualType CastT) { + SVal EvalCast(SVal X, QualType CastT) { if (X.isUnknownOrUndef()) return X; - if (isa<LVal>(X)) - return getTF().EvalCast(*this, cast<LVal>(X), CastT); + if (isa<Loc>(X)) + return getTF().EvalCast(*this, cast<Loc>(X), CastT); else - return getTF().EvalCast(*this, cast<NonLVal>(X), CastT); + return getTF().EvalCast(*this, cast<NonLoc>(X), CastT); } - RVal EvalMinus(UnaryOperator* U, RVal X) { - return X.isValid() ? getTF().EvalMinus(*this, U, cast<NonLVal>(X)) : X; + SVal EvalMinus(UnaryOperator* U, SVal X) { + return X.isValid() ? getTF().EvalMinus(*this, U, cast<NonLoc>(X)) : X; } - RVal EvalComplement(RVal X) { - return X.isValid() ? getTF().EvalComplement(*this, cast<NonLVal>(X)) : X; + SVal EvalComplement(SVal X) { + return X.isValid() ? getTF().EvalComplement(*this, cast<NonLoc>(X)) : X; } - RVal EvalBinOp(BinaryOperator::Opcode Op, NonLVal L, NonLVal R) { + SVal EvalBinOp(BinaryOperator::Opcode Op, NonLoc L, NonLoc R) { return R.isValid() ? getTF().DetermEvalBinOpNN(getStateManager(), Op, L, R) : R; } - RVal EvalBinOp(BinaryOperator::Opcode Op, NonLVal L, RVal R) { + SVal EvalBinOp(BinaryOperator::Opcode Op, NonLoc L, SVal R) { return R.isValid() ? getTF().DetermEvalBinOpNN(getStateManager(), Op, L, - cast<NonLVal>(R)) : R; + cast<NonLoc>(R)) : R; } void EvalBinOp(ExplodedNodeSet<GRState>& Dst, Expr* Ex, - BinaryOperator::Opcode Op, NonLVal L, NonLVal R, + BinaryOperator::Opcode Op, NonLoc L, NonLoc R, ExplodedNode<GRState>* Pred); void EvalBinOp(GRStateSet& OStates, const GRState* St, Expr* Ex, - BinaryOperator::Opcode Op, NonLVal L, NonLVal R); + BinaryOperator::Opcode Op, NonLoc L, NonLoc R); - RVal EvalBinOp(BinaryOperator::Opcode Op, RVal L, RVal R) { + SVal EvalBinOp(BinaryOperator::Opcode Op, SVal L, SVal R) { if (L.isUndef() || R.isUndef()) return UndefinedVal(); @@ -584,30 +584,30 @@ protected: if (L.isUnknown() || R.isUnknown()) return UnknownVal(); - if (isa<LVal>(L)) { - if (isa<LVal>(R)) - return getTF().EvalBinOp(*this, Op, cast<LVal>(L), cast<LVal>(R)); + if (isa<Loc>(L)) { + if (isa<Loc>(R)) + return getTF().EvalBinOp(*this, Op, cast<Loc>(L), cast<Loc>(R)); else - return getTF().EvalBinOp(*this, Op, cast<LVal>(L), cast<NonLVal>(R)); + return getTF().EvalBinOp(*this, Op, cast<Loc>(L), cast<NonLoc>(R)); } - if (isa<LVal>(R)) { + if (isa<Loc>(R)) { // Support pointer arithmetic where the increment/decrement operand // is on the left and the pointer on the right. assert (Op == BinaryOperator::Add || Op == BinaryOperator::Sub); // Commute the operands. - return getTF().EvalBinOp(*this, Op, cast<LVal>(R), - cast<NonLVal>(L)); + return getTF().EvalBinOp(*this, Op, cast<Loc>(R), + cast<NonLoc>(L)); } else - return getTF().DetermEvalBinOpNN(getStateManager(), Op, cast<NonLVal>(L), - cast<NonLVal>(R)); + return getTF().DetermEvalBinOpNN(getStateManager(), Op, cast<NonLoc>(L), + cast<NonLoc>(R)); } - void EvalCall(NodeSet& Dst, CallExpr* CE, RVal L, NodeTy* Pred) { + void EvalCall(NodeSet& Dst, CallExpr* CE, SVal L, NodeTy* Pred) { assert (Builder && "GRStmtNodeBuilder must be defined."); getTF().EvalCall(Dst, *this, *Builder, CE, L, Pred); } @@ -618,24 +618,25 @@ protected: } void EvalStore(NodeSet& Dst, Expr* E, NodeTy* Pred, const GRState* St, - RVal TargetLV, RVal Val); + SVal TargetLV, SVal Val); void EvalStore(NodeSet& Dst, Expr* E, Expr* StoreE, NodeTy* Pred, - const GRState* St, RVal TargetLV, RVal Val); + const GRState* St, SVal TargetLV, SVal Val); // FIXME: The "CheckOnly" option exists only because Array and Field // loads aren't fully implemented. Eventually this option will go away. void EvalLoad(NodeSet& Dst, Expr* Ex, NodeTy* Pred, - const GRState* St, RVal location, bool CheckOnly = false); + const GRState* St, SVal location, bool CheckOnly = false); const GRState* EvalLocation(Expr* Ex, NodeTy* Pred, - const GRState* St, RVal location, - bool isLoad = false); + const GRState* St, SVal location, + bool isLoad = false); void EvalReturn(NodeSet& Dst, ReturnStmt* s, NodeTy* Pred); - const GRState* MarkBranch(const GRState* St, Stmt* Terminator, bool branchTaken); + const GRState* MarkBranch(const GRState* St, Stmt* Terminator, + bool branchTaken); }; } // end clang namespace diff --git a/include/clang/Analysis/PathSensitive/GRState.h b/include/clang/Analysis/PathSensitive/GRState.h index 841927bf3e..331c8301cd 100644 --- a/include/clang/Analysis/PathSensitive/GRState.h +++ b/include/clang/Analysis/PathSensitive/GRState.h @@ -61,7 +61,7 @@ template <typename T> struct GRStateTrait { }; //===----------------------------------------------------------------------===// -// GRState- An ImmutableMap type Stmt*/Decl*/Symbols to RVals. +// GRState- An ImmutableMap type Stmt*/Decl*/Symbols to SVals. //===----------------------------------------------------------------------===// /// GRState - This class encapsulates the actual data values for @@ -129,7 +129,7 @@ public: Profile(ID, this); } - RVal LookupExpr(Expr* E) const { + SVal LookupExpr(Expr* E) const { return Env.LookupExpr(E); } @@ -174,7 +174,7 @@ public: // Tags used for the Generic Data Map. struct NullDerefTag { static int TagInt; - typedef const RVal* data_type; + typedef const SVal* data_type; }; }; @@ -251,7 +251,7 @@ private: /// a particular function. This is used to unique states. llvm::FoldingSet<GRState> StateSet; - /// ValueMgr - Object that manages the data for all created RVals. + /// ValueMgr - Object that manages the data for all created SVals. BasicValueFactory BasicVals; /// SymMgr - Object that manages the symbol information. @@ -268,7 +268,7 @@ private: CFG& cfg; /// TF - Object that represents a bundle of transfer functions - /// for manipulating and creating RVals. + /// for manipulating and creating SVals. GRTransferFuncs* TF; /// Liveness - live-variables information of the ValueDecl* and block-level @@ -282,8 +282,8 @@ private: } // FIXME: Remove when we do lazy initializaton of variable bindings. -// const GRState* BindVar(const GRState* St, VarDecl* D, RVal V) { -// return SetRVal(St, getLVal(D), V); +// const GRState* BindVar(const GRState* St, VarDecl* D, SVal V) { +// return SetSVal(St, getLoc(D), V); // } public: @@ -342,44 +342,44 @@ public: } // Get the lvalue for a variable reference. - RVal GetLValue(const GRState* St, const VarDecl* D) { + SVal GetLValue(const GRState* St, const VarDecl* D) { return StoreMgr->getLValueVar(St, D); } // Get the lvalue for an ivar reference. - RVal GetLValue(const GRState* St, const ObjCIvarDecl* D, RVal Base) { + SVal GetLValue(const GRState* St, const ObjCIvarDecl* D, SVal Base) { return StoreMgr->getLValueIvar(St, D, Base); } // Get the lvalue for a field reference. - RVal GetLValue(const GRState* St, const FieldDecl* D, RVal Base) { + SVal GetLValue(const GRState* St, const FieldDecl* D, SVal Base) { return StoreMgr->getLValueField(St, D, Base); } // Get the lvalue for an array index. - RVal GetLValue(const GRState* St, RVal Base, RVal Idx) { + SVal GetLValue(const GRState* St, SVal Base, SVal Idx) { return StoreMgr->getLValueElement(St, Base, Idx); } // Methods that query & manipulate the Environment. - RVal GetRVal(const GRState* St, Expr* Ex) { - return St->getEnvironment().GetRVal(Ex, BasicVals); + SVal GetSVal(const GRState* St, Expr* Ex) { + return St->getEnvironment().GetSVal(Ex, BasicVals); } - RVal GetRVal(const GRState* St, const Expr* Ex) { - return St->getEnvironment().GetRVal(Ex, BasicVals); + SVal GetSVal(const GRState* St, const Expr* Ex) { + return St->getEnvironment().GetSVal(Ex, BasicVals); } - RVal GetBlkExprRVal(const GRState* St, Expr* Ex) { - return St->getEnvironment().GetBlkExprRVal(Ex, BasicVals); + SVal GetBlkExprSVal(const GRState* St, Expr* Ex) { + return St->getEnvironment().GetBlkExprSVal(Ex, BasicVals); } - const GRState* SetRVal(const GRState* St, Expr* Ex, RVal V, + const GRState* SetSVal(const GRState* St, Expr* Ex, SVal V, bool isBlkExpr, bool Invalidate) { const Environment& OldEnv = St->getEnvironment(); - Environment NewEnv = EnvMgr.SetRVal(OldEnv, Ex, V, isBlkExpr, Invalidate); + Environment NewEnv = EnvMgr.SetSVal(OldEnv, Ex, V, isBlkExpr, Invalidate); if (NewEnv == OldEnv) return St; @@ -389,7 +389,7 @@ public: return getPersistentState(NewSt); } - const GRState* SetRVal(const GRState* St, Expr* Ex, RVal V, + const GRState* SetSVal(const GRState* St, Expr* Ex, SVal V, bool Invalidate = true) { bool isBlkExpr = false; @@ -403,7 +403,7 @@ public: return St; } - return SetRVal(St, Ex, V, isBlkExpr, Invalidate); + return SetSVal(St, Ex, V, isBlkExpr, Invalidate); } // Methods that manipulate the GDM. @@ -421,21 +421,21 @@ public: } - RVal GetRVal(const GRState* St, LVal LV, QualType T = QualType()) { - return StoreMgr->GetRVal(St->getStore(), LV, T); + SVal GetSVal(const GRState* St, Loc LV, QualType T = QualType()) { + return StoreMgr->GetSVal(St->getStore(), LV, T); } - void SetRVal(GRState& St, LVal LV, RVal V) { - St.St = StoreMgr->SetRVal(St.St, LV, V); + void SetSVal(GRState& St, Loc LV, SVal V) { + St.St = StoreMgr->SetSVal(St.St, LV, V); } - const GRState* SetRVal(const GRState* St, LVal LV, RVal V); + const GRState* SetSVal(const GRState* St, Loc LV, SVal V); - void Unbind(GRState& St, LVal LV) { + void Unbind(GRState& St, Loc LV) { St.St = StoreMgr->Remove(St.St, LV); } - const GRState* Unbind(const GRState* St, LVal LV); + const GRState* Unbind(const GRState* St, Loc LV); const GRState* getPersistentState(GRState& Impl); @@ -482,7 +482,7 @@ public: return GRStateTrait<T>::MakeContext(p); } - const GRState* Assume(const GRState* St, RVal Cond, bool Assumption, + const GRState* Assume(const GRState* St, SVal Cond, bool Assumption, bool& isFeasible) { return ConstraintMgr->Assume(St, Cond, Assumption, isFeasible); } @@ -510,33 +510,33 @@ public: operator const GRState*() const { return St; } GRStateManager& getManager() const { return *Mgr; } - RVal GetRVal(Expr* Ex) { - return Mgr->GetRVal(St, Ex); + SVal GetSVal(Expr* Ex) { + return Mgr->GetSVal(St, Ex); } - RVal GetBlkExprRVal(Expr* Ex) { - return Mgr->GetBlkExprRVal(St, Ex); + SVal GetBlkExprSVal(Expr* Ex) { + return Mgr->GetBlkExprSVal(St, Ex); } - RVal GetRVal(LVal LV, QualType T = QualType()) { - return Mgr->GetRVal(St, LV, T); + SVal GetSVal(Loc LV, QualType T = QualType()) { + return Mgr->GetSVal(St, LV, T); } - GRStateRef SetRVal(Expr* Ex, RVal V, bool isBlkExpr, bool Invalidate) { - return GRStateRef(Mgr->SetRVal(St, Ex, V, isBlkExpr, Invalidate), *Mgr); + GRStateRef SetSVal(Expr* Ex, SVal V, bool isBlkExpr, bool Invalidate) { + return GRStateRef(Mgr->SetSVal(St, Ex, V, isBlkExpr, Invalidate), *Mgr); } - GRStateRef SetRVal(Expr* Ex, RVal V, bool Invalidate = true) { - return GRStateRef(Mgr->SetRVal(St, Ex, V, Invalidate), *Mgr); + GRStateRef SetSVal(Expr* Ex, SVal V, bool Invalidate = true) { + return GRStateRef(Mgr->SetSVal(St, Ex, V, Invalidate), *Mgr); } - GRStateRef SetRVal(LVal LV, RVal V) { + GRStateRef SetSVal(Loc LV, SVal V) { GRState StImpl = *St; - Mgr->SetRVal(StImpl, LV, V); + Mgr->SetSVal(StImpl, LV, V); return GRStateRef(Mgr->getPersistentState(StImpl), *Mgr); } - GRStateRef Unbind(LVal LV) { + GRStateRef Unbind(Loc LV) { return GRStateRef(Mgr->Unbind(St, LV), *Mgr); } @@ -591,7 +591,7 @@ public: } // Lvalue methods. - RVal GetLValue(const VarDecl* VD) { + SVal GetLValue(const VarDecl* VD) { return Mgr->GetLValue(St, VD); } diff --git a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h index ad12328eda..ebb0c4ef64 100644 --- a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h +++ b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h @@ -32,9 +32,9 @@ class GRTransferFuncs { protected: - virtual RVal DetermEvalBinOpNN(GRStateManager& StateMgr, + virtual SVal DetermEvalBinOpNN(GRStateManager& StateMgr, BinaryOperator::Opcode Op, - NonLVal L, NonLVal R) { + NonLoc L, NonLoc R) { return UnknownVal(); } @@ -48,34 +48,34 @@ public: // Casts. - virtual RVal EvalCast(GRExprEngine& Engine, NonLVal V, QualType CastT) =0; - virtual RVal EvalCast(GRExprEngine& Engine, LVal V, QualType CastT) = 0; + virtual SVal EvalCast(GRExprEngine& Engine, NonLoc V, QualType CastT) =0; + virtual SVal EvalCast(GRExprEngine& Engine, Loc V, QualType CastT) = 0; // Unary Operators. - virtual RVal EvalMinus(GRExprEngine& Engine, UnaryOperator* U, NonLVal X) = 0; + virtual SVal EvalMinus(GRExprEngine& Engine, UnaryOperator* U, NonLoc X) = 0; - virtual RVal EvalComplement(GRExprEngine& Engine, NonLVal X) = 0; + virtual SVal EvalComplement(GRExprEngine& Engine, NonLoc X) = 0; // Binary Operators. virtual void EvalBinOpNN(GRStateSet& OStates, GRStateManager& StateMgr, const GRState* St, Expr* Ex, - BinaryOperator::Opcode Op, NonLVal L, NonLVal R); + BinaryOperator::Opcode Op, NonLoc L, NonLoc R); - virtual RVal EvalBinOp(GRExprEngine& Engine, BinaryOperator::Opcode Op, - LVal L, LVal R) = 0; + virtual SVal EvalBinOp(GRExprEngine& Engine, BinaryOperator::Opcode Op, + Loc L, Loc R) = 0; // Pointer arithmetic. - virtual RVal EvalBinOp(GRExprEngine& Engine, BinaryOperator::Opcode Op, - LVal L, NonLVal R) = 0; + virtual SVal EvalBinOp(GRExprEngine& Engine, BinaryOperator::Opcode Op, + Loc L, NonLoc R) = 0; // Calls. virtual void EvalCall(ExplodedNodeSet<GRState>& Dst, GRExprEngine& Engine, GRStmtNodeBuilder<GRState>& Builder, - CallExpr* CE, RVal L, + CallExpr* CE, SVal L, ExplodedNode<GRState>* Pred) {} virtual void EvalObjCMessageExpr(ExplodedNodeSet<GRState>& Dst, @@ -88,12 +88,12 @@ public: /// EvalStore - Evaluate the effects of a store, creating a new node /// the represents the effect of binding 'Val' to the location 'TargetLV'. - // TargetLV is guaranteed to either be an UnknownVal or an LVal. + // TargetLV is guaranteed to either be an UnknownVal or an Loc. virtual void EvalStore(ExplodedNodeSet<GRState>& Dst, 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 and dead symbol notification. @@ -121,7 +121,7 @@ public: virtual const GRState* EvalAssume(GRStateManager& VMgr, const GRState* St, - RVal Cond, bool Assumption, + SVal Cond, bool Assumption, bool& isFeasible) { return St; } diff --git a/include/clang/Analysis/PathSensitive/RValues.h b/include/clang/Analysis/PathSensitive/RValues.h index e41113d6c7..c1ee0e0e90 100644 --- a/include/clang/Analysis/PathSensitive/RValues.h +++ b/include/clang/Analysis/PathSensitive/RValues.h @@ -1,4 +1,4 @@ -//== RValues.h - Abstract RValues for Path-Sens. Value Tracking -*- C++ -*--==// +//== SValues.h - Abstract Values for Static Analysis ---------*- C++ -*--==// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file defines RVal, LVal, and NonLVal, classes that represent +// This file defines SVal, Loc, and NonLoc, classes that represent // abstract r-values for use with path-sensitive value tracking. // //===----------------------------------------------------------------------===// @@ -19,17 +19,17 @@ #include "llvm/Support/Casting.h" //==------------------------------------------------------------------------==// -// Base RVal types. -//==------------------------------------------------------------------------==// +// Base SVal types. +//==------------------------------------------------------------------------==// namespace clang { class MemRegion; class GRStateManager; -class RVal { +class SVal { public: - enum BaseKind { UndefinedKind, UnknownKind, LValKind, NonLValKind }; + enum BaseKind { UndefinedKind, UnknownKind, LocKind, NonLocKind }; enum { BaseBits = 2, BaseMask = 0x3 }; protected: @@ -37,18 +37,18 @@ protected: unsigned Kind; protected: - RVal(const void* d, bool isLVal, unsigned ValKind) + SVal(const void* d, bool isLoc, unsigned ValKind) : Data(const_cast<void*>(d)), - Kind((isLVal ? LValKind : NonLValKind) | (ValKind << BaseBits)) {} + Kind((isLoc ? LocKind : NonLocKind) | (ValKind << BaseBits)) {} - explicit RVal(BaseKind k, void* D = NULL) + explicit SVal(BaseKind k, void* D = NULL) : Data(D), Kind(k) {} public: - ~RVal() {}; + ~SVal() {}; - /// BufferTy - A temporary buffer to hold a set of RVals. - typedef llvm::SmallVector<RVal,5> BufferTy; + /// BufferTy - A temporary buffer to hold a set of SVals. + typedef llvm::SmallVector<SVal,5> BufferTy; inline unsigned getRawKind() const { return Kind; } inline BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); } @@ -59,16 +59,16 @@ public: ID.AddPointer(reinterpret_cast<void*>(Data)); } - inline bool operator==(const RVal& R) const { + inline bool operator==(const SVal& R) const { return getRawKind() == R.getRawKind() && Data == R.Data; } - inline bool operator!=(const RVal& R) const { + inline bool operator!=(const SVal& R) const { return !(*this == R); } - static RVal GetSymbolValue(SymbolManager& SymMgr, VarDecl *D); + static SVal GetSymbolValue(SymbolManager& SymMgr, VarDecl *D); inline bool isUnknown() const { return getRawKi |