diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-08-06 01:32:16 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-08-06 01:32:16 +0000 |
commit | c5619d901a68dc27a9e310a6a831f03efebcd950 (patch) | |
tree | 182ee9df6e543f6a7cbb063fccb62ba1c3548932 | |
parent | a10f7eabea651c5ba71569e69143dd77008f2a56 (diff) |
As GRState seems general enough, it is time to merge some template classes
and their impl base classes. This can greatly simply some code of the core
analysis engine. This patch merges ExplodedNodeImpl into ExplodedNode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78270 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Analysis/PathSensitive/BugReporter.h | 40 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/Checker.h | 20 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/ExplodedGraph.h | 225 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRAuditor.h | 2 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRCoreEngine.h | 88 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRExprEngine.h | 2 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRTransferFuncs.h | 16 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRWorkList.h | 12 | ||||
-rw-r--r-- | lib/Analysis/BasicObjCFoundationChecks.cpp | 16 | ||||
-rw-r--r-- | lib/Analysis/BugReporter.cpp | 104 | ||||
-rw-r--r-- | lib/Analysis/BugReporterVisitors.cpp | 24 | ||||
-rw-r--r-- | lib/Analysis/CFRefCount.cpp | 126 | ||||
-rw-r--r-- | lib/Analysis/ExplodedGraph.cpp | 74 | ||||
-rw-r--r-- | lib/Analysis/GRCoreEngine.cpp | 54 | ||||
-rw-r--r-- | lib/Analysis/GRExprEngine.cpp | 20 | ||||
-rw-r--r-- | lib/Analysis/GRExprEngineInternalChecks.cpp | 48 | ||||
-rw-r--r-- | lib/Frontend/AnalysisConsumer.cpp | 16 |
17 files changed, 433 insertions, 454 deletions
diff --git a/include/clang/Analysis/PathSensitive/BugReporter.h b/include/clang/Analysis/PathSensitive/BugReporter.h index 485299518a..a414208269 100644 --- a/include/clang/Analysis/PathSensitive/BugReporter.h +++ b/include/clang/Analysis/PathSensitive/BugReporter.h @@ -48,8 +48,8 @@ class ParentMap; class BugReporterVisitor { public: virtual ~BugReporterVisitor(); - virtual PathDiagnosticPiece* VisitNode(const ExplodedNode<GRState>* N, - const ExplodedNode<GRState>* PrevN, + virtual PathDiagnosticPiece* VisitNode(const ExplodedNode* N, + const ExplodedNode* PrevN, BugReporterContext& BRC) = 0; virtual bool isOwnedByReporterContext() { return true; } @@ -61,7 +61,7 @@ protected: BugType& BT; std::string ShortDescription; std::string Description; - const ExplodedNode<GRState> *EndNode; + const ExplodedNode *EndNode; SourceRange R; protected: @@ -76,15 +76,15 @@ public: class NodeResolver { public: virtual ~NodeResolver() {} - virtual const ExplodedNode<GRState>* - getOriginalNode(const ExplodedNode<GRState>* N) = 0; + virtual const ExplodedNode* + getOriginalNode(const ExplodedNode* N) = 0; }; - BugReport(BugType& bt, const char* desc, const ExplodedNode<GRState> *n) + BugReport(BugType& bt, const char* desc, const ExplodedNode *n) : BT(bt), Description(desc), EndNode(n) {} BugReport(BugType& bt, const char* shortDesc, const char* desc, - const ExplodedNode<GRState> *n) + const ExplodedNode *n) : BT(bt), ShortDescription(shortDesc), Description(desc), EndNode(n) {} virtual ~BugReport(); @@ -95,7 +95,7 @@ public: BugType& getBugType() { return BT; } // FIXME: Perhaps this should be moved into a subclass? - const ExplodedNode<GRState>* getEndNode() const { return EndNode; } + const ExplodedNode* getEndNode() const { return EndNode; } // FIXME: Do we need this? Maybe getLocation() should return a ProgramPoint // object. @@ -116,7 +116,7 @@ public: // FIXME: Perhaps move this into a subclass. virtual PathDiagnosticPiece* getEndPath(BugReporterContext& BRC, - const ExplodedNode<GRState>* N); + const ExplodedNode* N); /// getLocation - Return the "definitive" location of the reported bug. /// While a bug can span an entire path, usually there is a specific @@ -128,12 +128,12 @@ public: virtual void getRanges(BugReporter& BR,const SourceRange*& beg, const SourceRange*& end); - virtual PathDiagnosticPiece* VisitNode(const ExplodedNode<GRState>* N, - const ExplodedNode<GRState>* PrevN, + virtual PathDiagnosticPiece* VisitNode(const ExplodedNode* N, + const ExplodedNode* PrevN, BugReporterContext& BR); virtual void registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode<GRState>* N) {} + const ExplodedNode* N) {} }; //===----------------------------------------------------------------------===// @@ -217,11 +217,11 @@ public: class RangedBugReport : public BugReport { std::vector<SourceRange> Ranges; public: - RangedBugReport(BugType& D, const char* description, ExplodedNode<GRState> *n) + RangedBugReport(BugType& D, const char* description, ExplodedNode *n) : BugReport(D, description, n) {} RangedBugReport(BugType& D, const char *shortDescription, - const char *description, ExplodedNode<GRState> *n) + const char *description, ExplodedNode *n) : BugReport(D, shortDescription, description, n) {} ~RangedBugReport(); @@ -465,14 +465,14 @@ public: namespace bugreporter { -const Stmt *GetDerefExpr(const ExplodedNode<GRState> *N); -const Stmt *GetReceiverExpr(const ExplodedNode<GRState> *N); -const Stmt *GetDenomExpr(const ExplodedNode<GRState> *N); -const Stmt *GetCalleeExpr(const ExplodedNode<GRState> *N); -const Stmt *GetRetValExpr(const ExplodedNode<GRState> *N); +const Stmt *GetDerefExpr(const ExplodedNode *N); +const Stmt *GetReceiverExpr(const ExplodedNode *N); +const Stmt *GetDenomExpr(const ExplodedNode *N); +const Stmt *GetCalleeExpr(const ExplodedNode *N); +const Stmt *GetRetValExpr(const ExplodedNode *N); void registerTrackNullOrUndefValue(BugReporterContext& BRC, const Stmt *S, - const ExplodedNode<GRState>* N); + const ExplodedNode* N); } // end namespace clang::bugreporter diff --git a/include/clang/Analysis/PathSensitive/Checker.h b/include/clang/Analysis/PathSensitive/Checker.h index f70b6129c4..f3011cc90f 100644 --- a/include/clang/Analysis/PathSensitive/Checker.h +++ b/include/clang/Analysis/PathSensitive/Checker.h @@ -30,20 +30,20 @@ namespace clang { class GRExprEngine; class CheckerContext { - ExplodedNodeSet<GRState> &Dst; + ExplodedNodeSet &Dst; GRStmtNodeBuilder<GRState> &B; GRExprEngine &Eng; - ExplodedNode<GRState> *Pred; + ExplodedNode *Pred; SaveAndRestore<bool> OldSink; SaveAndRestore<const void*> OldTag; SaveAndRestore<ProgramPoint::Kind> OldPointKind; SaveOr OldHasGen; public: - CheckerContext(ExplodedNodeSet<GRState> &dst, + CheckerContext(ExplodedNodeSet &dst, GRStmtNodeBuilder<GRState> &builder, GRExprEngine &eng, - ExplodedNode<GRState> *pred, + ExplodedNode *pred, const void *tag, bool preVisit) : Dst(dst), B(builder), Eng(eng), Pred(pred), OldSink(B.BuildSinks), OldTag(B.Tag), @@ -62,17 +62,17 @@ public: ConstraintManager &getConstraintManager() { return Eng.getConstraintManager(); } - ExplodedNodeSet<GRState> &getNodeSet() { return Dst; } + ExplodedNodeSet &getNodeSet() { return Dst; } GRStmtNodeBuilder<GRState> &getNodeBuilder() { return B; } - ExplodedNode<GRState> *&getPredecessor() { return Pred; } + ExplodedNode *&getPredecessor() { return Pred; } const GRState *getState() { return B.GetState(Pred); } - ExplodedNode<GRState> *generateNode(const Stmt* S, + ExplodedNode *generateNode(const Stmt* S, const GRState *state) { return B.generateNode(S, state, Pred); } - void addTransition(ExplodedNode<GRState> *node) { + void addTransition(ExplodedNode *node) { Dst.Add(node); } @@ -85,11 +85,11 @@ class Checker { private: friend class GRExprEngine; - void GR_Visit(ExplodedNodeSet<GRState> &Dst, + void GR_Visit(ExplodedNodeSet &Dst, GRStmtNodeBuilder<GRState> &Builder, GRExprEngine &Eng, const Stmt *stmt, - ExplodedNode<GRState> *Pred, bool isPrevisit) { + ExplodedNode *Pred, bool isPrevisit) { CheckerContext C(Dst, Builder, Eng, Pred, getTag(), isPrevisit); assert(isPrevisit && "Only previsit supported for now."); _PreVisit(C, stmt); diff --git a/include/clang/Analysis/PathSensitive/ExplodedGraph.h b/include/clang/Analysis/PathSensitive/ExplodedGraph.h index 53b3330905..73cfd9cce6 100644 --- a/include/clang/Analysis/PathSensitive/ExplodedGraph.h +++ b/include/clang/Analysis/PathSensitive/ExplodedGraph.h @@ -28,8 +28,9 @@ namespace clang { +class GRState; class GRCoreEngineImpl; -class ExplodedNodeImpl; +class ExplodedNode; class CFG; class ASTContext; @@ -45,7 +46,7 @@ class GREndPathNodebuilderImpl; // on top of these classes. //===----------------------------------------------------------------------===// -class ExplodedNodeImpl : public llvm::FoldingSetNode { +class ExplodedNode : public llvm::FoldingSetNode { protected: friend class ExplodedGraphImpl; friend class GRCoreEngineImpl; @@ -68,8 +69,8 @@ protected: return reinterpret_cast<void*>(P & ~Mask); } - ExplodedNodeImpl* getNode() const { - return reinterpret_cast<ExplodedNodeImpl*>(getPtr()); + ExplodedNode *getNode() const { + return reinterpret_cast<ExplodedNode*>(getPtr()); } public: @@ -77,15 +78,15 @@ protected: ~NodeGroup(); - ExplodedNodeImpl** begin() const; + ExplodedNode** begin() const; - ExplodedNodeImpl** end() const; + ExplodedNode** end() const; unsigned size() const; bool empty() const { return size() == 0; } - void addNode(ExplodedNodeImpl* N); + void addNode(ExplodedNode* N); void setFlag() { assert (P == 0); @@ -102,30 +103,40 @@ protected: const ProgramPoint Location; /// State - The state associated with this node. - const void* State; + const GRState* State; /// Preds - The predecessors of this node. NodeGroup Preds; /// Succs - The successors of this node. NodeGroup Succs; - - /// Construct a ExplodedNodeImpl with the provided location and state. - explicit ExplodedNodeImpl(const ProgramPoint& loc, const void* state) - : Location(loc), State(state) {} - - /// addPredeccessor - Adds a predecessor to the current node, and - /// in tandem add this node as a successor of the other node. - void addPredecessor(ExplodedNodeImpl* V); - + public: - + + explicit ExplodedNode(const ProgramPoint& loc, const GRState* state) + : Location(loc), State(state) {} + /// getLocation - Returns the edge associated with the given node. ProgramPoint getLocation() const { return Location; } - + + const GRState* getState() const { + return State; + } + template <typename T> const T* getLocationAs() const { return llvm::dyn_cast<T>(&Location); } - + + static void Profile(llvm::FoldingSetNodeID &ID, + const ProgramPoint& Loc, const GRState* state); + + void Profile(llvm::FoldingSetNodeID& ID) const { + Profile(ID, getLocation(), getState()); + } + + /// addPredeccessor - Adds a predecessor to the current node, and + /// in tandem add this node as a successor of the other node. + void addPredecessor(ExplodedNode* V); + unsigned succ_size() const { return Succs.size(); } unsigned pred_size() const { return Preds.size(); } bool succ_empty() const { return Succs.empty(); } @@ -133,59 +144,7 @@ public: bool isSink() const { return Succs.getFlag(); } void markAsSink() { Succs.setFlag(); } - - // For debugging. - -public: - - class Auditor { - public: - virtual ~Auditor(); - virtual void AddEdge(ExplodedNodeImpl* Src, ExplodedNodeImpl* Dst) = 0; - }; - - static void SetAuditor(Auditor* A); -}; - - -template <typename StateTy> -struct GRTrait { - static inline void Profile(llvm::FoldingSetNodeID& ID, const StateTy* St) { - St->Profile(ID); - } -}; - -template <typename StateTy> -class ExplodedNode : public ExplodedNodeImpl { -public: - /// Construct a ExplodedNodeImpl with the given node ID, program edge, - /// and state. - explicit ExplodedNode(const ProgramPoint& loc, const StateTy* St) - : ExplodedNodeImpl(loc, St) {} - - /// getState - Returns the state associated with the node. - inline const StateTy* getState() const { - return static_cast<const StateTy*>(State); - } - - // Profiling (for FoldingSet). - - static inline void Profile(llvm::FoldingSetNodeID& ID, - const ProgramPoint& Loc, - const StateTy* state) { - ID.Add(Loc); - GRTrait<StateTy>::Profile(ID, state); - } - - inline void Profile(llvm::FoldingSetNodeID& ID) const { - Profile(ID, getLocation(), getState()); - } - - void addPredecessor(ExplodedNode* V) { - ExplodedNodeImpl::addPredecessor(V); - } - ExplodedNode* getFirstPred() { return pred_empty() ? NULL : *(pred_begin()); } @@ -200,8 +159,8 @@ public: typedef ExplodedNode** pred_iterator; typedef const ExplodedNode* const * const_pred_iterator; - pred_iterator pred_begin() { return (ExplodedNode**) Preds.begin(); } - pred_iterator pred_end() { return (ExplodedNode**) Preds.end(); } + pred_iterator pred_begin() { return Preds.begin(); } + pred_iterator pred_end() { return Preds.end(); } const_pred_iterator pred_begin() const { return const_cast<ExplodedNode*>(this)->pred_begin(); @@ -210,8 +169,8 @@ public: return const_cast<ExplodedNode*>(this)->pred_end(); } - succ_iterator succ_begin() { return (ExplodedNode**) Succs.begin(); } - succ_iterator succ_end() { return (ExplodedNode**) Succs.end(); } + succ_iterator succ_begin() { return Succs.begin(); } + succ_iterator succ_end() { return Succs.end(); } const_succ_iterator succ_begin() const { return const_cast<ExplodedNode*>(this)->succ_begin(); @@ -219,6 +178,26 @@ public: const_succ_iterator succ_end() const { return const_cast<ExplodedNode*>(this)->succ_end(); } + + // For debugging. + +public: + + class Auditor { + public: + virtual ~Auditor(); + virtual void AddEdge(ExplodedNode* Src, ExplodedNode* Dst) = 0; + }; + + static void SetAuditor(Auditor* A); +}; + + +template <typename StateTy> +struct GRTrait { + static inline void Profile(llvm::FoldingSetNodeID& ID, const StateTy* St) { + St->Profile(ID); + } }; class InterExplodedGraphMapImpl; @@ -233,8 +212,8 @@ protected: friend class GREndPathNodeBuilderImpl; // Type definitions. - typedef llvm::SmallVector<ExplodedNodeImpl*,2> RootsTy; - typedef llvm::SmallVector<ExplodedNodeImpl*,10> EndNodesTy; + typedef llvm::SmallVector<ExplodedNode*,2> RootsTy; + typedef llvm::SmallVector<ExplodedNode*,10> EndNodesTy; /// Roots - The roots of the simulation graph. Usually there will be only /// one, but clients are free to establish multiple subgraphs within a single @@ -265,20 +244,20 @@ protected: /// getNodeImpl - Retrieve the node associated with a (Location,State) /// pair, where 'State' is represented as an opaque void*. This method /// is intended to be used only by GRCoreEngineImpl. - virtual ExplodedNodeImpl* getNodeImpl(const ProgramPoint& L, + virtual ExplodedNode* getNodeImpl(const ProgramPoint& L, const void* State, bool* IsNew) = 0; virtual ExplodedGraphImpl* MakeEmptyGraph() const = 0; /// addRoot - Add an untyped node to the set of roots. - ExplodedNodeImpl* addRoot(ExplodedNodeImpl* V) { + ExplodedNode* addRoot(ExplodedNode* V) { Roots.push_back(V); return V; } /// addEndOfPath - Add an untyped node to the set of EOP nodes. - ExplodedNodeImpl* addEndOfPath(ExplodedNodeImpl* V) { + ExplodedNode* addEndOfPath(ExplodedNode* V) { EndNodes.push_back(V); return V; } @@ -307,22 +286,21 @@ public: return llvm::dyn_cast<FunctionDecl>(&CodeDecl); } - typedef llvm::DenseMap<const ExplodedNodeImpl*, ExplodedNodeImpl*> NodeMap; + typedef llvm::DenseMap<const ExplodedNode*, ExplodedNode*> NodeMap; - ExplodedGraphImpl* Trim(const ExplodedNodeImpl* const * NBeg, - const ExplodedNodeImpl* const * NEnd, + ExplodedGraphImpl* Trim(const ExplodedNode* const * NBeg, + const ExplodedNode* const * NEnd, InterExplodedGraphMapImpl *M, - llvm::DenseMap<const void*, const void*> *InverseMap) - const; + llvm::DenseMap<const void*, const void*> *InverseMap) const; }; class InterExplodedGraphMapImpl { - llvm::DenseMap<const ExplodedNodeImpl*, ExplodedNodeImpl*> M; + llvm::DenseMap<const ExplodedNode*, ExplodedNode*> M; friend class ExplodedGraphImpl; - void add(const ExplodedNodeImpl* From, ExplodedNodeImpl* To); + void add(const ExplodedNode* From, ExplodedNode* To); protected: - ExplodedNodeImpl* getMappedImplNode(const ExplodedNodeImpl* N) const; + ExplodedNode* getMappedImplNode(const ExplodedNode* N) const; InterExplodedGraphMapImpl(); public: @@ -333,14 +311,13 @@ public: // Type-specialized ExplodedGraph classes. //===----------------------------------------------------------------------===// -template <typename STATE> class InterExplodedGraphMap : public InterExplodedGraphMapImpl { public: InterExplodedGraphMap() {}; ~InterExplodedGraphMap() {}; - ExplodedNode<STATE>* getMappedNode(const ExplodedNode<STATE>* N) const { - return static_cast<ExplodedNode<STATE>*>(getMappedImplNode(N)); + ExplodedNode* getMappedNode(const ExplodedNode* N) const { + return static_cast<ExplodedNode*>(getMappedImplNode(N)); } }; @@ -348,21 +325,21 @@ template <typename STATE> class ExplodedGraph : public ExplodedGraphImpl { public: typedef STATE StateTy; - typedef ExplodedNode<StateTy> NodeTy; + typedef ExplodedNode NodeTy; typedef llvm::FoldingSet<NodeTy> AllNodesTy; protected: - /// Nodes - The nodes in the graph. - AllNodesTy Nodes; - -protected: - virtual ExplodedNodeImpl* getNodeImpl(const ProgramPoint& L, - const void* State, - bool* IsNew) { + virtual ExplodedNode* getNodeImpl(const ProgramPoint& L, + const void* State, + bool* IsNew) { return getNode(L, static_cast<const StateTy*>(State), IsNew); } + + /// Nodes - The nodes in the graph. + AllNodesTy Nodes; +protected: virtual ExplodedGraphImpl* MakeEmptyGraph() const { return new ExplodedGraph(cfg, CodeDecl, Ctx); } @@ -375,7 +352,7 @@ public: /// where the 'Location' is a ProgramPoint in the CFG. If no node for /// this pair exists, it is created. IsNew is set to true if /// the node was freshly created. - NodeTy* getNode(const ProgramPoint& L, const StateTy* State, + NodeTy* getNode(const ProgramPoint& L, const GRState* State, bool* IsNew = NULL) { // Profile 'State' to determine if we already have an existing node. @@ -459,23 +436,22 @@ public: return const_cast<ExplodedGraph>(this)->eop_end(); } - std::pair<ExplodedGraph*, InterExplodedGraphMap<STATE>*> + std::pair<ExplodedGraph*, InterExplodedGraphMap*> Trim(const NodeTy* const* NBeg, const NodeTy* const* NEnd, llvm::DenseMap<const void*, const void*> *InverseMap = 0) const { if (NBeg == NEnd) return std::make_pair((ExplodedGraph*) 0, - (InterExplodedGraphMap<STATE>*) 0); + (InterExplodedGraphMap*) 0); assert (NBeg < NEnd); - const ExplodedNodeImpl* const* NBegImpl = - (const ExplodedNodeImpl* const*) NBeg; - const ExplodedNodeImpl* const* NEndImpl = - (const ExplodedNodeImpl* const*) NEnd; + const ExplodedNode* const* NBegImpl = + (const ExplodedNode* const*) NBeg; + const ExplodedNode* const* NEndImpl = + (const ExplodedNode* const*) NEnd; - llvm::OwningPtr<InterExplodedGraphMap<STATE> > - M(new InterExplodedGraphMap<STATE>()); + llvm::OwningPtr<InterExplodedGraphMap> M(new InterExplodedGraphMap()); ExplodedGraphImpl* G = ExplodedGraphImpl::Trim(NBegImpl, NEndImpl, M.get(), InverseMap); @@ -484,23 +460,20 @@ public: } }; -template <typename StateTy> class ExplodedNodeSet { - - typedef ExplodedNode<StateTy> NodeTy; - typedef llvm::SmallPtrSet<NodeTy*,5> ImplTy; + typedef llvm::SmallPtrSet<ExplodedNode*,5> ImplTy; ImplTy Impl; public: - ExplodedNodeSet(NodeTy* N) { - assert (N && !static_cast<ExplodedNodeImpl*>(N)->isSink()); + ExplodedNodeSet(ExplodedNode* N) { + assert (N && !static_cast<ExplodedNode*>(N)->isSink()); Impl.insert(N); } ExplodedNodeSet() {} - inline void Add(NodeTy* N) { - if (N && !static_cast<ExplodedNodeImpl*>(N)->isSink()) Impl.insert(N); + inline void Add(ExplodedNode* N) { + if (N && !static_cast<ExplodedNode*>(N)->isSink()) Impl.insert(N); } ExplodedNodeSet& operator=(const ExplodedNodeSet &X) { @@ -508,8 +481,8 @@ public: return *this; } - typedef typename ImplTy::iterator iterator; - typedef typename ImplTy::const_iterator const_iterator; + typedef ImplTy::iterator iterator; + typedef ImplTy::const_iterator const_iterator; inline unsigned size() const { return Impl.size(); } inline bool empty() const { return Impl.empty(); } @@ -528,10 +501,9 @@ public: // GraphTraits namespace llvm { - template<typename StateTy> - struct GraphTraits<clang::ExplodedNode<StateTy>*> { - typedef clang::ExplodedNode<StateTy> NodeType; - typedef typename NodeType::succ_iterator ChildIteratorType; + template<> struct GraphTraits<clang::ExplodedNode*> { + typedef clang::ExplodedNode NodeType; + typedef NodeType::succ_iterator ChildIteratorType; typedef llvm::df_iterator<NodeType*> nodes_iterator; static inline NodeType* getEntryNode(NodeType* N) { @@ -555,10 +527,9 @@ namespace llvm { } }; - template<typename StateTy> - struct GraphTraits<const clang::ExplodedNode<StateTy>*> { - typedef const clang::ExplodedNode<StateTy> NodeType; - typedef typename NodeType::succ_iterator ChildIteratorType; + template<> struct GraphTraits<const clang::ExplodedNode*> { + typedef const clang::ExplodedNode NodeType; + typedef NodeType::const_succ_iterator ChildIteratorType; typedef llvm::df_iterator<NodeType*> nodes_iterator; static inline NodeType* getEntryNode(NodeType* N) { diff --git a/include/clang/Analysis/PathSensitive/GRAuditor.h b/include/clang/Analysis/PathSensitive/GRAuditor.h index eca591d4af..eda1985da9 100644 --- a/include/clang/Analysis/PathSensitive/GRAuditor.h +++ b/include/clang/Analysis/PathSensitive/GRAuditor.h @@ -26,7 +26,7 @@ namespace clang { template <typename STATE> class GRAuditor { public: - typedef ExplodedNode<STATE> NodeTy; + typedef ExplodedNode NodeTy; typedef typename STATE::ManagerTy ManagerTy; virtual ~GRAuditor() {} diff --git a/include/clang/Analysis/PathSensitive/GRCoreEngine.h b/include/clang/Analysis/PathSensitive/GRCoreEngine.h index 8fb2506fa1..a8c741f748 100644 --- a/include/clang/Analysis/PathSensitive/GRCoreEngine.h +++ b/include/clang/Analysis/PathSensitive/GRCoreEngine.h @@ -62,7 +62,7 @@ protected: GRBlockCounter::Factory BCounterFactory; void GenerateNode(const ProgramPoint& Loc, const void* State, - ExplodedNodeImpl* Pred); + ExplodedNode* Pred); /// getInitialState - Gets the void* representing the initial 'state' /// of the analysis. This is simply a wrapper (implemented @@ -70,14 +70,14 @@ protected: /// state returned by the checker object. virtual const void* getInitialState() = 0; - void HandleBlockEdge(const BlockEdge& E, ExplodedNodeImpl* Pred); - void HandleBlockEntrance(const BlockEntrance& E, ExplodedNodeImpl* Pred); - void HandleBlockExit(CFGBlock* B, ExplodedNodeImpl* Pred); + void HandleBlockEdge(const BlockEdge& E, ExplodedNode* Pred); + void HandleBlockEntrance(const BlockEntrance& E, ExplodedNode* Pred); + void HandleBlockExit(CFGBlock* B, ExplodedNode* Pred); void HandlePostStmt(const PostStmt& S, CFGBlock* B, - unsigned StmtIdx, ExplodedNodeImpl *Pred); + unsigned StmtIdx, ExplodedNode *Pred); void HandleBranch(Stmt* Cond, Stmt* Term, CFGBlock* B, - ExplodedNodeImpl* Pred); + ExplodedNode* Pred); virtual void ProcessEndPath(GREndPathNodeBuilderImpl& Builder) = 0; @@ -115,23 +115,23 @@ class GRStmtNodeBuilderImpl { GRCoreEngineImpl& Eng; CFGBlock& B; const unsigned Idx; - ExplodedNodeImpl* Pred; - ExplodedNodeImpl* LastNode; + ExplodedNode* Pred; + ExplodedNode* LastNode; - typedef llvm::SmallPtrSet<ExplodedNodeImpl*,5> DeferredTy; + typedef llvm::SmallPtrSet<ExplodedNode*,5> DeferredTy; DeferredTy Deferred; - void GenerateAutoTransition(ExplodedNodeImpl* N); + void GenerateAutoTransition(ExplodedNode* N); public: GRStmtNodeBuilderImpl(CFGBlock* b, unsigned idx, - ExplodedNodeImpl* N, GRCoreEngineImpl* e); + ExplodedNode* N, GRCoreEngineImpl* e); ~GRStmtNodeBuilderImpl(); - ExplodedNodeImpl* getBasePredecessor() const { return Pred; } + ExplodedNode* getBasePredecessor() const { return Pred; } - ExplodedNodeImpl* getLastNode() const { + ExplodedNode* getLastNode() const { return LastNode ? (LastNode->isSink() ? NULL : LastNode) : NULL; } @@ -141,27 +141,27 @@ public: return getBlockCounter().getNumVisited(B.getBlockID()); } - ExplodedNodeImpl* + ExplodedNode* generateNodeImpl(const ProgramPoint &PP, const void* State, - ExplodedNodeImpl* Pred); + ExplodedNode* Pred); - ExplodedNodeImpl* - generateNodeImpl(const Stmt* S, const void* State, ExplodedNodeImpl* Pred, + ExplodedNode* + generateNodeImpl(const Stmt* S, const void* State, ExplodedNode* Pred, ProgramPoint::Kind K = ProgramPoint::PostStmtKind, const void *tag = 0); - ExplodedNodeImpl* + ExplodedNode* generateNodeImpl(const Stmt* S, const void* State, ProgramPoint::Kind K = ProgramPoint::PostStmtKind, const void *tag = 0) { - ExplodedNodeImpl* N = getLastNode(); + ExplodedNode* N = getLastNode(); assert (N && "Predecessor of new node is infeasible."); return generateNodeImpl(S, State, N, K, tag); } - ExplodedNodeImpl* + ExplodedNode* generateNodeImpl(const Stmt* S, const void* State, const void *tag = 0) { - ExplodedNodeImpl* N = getLastNode(); + ExplodedNode* N = getLastNode(); assert (N && "Predecessor of new node is infeasible."); return generateNodeImpl(S, State, N, ProgramPoint::PostStmtKind, tag); } @@ -181,7 +181,7 @@ class GRStmtNodeBuilder { public: typedef STATE StateTy; typedef typename StateTy::ManagerTy StateManagerTy; - typedef ExplodedNode<StateTy> NodeTy; + typedef ExplodedNode NodeTy; private: GRStmtNodeBuilderImpl& NB; @@ -242,7 +242,7 @@ public: } const StateTy* GetState(NodeTy* Pred) const { - if ((ExplodedNodeImpl*) Pred == NB.getBasePredecessor()) + if ((ExplodedNode*) Pred == NB.getBasePredecessor()) return CleanedState; else return Pred->getState(); @@ -252,12 +252,12 @@ public: CleanedState = St; } - NodeTy* MakeNode(ExplodedNodeSet<StateTy>& Dst, Stmt* S, + NodeTy* MakeNode(ExplodedNodeSet& Dst, Stmt* S, NodeTy* Pred, const StateTy* St) { return MakeNode(Dst, S, Pred, St, PointKind); } - NodeTy* MakeNode(ExplodedNodeSet<StateTy>& Dst, Stmt* S, + NodeTy* MakeNode(ExplodedNodeSet& Dst, Stmt* S, NodeTy* Pred, const StateTy* St, ProgramPoint::Kind K) { const StateTy* PredState = GetState(Pred); @@ -284,7 +284,7 @@ public: return N; } - NodeTy* MakeSinkNode(ExplodedNodeSet<StateTy>& Dst, Stmt* S, + NodeTy* MakeSinkNode(ExplodedNodeSet& Dst, Stmt* S, NodeTy* Pred, const StateTy* St) { bool Tmp = BuildSinks; BuildSinks = true; @@ -305,9 +305,9 @@ class GRBranchNodeBuilderImpl { CFGBlock* Src; CFGBlock* DstT; CFGBlock* DstF; - ExplodedNodeImpl* Pred; + ExplodedNode* Pred; - typedef llvm::SmallVector<ExplodedNodeImpl*,3> DeferredTy; + typedef llvm::SmallVector<ExplodedNode*,3> DeferredTy; DeferredTy Deferred; bool GeneratedTrue; @@ -317,18 +317,18 @@ class GRBranchNodeBuilderImpl { public: GRBranchNodeBuilderImpl(CFGBlock* src, CFGBlock* dstT, CFGBlock* dstF, - ExplodedNodeImpl* pred, GRCoreEngineImpl* e) + ExplodedNode* pred, GRCoreEngineImpl* e) : Eng(*e), Src(src), DstT(dstT), DstF(dstF), Pred(pred), GeneratedTrue(false), GeneratedFalse(false), InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {} ~GRBranchNodeBuilderImpl(); - ExplodedNodeImpl* getPredecessor() const { return Pred; } + ExplodedNode* getPredecessor() const { return Pred; } const ExplodedGraphImpl& getGraph() const { return *Eng.G; } GRBlockCounter getBlockCounter() const { return Eng.WList->getBlockCounter();} - ExplodedNodeImpl* generateNodeImpl(const void* State, bool branch); + ExplodedNode* generateNodeImpl(const void* State, bool branch); CFGBlock* getTargetBlock(bool branch) const { return branch ? DstT : DstF; @@ -395,9 +395,9 @@ class GRIndirectGotoNodeBuilderImpl { CFGBlock* Src; CFGBlock& DispatchBlock; Expr* E; - ExplodedNodeImpl* Pred; + ExplodedNode* Pred; public: - GRIndirectGotoNodeBuilderImpl(ExplodedNodeImpl* pred, CFGBlock* src, + GRIndirectGotoNodeBuilderImpl(ExplodedNode* pred, CFGBlock* src, Expr* e, CFGBlock* dispatch, GRCoreEngineImpl* eng) : Eng(*eng), Src(src), DispatchBlock(*dispatch), E(e), Pred(pred) {} @@ -425,7 +425,7 @@ public: Iterator begin() { return Iterator(DispatchBlock.succ_begin()); } Iterator end() { return Iterator(DispatchBlock.succ_end()); } - ExplodedNodeImpl* generateNodeImpl(const Iterator& I, const void* State, + ExplodedNode* generateNodeImpl(const Iterator& I, const void* State, bool isSink); Expr* getTarget() const { return E; } @@ -463,9 +463,9 @@ class GRSwitchNodeBuilderImpl { GRCoreEngineImpl& Eng; CFGBlock* Src; Expr* Condition; - ExplodedNodeImpl* Pred; + ExplodedNode* Pred; public: - GRSwitchNodeBuilderImpl(ExplodedNodeImpl* pred, CFGBlock* src, + GRSwitchNodeBuilderImpl(ExplodedNode* pred, CFGBlock* src, Expr* condition, GRCoreEngineImpl* eng) : Eng(*eng), Src(src), Condition(condition), Pred(pred) {} @@ -491,10 +491,10 @@ public: Iterator begin() { return Iterator(Src->succ_rbegin()+1); } Iterator end() { return Iterator(Src->succ_rend()); } - ExplodedNodeImpl* generateCaseStmtNodeImpl(const Iterator& I, + ExplodedNode* generateCaseStmtNodeImpl(const Iterator& I, const void* State); - ExplodedNodeImpl* generateDefaultCaseNodeImpl(const void* State, + ExplodedNode* generateDefaultCaseNodeImpl(const void* State, bool isSink); Expr* getCondition() const { return Condition; } |