diff options
-rw-r--r-- | include/clang/Analysis/PathSensitive/BugReporter.h | 28 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRExprEngine.h | 62 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRSimpleAPICheck.h | 4 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRTransferFuncs.h | 52 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/ValueState.h | 136 | ||||
-rw-r--r-- | lib/Analysis/BasicObjCFoundationChecks.cpp | 40 | ||||
-rw-r--r-- | lib/Analysis/BasicObjCFoundationChecks.h | 8 | ||||
-rw-r--r-- | lib/Analysis/BugReporter.cpp | 80 | ||||
-rw-r--r-- | lib/Analysis/CFRefCount.cpp | 218 | ||||
-rw-r--r-- | lib/Analysis/GRExprEngine.cpp | 124 | ||||
-rw-r--r-- | lib/Analysis/GRExprEngineInternalChecks.cpp | 22 | ||||
-rw-r--r-- | lib/Analysis/GRSimpleVals.cpp | 24 | ||||
-rw-r--r-- | lib/Analysis/GRSimpleVals.h | 16 | ||||
-rw-r--r-- | lib/Analysis/GRTransferFuncs.cpp | 14 | ||||
-rw-r--r-- | lib/Analysis/ValueState.cpp | 100 |
15 files changed, 464 insertions, 464 deletions
diff --git a/include/clang/Analysis/PathSensitive/BugReporter.h b/include/clang/Analysis/PathSensitive/BugReporter.h index f3e0208d6a..dddc81cc40 100644 --- a/include/clang/Analysis/PathSensitive/BugReporter.h +++ b/include/clang/Analysis/PathSensitive/BugReporter.h @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // // This file defines BugReporter, a utility class for generating -// PathDiagnostics for analyses based on ValueState. +// PathDiagnostics for analyses based on GRState. // //===----------------------------------------------------------------------===// @@ -17,7 +17,7 @@ #include "clang/Basic/Diagnostic.h" #include "clang/Basic/SourceLocation.h" -#include "clang/Analysis/PathSensitive/ValueState.h" +#include "clang/Analysis/PathSensitive/GRState.h" #include "clang/Analysis/PathSensitive/ExplodedGraph.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallSet.h" @@ -33,7 +33,7 @@ class ASTContext; class Diagnostic; class BugReporter; class GRExprEngine; -class ValueState; +class GRState; class Stmt; class BugReport; class ParentMap; @@ -51,7 +51,7 @@ public: } virtual void EmitWarnings(BugReporter& BR) {} - virtual void GetErrorNodes(std::vector<ExplodedNode<ValueState>*>& Nodes) {} + virtual void GetErrorNodes(std::vector<ExplodedNode<GRState>*>& Nodes) {} virtual bool isCached(BugReport& R) = 0; }; @@ -68,16 +68,16 @@ public: class BugReport { BugType& Desc; - ExplodedNode<ValueState> *EndNode; + ExplodedNode<GRState> *EndNode; SourceRange R; public: - BugReport(BugType& D, ExplodedNode<ValueState> *n) : Desc(D), EndNode(n) {} + BugReport(BugType& D, ExplodedNode<GRState> *n) : Desc(D), EndNode(n) {} virtual ~BugReport(); const BugType& getBugType() const { return Desc; } BugType& getBugType() { return Desc; } - ExplodedNode<ValueState>* getEndNode() const { return EndNode; } + ExplodedNode<GRState>* getEndNode() const { return EndNode; } Stmt* getStmt(BugReporter& BR) const; @@ -92,16 +92,16 @@ public: } virtual PathDiagnosticPiece* getEndPath(BugReporter& BR, - ExplodedNode<ValueState>* N); + ExplodedNode<GRState>* N); virtual FullSourceLoc getLocation(SourceManager& Mgr); virtual void getRanges(BugReporter& BR,const SourceRange*& beg, const SourceRange*& end); - virtual PathDiagnosticPiece* VisitNode(ExplodedNode<ValueState>* N, - ExplodedNode<ValueState>* PrevN, - ExplodedGraph<ValueState>& G, + virtual PathDiagnosticPiece* VisitNode(ExplodedNode<GRState>* N, + ExplodedNode<GRState>* PrevN, + ExplodedGraph<GRState>& G, BugReporter& BR); }; @@ -109,7 +109,7 @@ class RangedBugReport : public BugReport { std::vector<SourceRange> Ranges; const char* desc; public: - RangedBugReport(BugType& D, ExplodedNode<ValueState> *n, + RangedBugReport(BugType& D, ExplodedNode<GRState> *n, const char* description = 0) : BugReport(D, n), desc(description) {} @@ -227,9 +227,9 @@ public: return Eng; } - ExplodedGraph<ValueState>& getGraph(); + ExplodedGraph<GRState>& getGraph(); - ValueStateManager& getStateManager(); + GRStateManager& getStateManager(); virtual void GeneratePathDiagnostic(PathDiagnostic& PD, BugReport& R); diff --git a/include/clang/Analysis/PathSensitive/GRExprEngine.h b/include/clang/Analysis/PathSensitive/GRExprEngine.h index e9a36af295..69a5c45a31 100644 --- a/include/clang/Analysis/PathSensitive/GRExprEngine.h +++ b/include/clang/Analysis/PathSensitive/GRExprEngine.h @@ -17,7 +17,7 @@ #define LLVM_CLANG_ANALYSIS_GREXPRENGINE #include "clang/Analysis/PathSensitive/GRCoreEngine.h" -#include "clang/Analysis/PathSensitive/ValueState.h" +#include "clang/Analysis/PathSensitive/GRState.h" #include "clang/Analysis/PathSensitive/GRSimpleAPICheck.h" #include "clang/Analysis/PathSensitive/GRTransferFuncs.h" #include "clang/AST/Type.h" @@ -33,7 +33,7 @@ namespace clang { class GRExprEngine { public: - typedef ValueState StateTy; + typedef GRState StateTy; typedef ExplodedGraph<StateTy> GraphTy; typedef GraphTy::NodeTy NodeTy; @@ -57,15 +57,15 @@ protected: LiveVariables& Liveness; /// DeadSymbols - A scratch set used to record the set of symbols that - /// were just marked dead by a call to ValueStateManager::RemoveDeadBindings. - ValueStateManager::DeadSymbolsTy DeadSymbols; + /// were just marked dead by a call to GRStateManager::RemoveDeadBindings. + GRStateManager::DeadSymbolsTy DeadSymbols; /// Builder - The current GRStmtNodeBuilder which is used when building the /// nodes for a given statement. StmtNodeBuilder* Builder; /// StateMgr - Object that manages the data for all created states. - ValueStateManager StateMgr; + GRStateManager StateMgr; /// BugTypes - Objects used for reporting bugs. typedef std::vector<BugType*> BugTypeSet; @@ -79,7 +79,7 @@ protected: /// CleanedState - The state for EntryNode "cleaned" of all dead /// variables and symbols (as determined by a liveness analysis). - const ValueState* CleanedState; + const GRState* CleanedState; /// CurrentStmt - The current block-level statement. Stmt* CurrentStmt; @@ -202,7 +202,7 @@ public: /// getInitialState - Return the initial state used for the root vertex /// in the ExplodedGraph. - const ValueState* getInitialState(); + const GRState* getInitialState(); GraphTy& getGraph() { return G; } const GraphTy& getGraph() const { return G; } @@ -350,7 +350,7 @@ public: /// ProcessBlockEntrance - Called by GRCoreEngine when start processing /// a CFGBlock. This method returns true if the analysis should continue /// exploring the given path, and false otherwise. - bool ProcessBlockEntrance(CFGBlock* B, const ValueState* St, + bool ProcessBlockEntrance(CFGBlock* B, const GRState* St, GRBlockCounter BC); /// ProcessBranch - Called by GRCoreEngine. Used to generate successor @@ -371,8 +371,8 @@ public: getTF().EvalEndPath(*this, builder); } - ValueStateManager& getStateManager() { return StateMgr; } - const ValueStateManager& getStateManger() const { return StateMgr; } + GRStateManager& getStateManager() { return StateMgr; } + const GRStateManager& getStateManger() const { return StateMgr; } BasicValueFactory& getBasicVals() { return StateMgr.getBasicVals(); @@ -386,43 +386,43 @@ public: protected: - const ValueState* GetState(NodeTy* N) { + const GRState* GetState(NodeTy* N) { return N == EntryNode ? CleanedState : N->getState(); } public: - const ValueState* SetRVal(const ValueState* St, Expr* Ex, RVal V) { + const GRState* SetRVal(const GRState* St, Expr* Ex, RVal V) { return StateMgr.SetRVal(St, Ex, V); } - const ValueState* SetRVal(const ValueState* St, const Expr* Ex, RVal V) { + const GRState* SetRVal(const GRState* St, const Expr* Ex, RVal V) { return SetRVal(St, const_cast<Expr*>(Ex), V); } protected: - const ValueState* SetBlkExprRVal(const ValueState* St, Expr* Ex, RVal V) { + const GRState* SetBlkExprRVal(const GRState* St, Expr* Ex, RVal V) { return StateMgr.SetRVal(St, Ex, V, true, false); } - const ValueState* SetRVal(const ValueState* St, LVal LV, RVal V) { + const GRState* SetRVal(const GRState* St, LVal LV, RVal V) { return StateMgr.SetRVal(St, LV, V); } - RVal GetRVal(const ValueState* St, Expr* Ex) { + RVal GetRVal(const GRState* St, Expr* Ex) { return StateMgr.GetRVal(St, Ex); } - RVal GetRVal(const ValueState* St, const Expr* Ex) { + RVal GetRVal(const GRState* St, const Expr* Ex) { return GetRVal(St, const_cast<Expr*>(Ex)); } - RVal GetBlkExprRVal(const ValueState* St, Expr* Ex) { + RVal GetBlkExprRVal(const GRState* St, Expr* Ex) { return StateMgr.GetBlkExprRVal(St, Ex); } - RVal GetRVal(const ValueState* St, LVal LV, QualType T = QualType()) { + RVal GetRVal(const GRState* St, LVal LV, QualType T = QualType()) { return StateMgr.GetRVal(St, LV, T); } @@ -432,17 +432,17 @@ protected: /// Assume - Create new state by assuming that a given expression /// is true or false. - const ValueState* Assume(const ValueState* St, RVal Cond, bool Assumption, + const GRState* Assume(const GRState* St, RVal Cond, bool Assumption, bool& isFeasible) { return StateMgr.Assume(St, Cond, Assumption, isFeasible); } - const ValueState* Assume(const ValueState* St, LVal Cond, bool Assumption, + const GRState* Assume(const GRState* St, LVal Cond, bool Assumption, bool& isFeasible) { return StateMgr.Assume(St, Cond, Assumption, isFeasible); } - NodeTy* MakeNode(NodeSet& Dst, Stmt* S, NodeTy* Pred, const ValueState* St) { + NodeTy* MakeNode(NodeSet& Dst, Stmt* S, NodeTy* Pred, const GRState* St) { assert (Builder && "GRStmtNodeBuilder not present."); return Builder->MakeNode(Dst, S, Pred, St); } @@ -528,7 +528,7 @@ protected: void VisitUnaryOperator(UnaryOperator* B, NodeTy* Pred, NodeSet& Dst, bool asLVal); - bool CheckDivideZero(Expr* Ex, const ValueState* St, NodeTy* Pred, + bool CheckDivideZero(Expr* Ex, const GRState* St, NodeTy* Pred, RVal Denom); RVal EvalCast(RVal X, QualType CastT) { @@ -559,11 +559,11 @@ protected: cast<NonLVal>(R)) : R; } - void EvalBinOp(ExplodedNodeSet<ValueState>& Dst, Expr* Ex, + void EvalBinOp(ExplodedNodeSet<GRState>& Dst, Expr* Ex, BinaryOperator::Opcode Op, NonLVal L, NonLVal R, - ExplodedNode<ValueState>* Pred); + ExplodedNode<GRState>* Pred); - void EvalBinOp(ValueStateSet& OStates, const ValueState* St, Expr* Ex, + void EvalBinOp(GRStateSet& OStates, const GRState* St, Expr* Ex, BinaryOperator::Opcode Op, NonLVal L, NonLVal R); RVal EvalBinOp(BinaryOperator::Opcode Op, RVal L, RVal R) { @@ -607,22 +607,22 @@ protected: getTF().EvalObjCMessageExpr(Dst, *this, *Builder, ME, Pred); } - void EvalStore(NodeSet& Dst, Expr* E, NodeTy* Pred, const ValueState* St, + void EvalStore(NodeSet& Dst, Expr* E, NodeTy* Pred, const GRState* St, RVal TargetLV, RVal 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 ValueState* St, RVal location, bool CheckOnly = false); + const GRState* St, RVal location, bool CheckOnly = false); - const ValueState* EvalLocation(Expr* Ex, NodeTy* Pred, - const ValueState* St, RVal location, + const GRState* EvalLocation(Expr* Ex, NodeTy* Pred, + const GRState* St, RVal location, bool isLoad = false); void EvalReturn(NodeSet& Dst, ReturnStmt* s, NodeTy* Pred); - const ValueState* MarkBranch(const ValueState* 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/GRSimpleAPICheck.h b/include/clang/Analysis/PathSensitive/GRSimpleAPICheck.h index fcc9a0c3be..66b2fb1ae8 100644 --- a/include/clang/Analysis/PathSensitive/GRSimpleAPICheck.h +++ b/include/clang/Analysis/PathSensitive/GRSimpleAPICheck.h @@ -17,7 +17,7 @@ #define LLVM_CLANG_ANALYSIS_GRAPICHECKS #include "clang/Analysis/PathSensitive/GRAuditor.h" -#include "clang/Analysis/PathSensitive/ValueState.h" +#include "clang/Analysis/PathSensitive/GRState.h" namespace clang { @@ -29,7 +29,7 @@ class PathDiagnosticClient; template <typename T> class ExplodedGraph; -class GRSimpleAPICheck : public GRAuditor<ValueState> { +class GRSimpleAPICheck : public GRAuditor<GRState> { public: GRSimpleAPICheck() {} virtual ~GRSimpleAPICheck() {} diff --git a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h index 8a9b9741d4..dedb521a3f 100644 --- a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h +++ b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h @@ -17,7 +17,7 @@ #include "clang/Analysis/PathSensitive/RValues.h" #include "clang/Analysis/PathSensitive/GRCoreEngine.h" -#include "clang/Analysis/PathSensitive/ValueState.h" +#include "clang/Analysis/PathSensitive/GRState.h" namespace clang { @@ -31,7 +31,7 @@ class GRTransferFuncs { protected: - virtual RVal DetermEvalBinOpNN(ValueStateManager& StateMgr, + virtual RVal DetermEvalBinOpNN(GRStateManager& StateMgr, BinaryOperator::Opcode Op, NonLVal L, NonLVal R) { return UnknownVal(); @@ -42,7 +42,7 @@ public: GRTransferFuncs() {} virtual ~GRTransferFuncs() {} - virtual ValueState::CheckerStatePrinter* getCheckerStatePrinter() { + virtual GRState::CheckerStatePrinter* getCheckerStatePrinter() { return NULL; } @@ -60,8 +60,8 @@ public: virtual RVal EvalComplement(GRExprEngine& Engine, NonLVal X) = 0; // Binary Operators. - virtual void EvalBinOpNN(ValueStateSet& OStates, ValueStateManager& StateMgr, - const ValueState* St, Expr* Ex, + virtual void EvalBinOpNN(GRStateSet& OStates, GRStateManager& StateMgr, + const GRState* St, Expr* Ex, BinaryOperator::Opcode Op, NonLVal L, NonLVal R); virtual RVal EvalBinOp(GRExprEngine& Engine, BinaryOperator::Opcode Op, @@ -74,55 +74,55 @@ public: // Calls. - virtual void EvalCall(ExplodedNodeSet<ValueState>& Dst, + virtual void EvalCall(ExplodedNodeSet<GRState>& Dst, GRExprEngine& Engine, - GRStmtNodeBuilder<ValueState>& Builder, + GRStmtNodeBuilder<GRState>& Builder, CallExpr* CE, RVal L, - ExplodedNode<ValueState>* Pred) {} + ExplodedNode<GRState>* Pred) {} - virtual void EvalObjCMessageExpr(ExplodedNodeSet<ValueState>& Dst, + virtual void EvalObjCMessageExpr(ExplodedNodeSet<GRState>& Dst, GRExprEngine& Engine, - GRStmtNodeBuilder<ValueState>& Builder, + GRStmtNodeBuilder<GRState>& Builder, ObjCMessageExpr* ME, - ExplodedNode<ValueState>* Pred) {} + ExplodedNode<GRState>* Pred) {} // Stores. /// 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. - virtual void EvalStore(ExplodedNodeSet<ValueState>& Dst, + virtual void EvalStore(ExplodedNodeSet<GRState>& Dst, GRExprEngine& Engine, - GRStmtNodeBuilder<ValueState>& Builder, - Expr* E, ExplodedNode<ValueState>* Pred, - const ValueState* St, RVal TargetLV, RVal Val); + GRStmtNodeBuilder<GRState>& Builder, + Expr* E, ExplodedNode<GRState>* Pred, + const GRState* St, RVal TargetLV, RVal Val); // End-of-path and dead symbol notification. virtual void EvalEndPath(GRExprEngine& Engine, - GREndPathNodeBuilder<ValueState>& Builder) {} + GREndPathNodeBuilder<GRState>& Builder) {} - virtual void EvalDeadSymbols(ExplodedNodeSet<ValueState>& Dst, + virtual void EvalDeadSymbols(ExplodedNodeSet<GRState>& Dst, GRExprEngine& Engine, - GRStmtNodeBuilder<ValueState>& Builder, - ExplodedNode<ValueState>* Pred, + GRStmtNodeBuilder<GRState>& Builder, + ExplodedNode<GRState>* Pred, Stmt* S, - const ValueState* St, - const ValueStateManager::DeadSymbolsTy& Dead) {} + const GRState* St, + const GRStateManager::DeadSymbolsTy& Dead) {} // Return statements. - virtual void EvalReturn(ExplodedNodeSet<ValueState>& Dst, + virtual void EvalReturn(ExplodedNodeSet<GRState>& Dst, GRExprEngine& Engine, - GRStmtNodeBuilder<ValueState>& Builder, + GRStmtNodeBuilder<GRState>& Builder, ReturnStmt* S, - ExplodedNode<ValueState>* Pred) {} + ExplodedNode<GRState>* Pred) {} // Assumptions. - virtual const ValueState* EvalAssume(ValueStateManager& VMgr, - const ValueState* St, + virtual const GRState* EvalAssume(GRStateManager& VMgr, + const GRState* St, RVal Cond, bool Assumption, bool& isFeasible) { return St; diff --git a/include/clang/Analysis/PathSensitive/ValueState.h b/include/clang/Analysis/PathSensitive/ValueState.h index 8566c252c6..7605cb6f2c 100644 --- a/include/clang/Analysis/PathSensitive/ValueState.h +++ b/include/clang/Analysis/PathSensitive/ValueState.h @@ -1,4 +1,4 @@ -//== ValueState*h - Path-Sens. "State" for tracking valuues -----*- C++ -*--==// +//== GRState*h - Path-Sens. "State" for tracking valuues -----*- C++ -*--==// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file defines SymbolID, ExprBindKey, and ValueState* +// This file defines SymbolID, ExprBindKey, and GRState* // //===----------------------------------------------------------------------===// @@ -40,18 +40,18 @@ namespace clang { -class ValueStateManager; +class GRStateManager; class GRTransferFuncs; //===----------------------------------------------------------------------===// -// ValueState- An ImmutableMap type Stmt*/Decl*/Symbols to RVals. +// GRState- An ImmutableMap type Stmt*/Decl*/Symbols to RVals. //===----------------------------------------------------------------------===// -/// ValueState - This class encapsulates the actual data values for +/// GRState - This class encapsulates the actual data values for /// for a "state" in our symbolic value tracking. It is intended to be /// used as a functional object; that is once it is created and made /// "persistent" in a FoldingSet its values will never change. -class ValueState : public llvm::FoldingSetNode { +class GRState : public llvm::FoldingSetNode { public: // Typedefs. typedef llvm::ImmutableSet<llvm::APSInt*> IntSetTy; @@ -59,12 +59,12 @@ public: typedef llvm::ImmutableMap<SymbolID,IntSetTy> ConstNotEqTy; typedef llvm::ImmutableMap<SymbolID,const llvm::APSInt*> ConstEqTy; - typedef ValueStateManager ManagerTy; + typedef GRStateManager ManagerTy; private: - void operator=(const ValueState& R) const; + void operator=(const GRState& R) const; - friend class ValueStateManager; + friend class GRStateManager; Environment Env; Store St; @@ -78,8 +78,8 @@ public: public: - /// This ctor is used when creating the first ValueState object. - ValueState(const Environment& env, Store st, GenericDataMap gdm, + /// This ctor is used when creating the first GRState object. + GRState(const Environment& env, Store st, GenericDataMap gdm, ConstNotEqTy CNE, ConstEqTy CE) : Env(env), St(st), @@ -90,7 +90,7 @@ public: /// Copy ctor - We must explicitly define this or else the "Next" ptr /// in FoldingSetNode will also get copied. - ValueState(const ValueState& RHS) + GRState(const GRState& RHS) : llvm::FoldingSetNode(), Env(RHS.Env), St(RHS.St), @@ -110,9 +110,9 @@ public: /// getGDM - Return the generic data map associated with this state. GenericDataMap getGDM() const { return GDM; } - /// Profile - Profile the contents of a ValueState object for use + /// Profile - Profile the contents of a GRState object for use /// in a FoldingSet. - static void Profile(llvm::FoldingSetNodeID& ID, const ValueState* V) { + static void Profile(llvm::FoldingSetNodeID& ID, const GRState* V) { V->Env.Profile(ID); ID.AddPointer(V->St); V->GDM.Profile(ID); @@ -186,23 +186,23 @@ public: void printDOT(std::ostream& Out, CheckerStatePrinter*P = NULL) const; }; -template<> struct GRTrait<ValueState*> { - static inline void* toPtr(ValueState* St) { return (void*) St; } - static inline ValueState* toState(void* P) { return (ValueState*) P; } - static inline void Profile(llvm::FoldingSetNodeID& profile, ValueState* St) { +template<> struct GRTrait<GRState*> { + static inline void* toPtr(GRState* St) { return (void*) St; } + static inline GRState* toState(void* P) { return (GRState*) P; } + static inline void Profile(llvm::FoldingSetNodeID& profile, GRState* St) { // At this point states have already been uniqued. Just // add the pointer. profile.AddPointer(St); } }; -class ValueStateSet { - typedef llvm::SmallPtrSet<const ValueState*,5> ImplTy; +class GRStateSet { + typedef llvm::SmallPtrSet<const GRState*,5> ImplTy; ImplTy Impl; public: - ValueStateSet() {} + GRStateSet() {} - inline void Add(const ValueState* St) { + inline void Add(const GRState* St) { Impl.insert(St); } @@ -215,11 +215,11 @@ public: inline iterator end() const { return Impl.end(); } class AutoPopulate { - ValueStateSet& S; + GRStateSet& S; unsigned StartSize; - const ValueState* St; + const GRState* St; public: - AutoPopulate(ValueStateSet& s, const ValueState* st) + AutoPopulate(GRStateSet& s, const GRState* st) : S(s), StartSize(S.size()), St(st) {} ~AutoPopulate() { @@ -229,20 +229,20 @@ public: }; }; -class ValueStateManager { +class GRStateManager { friend class GRExprEngine; private: EnvironmentManager EnvMgr; llvm::OwningPtr<StoreManager> StMgr; - ValueState::IntSetTy::Factory ISetFactory; - ValueState::GenericDataMap::Factory GDMFactory; - ValueState::ConstNotEqTy::Factory CNEFactory; - ValueState::ConstEqTy::Factory CEFactory; + GRState::IntSetTy::Factory ISetFactory; + GRState::GenericDataMap::Factory GDMFactory; + GRState::ConstNotEqTy::Factory CNEFactory; + GRState::ConstEqTy::Factory CEFactory; /// StateSet - FoldingSet containing all the states created for analyzing /// a particular function. This is used to unique states. - llvm::FoldingSet<ValueState> StateSet; + llvm::FoldingSet<GRState> StateSet; /// ValueMgr - Object that manages the data for all created RVals. BasicValueFactory BasicVals; @@ -275,12 +275,12 @@ private: } // FIXME: Remove when we do lazy initializaton of variable bindings. - const ValueState* BindVar(const ValueState* St, VarDecl* D, RVal V) { + const GRState* BindVar(const GRState* St, VarDecl* D, RVal V) { return SetRVal(St, lval::DeclVal(D), V); } public: - ValueStateManager(ASTContext& Ctx, StoreManager* stmgr, + GRStateManager(ASTContext& Ctx, StoreManager* stmgr, llvm::BumpPtrAllocator& alloc, CFG& c) : EnvMgr(alloc), StMgr(stmgr), @@ -293,7 +293,7 @@ public: Alloc(alloc), cfg(c) {} - const ValueState* getInitialState(); + const GRState* getInitialState(); BasicValueFactory& getBasicVals() { return BasicVals; } const BasicValueFactory& getBasicVals() const { return BasicVals; } @@ -301,27 +301,27 @@ public: typedef StoreManager::DeadSymbolsTy DeadSymbolsTy; - const ValueState* RemoveDeadBindings(const ValueState* St, Stmt* Loc, + const GRState* RemoveDeadBindings(const GRState* St, Stmt* Loc, const LiveVariables& Liveness, DeadSymbolsTy& DeadSyms); - const ValueState* RemoveSubExprBindings(const ValueState* St) { - ValueState NewSt = *St; + const GRState* RemoveSubExprBindings(const GRState* St) { + GRState NewSt = *St; NewSt.Env = EnvMgr.RemoveSubExprBindings(NewSt.Env); return getPersistentState(NewSt); } // Methods that query & manipulate the Environment. - RVal GetRVal(const ValueState* St, Expr* Ex) { + RVal GetRVal(const GRState* St, Expr* Ex) { return St->getEnvironment().GetRVal(Ex, BasicVals); } - RVal GetBlkExprRVal(const ValueState* St, Expr* Ex) { + RVal GetBlkExprRVal(const GRState* St, Expr* Ex) { return St->getEnvironment().GetBlkExprRVal(Ex, BasicVals); } - const ValueState* SetRVal(const ValueState* St, Expr* Ex, RVal V, + const GRState* SetRVal(const GRState* St, Expr* Ex, RVal V, bool isBlkExpr, bool Invalidate) { const Environment& OldEnv = St->getEnvironment(); @@ -330,12 +330,12 @@ public: if (NewEnv == OldEnv) return St; - ValueState NewSt = *St; + GRState NewSt = *St; NewSt.Env = NewEnv; return getPersistentState(NewSt); } - const ValueState* SetRVal(const ValueState* St, Expr* Ex, RVal V) { + const GRState* SetRVal(const GRState* St, Expr* Ex, RVal V) { bool isBlkExpr = false; @@ -350,48 +350,48 @@ public: } // Methods that manipulate the GDM. - const ValueState* addGDM(const ValueState* St, void* Key, void* Data) { - ValueState::GenericDataMap M1 = St->getGDM(); - ValueState::GenericDataMap M2 = GDMFactory.Add(M2, Key, Data); + const GRState* addGDM(const GRState* St, void* Key, void* Data) { + GRState::GenericDataMap M1 = St->getGDM(); + GRState::GenericDataMap M2 = GDMFactory.Add(M2, Key, Data); if (M1 == M2) return St; - ValueState NewSt = *St; + GRState NewSt = *St; NewSt.GDM = M2; return getPersistentState(NewSt); } // Methods that query & manipulate the Store. - RVal GetRVal(const ValueState* St, LVal LV, QualType T = QualType()) { + RVal GetRVal(const GRState* St, LVal LV, QualType T = QualType()) { return StMgr->GetRVal(St->getStore(), LV, T); } - void SetRVal(ValueState& St, LVal LV, RVal V) { + void SetRVal(GRState& St, LVal LV, RVal V) { St.St = StMgr->SetRVal(St.St, LV, V); } - const ValueState* SetRVal(const ValueState* St, LVal LV, RVal V); + const GRState* SetRVal(const GRState* St, LVal LV, RVal V); - void Unbind(ValueState& St, LVal LV) { + void Unbind(GRState& St, LVal LV) { St.St = StMgr->Remove(St.St, LV); } - const ValueState* Unbind(const ValueState* St, LVal LV); + const GRState* Unbind(const GRState* St, LVal LV); - const ValueState* getPersistentState(ValueState& Impl); + const GRState* getPersistentState(GRState& Impl); - const ValueState* AddEQ(const ValueState* St, SymbolID sym, + const GRState* AddEQ(const GRState* St, SymbolID sym, const llvm::APSInt& V); - const ValueState* AddNE(const ValueState* St, SymbolID sym, + const GRState* AddNE(const GRState* St, SymbolID sym, const llvm::APSInt& V); - bool isEqual(const ValueState* state, Expr* Ex, const llvm::APSInt& V); - bool isEqual(const ValueState* state, Expr* Ex, uint64_t); + bool isEqual(const GRState* state, Expr* Ex, const llvm::APSInt& V); + bool isEqual(const GRState* state, Expr* Ex, uint64_t); // Assumption logic. - const ValueState* Assume(const ValueState* St, RVal Cond, bool Assumption, + const GRState* Assume(const GRState* St, RVal Cond, bool Assumption, bool& isFeasible) { if (Cond.isUnknown()) { @@ -405,39 +405,39 @@ public: return Assume(St, cast<NonLVal>(Cond), Assumption, isFeasible); } - const ValueState* Assume(const ValueState* St, LVal Cond, bool Assumption, + const GRState* Assume(const GRState* St, LVal Cond, bool Assumption, bool& isFeasible); - const ValueState* Assume(const ValueState* St, NonLVal Cond, bool Assumption, + const GRState* Assume(const GRState* St, NonLVal Cond, bool Assumption, bool& isFeasible); private: - const ValueState* AssumeAux(const ValueState* St, LVal Cond, bool Assumption, + const GRState* AssumeAux(const GRState* St, LVal Cond, bool Assumption, bool& isFeasible); - const ValueState* AssumeAux(const ValueState* St, NonLVal Cond, + const GRState* AssumeAux(const GRState* St, NonLVal Cond, bool Assumption, bool& isFeasible); - const ValueState* AssumeSymInt(const ValueState* St, bool Assumption, + const GRState* AssumeSymInt(const GRState* St, bool Assumption, const SymIntConstraint& C, bool& isFeasible); - const ValueState* AssumeSymNE(const ValueState* St, SymbolID sym, + const GRState* AssumeSymNE(const GRState* St, SymbolID sym, const llvm::APSInt& V, bool& isFeasible); - const ValueState* AssumeSymEQ(const ValueState* St, SymbolID sym, + const GRState* AssumeSymEQ(const GRState* St, SymbolID sym, const llvm::APSInt& V, bool& isFeasible); - const ValueState* AssumeSymLT(const ValueState* St, SymbolID sym, + const GRState* AssumeSymLT(const GRState* St, SymbolID sym, const llvm::APSInt& V, bool& isFeasible); - const ValueState* AssumeSymLE(const ValueState* St, SymbolID sym, + const GRState* AssumeSymLE(const GRState* St, SymbolID sym, const llvm::APSInt& V, bool& isFeasible); - const ValueState* AssumeSymGT(const ValueState* St, SymbolID sym, + const GRState* AssumeSymGT(const GRState* St, SymbolID sym, const llvm::APSInt& V, bool& isFeasible); - const ValueState* AssumeSymGE(const ValueState* St, SymbolID sym, + const GRState* AssumeSymGE(const GRState* St, SymbolID sym, const llvm::APSInt& V, bool& isFeasible); }; diff --git a/lib/Analysis/BasicObjCFoundationChecks.cpp b/lib/Analysis/BasicObjCFoundationChecks.cpp index 29c0b92432..236cbed013 100644 --- a/lib/Analysis/BasicObjCFoundationChecks.cpp +++ b/lib/Analysis/BasicObjCFoundationChecks.cpp @@ -18,7 +18,7 @@ #include "clang/Analysis/PathSensitive/ExplodedGraph.h" #include "clang/Analysis/PathSensitive/GRSimpleAPICheck.h" #include "clang/Analysis/PathSensitive/GRExprEngine.h" -#include "clang/Analysis/PathSensitive/ValueState.h" +#include "clang/Analysis/PathSensitive/GRState.h" #include "clang/Analysis/PathSensitive/BugReporter.h" #include "clang/Analysis/PathDiagnostic.h" #include "clang/Analysis/LocalCheckers.h" @@ -73,7 +73,7 @@ public: SourceRange R; public: - Report(NilArg& Desc, ExplodedNode<ValueState>* N, + Report(NilArg& Desc, ExplodedNode<GRState>* N, ObjCMessageExpr* ME, unsigned Arg) : BugReport(Desc, N) { @@ -105,12 +105,12 @@ public: class VISIBILITY_HIDDEN BasicObjCFoundationChecks : public GRSimpleAPICheck { NilArg Desc; ASTContext &Ctx; - ValueStateManager* VMgr; + GRStateManager* VMgr; typedef std::vector<BugReport*> ErrorsTy; ErrorsTy Errors; - RVal GetRVal(const ValueState* St, Expr* E) { return VMgr->GetRVal(St, E); } + RVal GetRVal(const GRState* St, Expr* E) { return VMgr->GetRVal(St, E); } bool isNSString(ObjCInterfaceType* T, const char* suffix); bool AuditNSString(NodeTy* N, ObjCMessageExpr* ME); @@ -121,7 +121,7 @@ class VISIBILITY_HIDDEN BasicObjCFoundationChecks : public GRSimpleAPICheck { bool CheckNilArg(NodeTy* N, unsigned Arg); public: - BasicObjCFoundationChecks(ASTContext& ctx, ValueStateManager* vmgr) + BasicObjCFoundationChecks(ASTContext& ctx, GRStateManager* vmgr) : Ctx(ctx), VMgr(vmgr) {} virtual ~BasicObjCFoundationChecks() { @@ |