From c5619d901a68dc27a9e310a6a831f03efebcd950 Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Thu, 6 Aug 2009 01:32:16 +0000 Subject: [PATCH] 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 --- .../Analysis/PathSensitive/BugReporter.h | 40 ++-- .../clang/Analysis/PathSensitive/Checker.h | 20 +- .../Analysis/PathSensitive/ExplodedGraph.h | 225 ++++++++---------- .../clang/Analysis/PathSensitive/GRAuditor.h | 2 +- .../Analysis/PathSensitive/GRCoreEngine.h | 88 +++---- .../Analysis/PathSensitive/GRExprEngine.h | 2 +- .../Analysis/PathSensitive/GRTransferFuncs.h | 16 +- .../clang/Analysis/PathSensitive/GRWorkList.h | 12 +- lib/Analysis/BasicObjCFoundationChecks.cpp | 16 +- lib/Analysis/BugReporter.cpp | 104 ++++---- lib/Analysis/BugReporterVisitors.cpp | 24 +- lib/Analysis/CFRefCount.cpp | 126 +++++----- lib/Analysis/ExplodedGraph.cpp | 74 +++--- lib/Analysis/GRCoreEngine.cpp | 54 ++--- lib/Analysis/GRExprEngine.cpp | 20 +- lib/Analysis/GRExprEngineInternalChecks.cpp | 48 ++-- 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* N, - const ExplodedNode* 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 *EndNode; + const ExplodedNode *EndNode; SourceRange R; protected: @@ -76,15 +76,15 @@ public: class NodeResolver { public: virtual ~NodeResolver() {} - virtual const ExplodedNode* - getOriginalNode(const ExplodedNode* N) = 0; + virtual const ExplodedNode* + getOriginalNode(const ExplodedNode* N) = 0; }; - BugReport(BugType& bt, const char* desc, const ExplodedNode *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 *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* 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* 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* N, - const ExplodedNode* PrevN, + virtual PathDiagnosticPiece* VisitNode(const ExplodedNode* N, + const ExplodedNode* PrevN, BugReporterContext& BR); virtual void registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode* N) {} + const ExplodedNode* N) {} }; //===----------------------------------------------------------------------===// @@ -217,11 +217,11 @@ public: class RangedBugReport : public BugReport { std::vector Ranges; public: - RangedBugReport(BugType& D, const char* description, ExplodedNode *n) + RangedBugReport(BugType& D, const char* description, ExplodedNode *n) : BugReport(D, description, n) {} RangedBugReport(BugType& D, const char *shortDescription, - const char *description, ExplodedNode *n) + const char *description, ExplodedNode *n) : BugReport(D, shortDescription, description, n) {} ~RangedBugReport(); @@ -465,14 +465,14 @@ public: namespace bugreporter { -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); +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* 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 &Dst; + ExplodedNodeSet &Dst; GRStmtNodeBuilder &B; GRExprEngine &Eng; - ExplodedNode *Pred; + ExplodedNode *Pred; SaveAndRestore OldSink; SaveAndRestore OldTag; SaveAndRestore OldPointKind; SaveOr OldHasGen; public: - CheckerContext(ExplodedNodeSet &dst, + CheckerContext(ExplodedNodeSet &dst, GRStmtNodeBuilder &builder, GRExprEngine &eng, - ExplodedNode *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 &getNodeSet() { return Dst; } + ExplodedNodeSet &getNodeSet() { return Dst; } GRStmtNodeBuilder &getNodeBuilder() { return B; } - ExplodedNode *&getPredecessor() { return Pred; } + ExplodedNode *&getPredecessor() { return Pred; } const GRState *getState() { return B.GetState(Pred); } - ExplodedNode *generateNode(const Stmt* S, + ExplodedNode *generateNode(const Stmt* S, const GRState *state) { return B.generateNode(S, state, Pred); } - void addTransition(ExplodedNode *node) { + void addTransition(ExplodedNode *node) { Dst.Add(node); } @@ -85,11 +85,11 @@ class Checker { private: friend class GRExprEngine; - void GR_Visit(ExplodedNodeSet &Dst, + void GR_Visit(ExplodedNodeSet &Dst, GRStmtNodeBuilder &Builder, GRExprEngine &Eng, const Stmt *stmt, - ExplodedNode *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(P & ~Mask); } - ExplodedNodeImpl* getNode() const { - return reinterpret_cast(getPtr()); + ExplodedNode *getNode() const { + return reinterpret_cast(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 const T* getLocationAs() const { return llvm::dyn_cast(&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 -struct GRTrait { - static inline void Profile(llvm::FoldingSetNodeID& ID, const StateTy* St) { - St->Profile(ID); - } -}; - - -template -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(State); - } - - // Profiling (for FoldingSet). - - static inline void Profile(llvm::FoldingSetNodeID& ID, - const ProgramPoint& Loc, - const StateTy* state) { - ID.Add(Loc); - GRTrait::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(this)->pred_begin(); @@ -210,8 +169,8 @@ public: return const_cast(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(this)->succ_begin(); @@ -219,6 +178,26 @@ public: const_succ_iterator succ_end() const { return const_cast(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 +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 RootsTy; - typedef llvm::SmallVector EndNodesTy; + typedef llvm::SmallVector RootsTy; + typedef llvm::SmallVector 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(&CodeDecl); } - typedef llvm::DenseMap NodeMap; + typedef llvm::DenseMap 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 *InverseMap) - const; + llvm::DenseMap *InverseMap) const; }; class InterExplodedGraphMapImpl { - llvm::DenseMap M; + llvm::DenseMap 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 class InterExplodedGraphMap : public InterExplodedGraphMapImpl { public: InterExplodedGraphMap() {}; ~InterExplodedGraphMap() {}; - ExplodedNode* getMappedNode(const ExplodedNode* N) const { - return static_cast*>(getMappedImplNode(N)); + ExplodedNode* getMappedNode(const ExplodedNode* N) const { + return static_cast(getMappedImplNode(N)); } }; @@ -348,21 +325,21 @@ template class ExplodedGraph : public ExplodedGraphImpl { public: typedef STATE StateTy; - typedef ExplodedNode NodeTy; + typedef ExplodedNode NodeTy; typedef llvm::FoldingSet AllNodesTy; protected: + virtual ExplodedNode* getNodeImpl(const ProgramPoint& L, + const void* State, + bool* IsNew) { + + return getNode(L, static_cast(State), IsNew); + } + /// Nodes - The nodes in the graph. AllNodesTy Nodes; protected: - virtual ExplodedNodeImpl* getNodeImpl(const ProgramPoint& L, - const void* State, - bool* IsNew) { - - return getNode(L, static_cast(State), IsNew); - } - 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(this)->eop_end(); } - std::pair*> + std::pair Trim(const NodeTy* const* NBeg, const NodeTy* const* NEnd, llvm::DenseMap *InverseMap = 0) const { if (NBeg == NEnd) return std::make_pair((ExplodedGraph*) 0, - (InterExplodedGraphMap*) 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 > - M(new InterExplodedGraphMap()); + llvm::OwningPtr M(new InterExplodedGraphMap()); ExplodedGraphImpl* G = ExplodedGraphImpl::Trim(NBegImpl, NEndImpl, M.get(), InverseMap); @@ -484,23 +460,20 @@ public: } }; -template class ExplodedNodeSet { - - typedef ExplodedNode NodeTy; - typedef llvm::SmallPtrSet ImplTy; + typedef llvm::SmallPtrSet ImplTy; ImplTy Impl; public: - ExplodedNodeSet(NodeTy* N) { - assert (N && !static_cast(N)->isSink()); + ExplodedNodeSet(ExplodedNode* N) { + assert (N && !static_cast(N)->isSink()); Impl.insert(N); } ExplodedNodeSet() {} - inline void Add(NodeTy* N) { - if (N && !static_cast(N)->isSink()) Impl.insert(N); + inline void Add(ExplodedNode* N) { + if (N && !static_cast(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 - struct GraphTraits*> { - typedef clang::ExplodedNode NodeType; - typedef typename NodeType::succ_iterator ChildIteratorType; + template<> struct GraphTraits { + typedef clang::ExplodedNode NodeType; + typedef NodeType::succ_iterator ChildIteratorType; typedef llvm::df_iterator nodes_iterator; static inline NodeType* getEntryNode(NodeType* N) { @@ -555,10 +527,9 @@ namespace llvm { } }; - template - struct GraphTraits*> { - typedef const clang::ExplodedNode NodeType; - typedef typename NodeType::succ_iterator ChildIteratorType; + template<> struct GraphTraits { + typedef const clang::ExplodedNode NodeType; + typedef NodeType::const_succ_iterator ChildIteratorType; typedef llvm::df_iterator 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 class GRAuditor { public: - typedef ExplodedNode 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 DeferredTy; + typedef llvm::SmallPtrSet 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 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& Dst, Stmt* S, + NodeTy* MakeNode(ExplodedNodeSet& Dst, Stmt* S, NodeTy* Pred, const StateTy* St) { return MakeNode(Dst, S, Pred, St, PointKind); } - NodeTy* MakeNode(ExplodedNodeSet& 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& 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 DeferredTy; + typedef llvm::SmallVector 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; } @@ -536,17 +536,17 @@ public: class GREndPathNodeBuilderImpl { GRCoreEngineImpl& Eng; CFGBlock& B; - ExplodedNodeImpl* Pred; + ExplodedNode* Pred; bool HasGeneratedNode; public: - GREndPathNodeBuilderImpl(CFGBlock* b, ExplodedNodeImpl* N, + GREndPathNodeBuilderImpl(CFGBlock* b, ExplodedNode* N, GRCoreEngineImpl* e) : Eng(*e), B(*b), Pred(N), HasGeneratedNode(false) {} ~GREndPathNodeBuilderImpl(); - ExplodedNodeImpl* getPredecessor() const { return Pred; } + ExplodedNode* getPredecessor() const { return Pred; } GRBlockCounter getBlockCounter() const { return Eng.WList->getBlockCounter();} @@ -554,9 +554,9 @@ public: return getBlockCounter().getNumVisited(B.getBlockID()); } - ExplodedNodeImpl* generateNodeImpl(const void* State, + ExplodedNode* generateNodeImpl(const void* State, const void *tag = 0, - ExplodedNodeImpl *P = 0); + ExplodedNode *P = 0); CFGBlock* getBlock() const { return &B; } }; @@ -565,7 +565,7 @@ public: template class GREndPathNodeBuilder { typedef STATE StateTy; - typedef ExplodedNode NodeTy; + typedef ExplodedNode NodeTy; GREndPathNodeBuilderImpl& NB; diff --git a/include/clang/Analysis/PathSensitive/GRExprEngine.h b/include/clang/Analysis/PathSensitive/GRExprEngine.h index 534b595c0d..53456ca287 100644 --- a/include/clang/Analysis/PathSensitive/GRExprEngine.h +++ b/include/clang/Analysis/PathSensitive/GRExprEngine.h @@ -43,7 +43,7 @@ public: typedef GRIndirectGotoNodeBuilder IndirectGotoNodeBuilder; typedef GRSwitchNodeBuilder SwitchNodeBuilder; typedef GREndPathNodeBuilder EndPathNodeBuilder; - typedef ExplodedNodeSet NodeSet; + typedef ExplodedNodeSet NodeSet; protected: GRCoreEngine CoreEngine; diff --git a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h index db23f81e2d..3bb37cc74c 100644 --- a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h +++ b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h @@ -38,17 +38,17 @@ public: // Calls. - virtual void EvalCall(ExplodedNodeSet& Dst, + virtual void EvalCall(ExplodedNodeSet& Dst, GRExprEngine& Engine, GRStmtNodeBuilder& Builder, CallExpr* CE, SVal L, - ExplodedNode* Pred) {} + ExplodedNode* Pred) {} - virtual void EvalObjCMessageExpr(ExplodedNodeSet& Dst, + virtual void EvalObjCMessageExpr(ExplodedNodeSet& Dst, GRExprEngine& Engine, GRStmtNodeBuilder& Builder, ObjCMessageExpr* ME, - ExplodedNode* Pred) {} + ExplodedNode* Pred) {} // Stores. @@ -60,19 +60,19 @@ public: GREndPathNodeBuilder& Builder) {} - virtual void EvalDeadSymbols(ExplodedNodeSet& Dst, + virtual void EvalDeadSymbols(ExplodedNodeSet& Dst, GRExprEngine& Engine, GRStmtNodeBuilder& Builder, - ExplodedNode* Pred, + ExplodedNode* Pred, Stmt* S, const GRState* state, SymbolReaper& SymReaper) {} // Return statements. - virtual void EvalReturn(ExplodedNodeSet& Dst, + virtual void EvalReturn(ExplodedNodeSet& Dst, GRExprEngine& Engine, GRStmtNodeBuilder& Builder, ReturnStmt* S, - ExplodedNode* Pred) {} + ExplodedNode* Pred) {} // Assumptions. virtual const GRState* EvalAssume(const GRState *state, diff --git a/include/clang/Analysis/PathSensitive/GRWorkList.h b/include/clang/Analysis/PathSensitive/GRWorkList.h index c76532294c..b423e88072 100644 --- a/include/clang/Analysis/PathSensitive/GRWorkList.h +++ b/include/clang/Analysis/PathSensitive/GRWorkList.h @@ -22,26 +22,26 @@ namespace clang { class ExplodedNodeImpl; class GRWorkListUnit { - ExplodedNodeImpl* Node; + ExplodedNode* Node; GRBlockCounter Counter; CFGBlock* Block; unsigned BlockIdx; public: - GRWorkListUnit(ExplodedNodeImpl* N, GRBlockCounter C, + GRWorkListUnit(ExplodedNode* N, GRBlockCounter C, CFGBlock* B, unsigned idx) : Node(N), Counter(C), Block(B), BlockIdx(idx) {} - explicit GRWorkListUnit(ExplodedNodeImpl* N, GRBlockCounter C) + explicit GRWorkListUnit(ExplodedNode* N, GRBlockCounter C) : Node(N), Counter(C), Block(NULL), BlockIdx(0) {} - ExplodedNodeImpl* getNode() const { return Node; } + ExplodedNode* getNode() const { return Node; } GRBlockCounter getBlockCounter() const { return Counter; } CFGBlock* getBlock() const { return Block; } unsigned getIndex() const { return BlockIdx; } @@ -55,11 +55,11 @@ public: virtual void Enqueue(const GRWorkListUnit& U) = 0; - void Enqueue(ExplodedNodeImpl* N, CFGBlock& B, unsigned idx) { + void Enqueue(ExplodedNode* N, CFGBlock& B, unsigned idx) { Enqueue(GRWorkListUnit(N, CurrentCounter, &B, idx)); } - void Enqueue(ExplodedNodeImpl* N) { + void Enqueue(ExplodedNode* N) { Enqueue(GRWorkListUnit(N, CurrentCounter)); } diff --git a/lib/Analysis/BasicObjCFoundationChecks.cpp b/lib/Analysis/BasicObjCFoundationChecks.cpp index 684c88c998..d7631bc2c2 100644 --- a/lib/Analysis/BasicObjCFoundationChecks.cpp +++ b/lib/Analysis/BasicObjCFoundationChecks.cpp @@ -74,7 +74,7 @@ public: BasicObjCFoundationChecks(ASTContext& ctx, BugReporter& br) : BT(0), BR(br), Ctx(ctx) {} - bool Audit(ExplodedNode* N, GRStateManager&); + bool Audit(ExplodedNode* N, GRStateManager&); private: void WarnNilArg(NodeTy* N, const ObjCMessageExpr* ME, unsigned Arg) { @@ -103,7 +103,7 @@ clang::CreateBasicObjCFoundationChecks(ASTContext& Ctx, BugReporter& BR) { -bool BasicObjCFoundationChecks::Audit(ExplodedNode* N, +bool BasicObjCFoundationChecks::Audit(ExplodedNode* N, GRStateManager&) { const ObjCMessageExpr* ME = @@ -254,10 +254,10 @@ public: ~AuditCFNumberCreate() {} - bool Audit(ExplodedNode* N, GRStateManager&); + bool Audit(ExplodedNode* N, GRStateManager&); private: - void AddError(const TypedRegion* R, const Expr* Ex, ExplodedNode *N, + void AddError(const TypedRegion* R, const Expr* Ex, ExplodedNode *N, uint64_t SourceSize, uint64_t TargetSize, uint64_t NumberKind); }; } // end anonymous namespace @@ -355,7 +355,7 @@ static const char* GetCFNumberTypeStr(uint64_t i) { } #endif -bool AuditCFNumberCreate::Audit(ExplodedNode* N,GRStateManager&){ +bool AuditCFNumberCreate::Audit(ExplodedNode* N,GRStateManager&){ const CallExpr* CE = cast(cast(N->getLocation()).getStmt()); const Expr* Callee = CE->getCallee(); @@ -422,7 +422,7 @@ bool AuditCFNumberCreate::Audit(ExplodedNode* N,GRStateManager&){ } void AuditCFNumberCreate::AddError(const TypedRegion* R, const Expr* Ex, - ExplodedNode *N, + ExplodedNode *N, uint64_t SourceSize, uint64_t TargetSize, uint64_t NumberKind) { @@ -478,12 +478,12 @@ public: ~AuditCFRetainRelease() {} - bool Audit(ExplodedNode* N, GRStateManager&); + bool Audit(ExplodedNode* N, GRStateManager&); }; } // end anonymous namespace -bool AuditCFRetainRelease::Audit(ExplodedNode* N, GRStateManager&) { +bool AuditCFRetainRelease::Audit(ExplodedNode* N, GRStateManager&) { const CallExpr* CE = cast(cast(N->getLocation()).getStmt()); // If the CallExpr doesn't have exactly 1 argument just give up checking. diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp index f00583e8c4..19a031a1ae 100644 --- a/lib/Analysis/BugReporter.cpp +++ b/lib/Analysis/BugReporter.cpp @@ -49,17 +49,17 @@ static inline const Stmt* GetStmt(ProgramPoint P) { return 0; } -static inline const ExplodedNode* -GetPredecessorNode(const ExplodedNode* N) { +static inline const ExplodedNode* +GetPredecessorNode(const ExplodedNode* N) { return N->pred_empty() ? NULL : *(N->pred_begin()); } -static inline const ExplodedNode* -GetSuccessorNode(const ExplodedNode* N) { +static inline const ExplodedNode* +GetSuccessorNode(const ExplodedNode* N) { return N->succ_empty() ? NULL : *(N->succ_begin()); } -static const Stmt* GetPreviousStmt(const ExplodedNode* N) { +static const Stmt* GetPreviousStmt(const ExplodedNode* N) { for (N = GetPredecessorNode(N); N; N = GetPredecessorNode(N)) if (const Stmt *S = GetStmt(N->getLocation())) return S; @@ -67,7 +67,7 @@ static const Stmt* GetPreviousStmt(const ExplodedNode* N) { return 0; } -static const Stmt* GetNextStmt(const ExplodedNode* N) { +static const Stmt* GetNextStmt(const ExplodedNode* N) { for (N = GetSuccessorNode(N); N; N = GetSuccessorNode(N)) if (const Stmt *S = GetStmt(N->getLocation())) { // Check if the statement is '?' or '&&'/'||'. These are "merges", @@ -96,7 +96,7 @@ static const Stmt* GetNextStmt(const ExplodedNode* N) { } static inline const Stmt* -GetCurrentOrPreviousStmt(const ExplodedNode* N) { +GetCurrentOrPreviousStmt(const ExplodedNode* N) { if (const Stmt *S = GetStmt(N->getLocation())) return S; @@ -104,7 +104,7 @@ GetCurrentOrPreviousStmt(const ExplodedNode* N) { } static inline const Stmt* -GetCurrentOrNextStmt(const ExplodedNode* N) { +GetCurrentOrNextStmt(const ExplodedNode* N) { if (const Stmt *S = GetStmt(N->getLocation())) return S; @@ -115,8 +115,8 @@ GetCurrentOrNextStmt(const ExplodedNode* N) { // PathDiagnosticBuilder and its associated routines and helper objects. //===----------------------------------------------------------------------===// -typedef llvm::DenseMap*, -const ExplodedNode*> NodeBackMap; +typedef llvm::DenseMap NodeBackMap; namespace { class VISIBILITY_HIDDEN NodeMapClosure : public BugReport::NodeResolver { @@ -125,7 +125,7 @@ public: NodeMapClosure(NodeBackMap *m) : M(*m) {} ~NodeMapClosure() {} - const ExplodedNode* getOriginalNode(const ExplodedNode* N) { + const ExplodedNode* getOriginalNode(const ExplodedNode* N) { NodeBackMap::iterator I = M.find(N); return I == M.end() ? 0 : I->second; } @@ -146,10 +146,10 @@ public: addVisitor(R); } - PathDiagnosticLocation ExecutionContinues(const ExplodedNode* N); + PathDiagnosticLocation ExecutionContinues(const ExplodedNode* N); PathDiagnosticLocation ExecutionContinues(llvm::raw_string_ostream& os, - const ExplodedNode* N); + const ExplodedNode* N); ParentMap& getParentMap() { if (PM.get() == 0) @@ -185,7 +185,7 @@ public: } // end anonymous namespace PathDiagnosticLocation -PathDiagnosticBuilder::ExecutionContinues(const ExplodedNode* N) { +PathDiagnosticBuilder::ExecutionContinues(const ExplodedNode* N) { if (const Stmt *S = GetNextStmt(N)) return PathDiagnosticLocation(S, getSourceManager()); @@ -194,7 +194,7 @@ PathDiagnosticBuilder::ExecutionContinues(const ExplodedNode* N) { PathDiagnosticLocation PathDiagnosticBuilder::ExecutionContinues(llvm::raw_string_ostream& os, - const ExplodedNode* N) { + const ExplodedNode* N) { // Slow, but probably doesn't matter. if (os.str().empty()) @@ -327,7 +327,7 @@ PathDiagnosticBuilder::getEnclosingStmtLocation(const Stmt *S) { //===----------------------------------------------------------------------===// static const VarDecl* -GetMostRecentVarDeclBinding(const ExplodedNode* N, +GetMostRecentVarDeclBinding(const ExplodedNode* N, GRStateManager& VMgr, SVal X) { for ( ; N ; N = N->pred_empty() ? 0 : *N->pred_begin()) { @@ -366,14 +366,14 @@ class VISIBILITY_HIDDEN NotableSymbolHandler const GRState* PrevSt; const Stmt* S; GRStateManager& VMgr; - const ExplodedNode* Pred; + const ExplodedNode* Pred; PathDiagnostic& PD; BugReporter& BR; public: NotableSymbolHandler(SymbolRef sym, const GRState* prevst, const Stmt* s, - GRStateManager& vmgr, const ExplodedNode* pred, + GRStateManager& vmgr, const ExplodedNode* pred, PathDiagnostic& pd, BugReporter& br) : Sym(sym), PrevSt(prevst), S(s), VMgr(vmgr), Pred(pred), PD(pd), BR(br) {} @@ -440,12 +440,12 @@ public: }; } -static void HandleNotableSymbol(const ExplodedNode* N, +static void HandleNotableSymbol(const ExplodedNode* N, const Stmt* S, SymbolRef Sym, BugReporter& BR, PathDiagnostic& PD) { - const ExplodedNode* Pred = N->pred_empty() ? 0 : *N->pred_begin(); + const ExplodedNode* Pred = N->pred_empty() ? 0 : *N->pred_begin(); const GRState* PrevSt = Pred ? Pred->getState() : 0; if (!PrevSt) @@ -463,13 +463,13 @@ class VISIBILITY_HIDDEN ScanNotableSymbols : public StoreManager::BindingsHandler { llvm::SmallSet AlreadyProcessed; - const ExplodedNode* N; + const ExplodedNode* N; const Stmt* S; GRBugReporter& BR; PathDiagnostic& PD; public: - ScanNotableSymbols(const ExplodedNode* n, const Stmt* s, + ScanNotableSymbols(const ExplodedNode* n, const Stmt* s, GRBugReporter& br, PathDiagnostic& pd) : N(n), S(s), BR(br), PD(pd) {} @@ -503,10 +503,10 @@ static void CompactPathDiagnostic(PathDiagnostic &PD, const SourceManager& SM); static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD, PathDiagnosticBuilder &PDB, - const ExplodedNode *N) { + const ExplodedNode *N) { SourceManager& SMgr = PDB.getSourceManager(); - const ExplodedNode* NextNode = N->pred_empty() + const ExplodedNode* NextNode = N->pred_empty() ? NULL : *(N->pred_begin()); while (NextNode) { N = NextNode; @@ -1113,12 +1113,12 @@ void EdgeBuilder::addContext(const Stmt *S) { static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD, PathDiagnosticBuilder &PDB, - const ExplodedNode *N) { + const ExplodedNode *N) { EdgeBuilder EB(PD, PDB); - const ExplodedNode* NextNode = N->pred_empty() + const ExplodedNode* NextNode = N->pred_empty() ? NULL : *(N->pred_begin()); while (NextNode) { N = NextNode; @@ -1221,7 +1221,7 @@ const Stmt* BugReport::getStmt(BugReporter& BR) const { PathDiagnosticPiece* BugReport::getEndPath(BugReporterContext& BRC, - const ExplodedNode* EndPathNode) { + const ExplodedNode* EndPathNode) { const Stmt* S = getStmt(BRC.getBugReporter()); @@ -1269,8 +1269,8 @@ SourceLocation BugReport::getLocation() const { return FullSourceLoc(); } -PathDiagnosticPiece* BugReport::VisitNode(const ExplodedNode* N, - const ExplodedNode* PrevN, +PathDiagnosticPiece* BugReport::VisitNode(const ExplodedNode* N, + const ExplodedNode* PrevN, BugReporterContext &BRC) { return NULL; } @@ -1333,17 +1333,17 @@ void BugReporter::FlushReports() { //===----------------------------------------------------------------------===// static std::pair*, NodeBackMap*>, - std::pair*, unsigned> > + std::pair > MakeReportGraph(const ExplodedGraph* G, - const ExplodedNode** NStart, - const ExplodedNode** NEnd) { + const ExplodedNode** NStart, + const ExplodedNode** NEnd) { // Create the trimmed graph. It will contain the shortest paths from the // error nodes to the root. In the new graph we should only have one // error node unless there are two or more error nodes with the same minimum // path length. ExplodedGraph* GTrim; - InterExplodedGraphMap* NMap; + InterExplodedGraphMap* NMap; llvm::DenseMap InverseMap; llvm::tie(GTrim, NMap) = G->Trim(NStart, NEnd, &InverseMap); @@ -1351,18 +1351,18 @@ MakeReportGraph(const ExplodedGraph* G, // Create owning pointers for GTrim and NMap just to ensure that they are // released when this function exists. llvm::OwningPtr > AutoReleaseGTrim(GTrim); - llvm::OwningPtr > AutoReleaseNMap(NMap); + llvm::OwningPtr AutoReleaseNMap(NMap); // Find the (first) error node in the trimmed graph. We just need to consult // the node map (NMap) which maps from nodes in the original graph to nodes // in the new graph. - std::queue*> WS; - typedef llvm::DenseMap*,unsigned> IndexMapTy; + std::queue WS; + typedef llvm::DenseMap IndexMapTy; IndexMapTy IndexMap; - for (const ExplodedNode** I = NStart; I != NEnd; ++I) - if (const ExplodedNode *N = NMap->getMappedNode(*I)) { + for (const ExplodedNode** I = NStart; I != NEnd; ++I) + if (const ExplodedNode *N = NMap->getMappedNode(*I)) { unsigned NodeIndex = (I - NStart) / sizeof(*I); WS.push(N); IndexMap[*I] = NodeIndex; @@ -1382,10 +1382,10 @@ MakeReportGraph(const ExplodedGraph* G, llvm::DenseMap Visited; unsigned cnt = 0; - const ExplodedNode* Root = 0; + const ExplodedNode* Root = 0; while (!WS.empty()) { - const ExplodedNode* Node = WS.front(); + const ExplodedNode* Node = WS.front(); WS.pop(); if (Visited.find(Node) != Visited.end()) @@ -1398,7 +1398,7 @@ MakeReportGraph(const ExplodedGraph* G, break; } - for (ExplodedNode::const_pred_iterator I=Node->pred_begin(), + for (ExplodedNode::const_pred_iterator I=Node->pred_begin(), E=Node->pred_end(); I!=E; ++I) WS.push(*I); } @@ -1407,24 +1407,24 @@ MakeReportGraph(const ExplodedGraph* G, // Now walk from the root down the BFS path, always taking the successor // with the lowest number. - ExplodedNode *Last = 0, *First = 0; + ExplodedNode *Last = 0, *First = 0; NodeBackMap *BM = new NodeBackMap(); unsigned NodeIndex = 0; - for ( const ExplodedNode *N = Root ;;) { + for ( const ExplodedNode *N = Root ;;) { // Lookup the number associated with the current node. llvm::DenseMap::iterator I = Visited.find(N); assert(I != Visited.end()); // Create the equivalent node in the new graph with the same state // and location. - ExplodedNode* NewN = + ExplodedNode* NewN = GNew->getNode(N->getLocation(), N->getState()); // Store the mapping to the original node. llvm::DenseMap::iterator IMitr=InverseMap.find(N); assert(IMitr != InverseMap.end() && "No mapping to original node."); - (*BM)[NewN] = (const ExplodedNode*) IMitr->second; + (*BM)[NewN] = (const ExplodedNode*) IMitr->second; // Link up the new node with the previous node. if (Last) @@ -1434,7 +1434,7 @@ MakeReportGraph(const ExplodedGraph* G, // Are we at the final node? IndexMapTy::iterator IMI = - IndexMap.find((const ExplodedNode*)(IMitr->second)); + IndexMap.find((const ExplodedNode*)(IMitr->second)); if (IMI != IndexMap.end()) { First = NewN; NodeIndex = IMI->second; @@ -1443,8 +1443,8 @@ MakeReportGraph(const ExplodedGraph* G, // Find the next successor node. We choose the node that is marked // with the lowest DFS number. - ExplodedNode::const_succ_iterator SI = N->succ_begin(); - ExplodedNode::const_succ_iterator SE = N->succ_end(); + ExplodedNode::const_succ_iterator SI = N->succ_begin(); + ExplodedNode::const_succ_iterator SE = N->succ_end(); N = 0; for (unsigned MinVal = 0; SI != SE; ++SI) { @@ -1564,10 +1564,10 @@ static void CompactPathDiagnostic(PathDiagnostic &PD, const SourceManager& SM) { void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD, BugReportEquivClass& EQ) { - std::vector*> Nodes; + std::vector Nodes; for (BugReportEquivClass::iterator I=EQ.begin(), E=EQ.end(); I!=E; ++I) { - const ExplodedNode* N = I->getEndNode(); + const ExplodedNode* N = I->getEndNode(); if (N) Nodes.push_back(N); } @@ -1577,7 +1577,7 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD, // Construct a new graph that contains only a single path from the error // node to a root. const std::pair*, NodeBackMap*>, - std::pair*, unsigned> >& + std::pair >& GPair = MakeReportGraph(&getGraph(), &Nodes[0], &Nodes[0] + Nodes.size()); // Find the BugReport with the original location. @@ -1590,7 +1590,7 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD, llvm::OwningPtr > ReportGraph(GPair.first.first); llvm::OwningPtr BackMap(GPair.first.second); - const ExplodedNode *N = GPair.second.first; + const ExplodedNode *N = GPair.second.first; // Start building the path diagnostic... PathDiagnosticBuilder PDB(*this, R, BackMap.get(), getPathDiagnosticClient()); diff --git a/lib/Analysis/BugReporterVisitors.cpp b/lib/Analysis/BugReporterVisitors.cpp index 2efa4c6857..77501bbba2 100644 --- a/lib/Analysis/BugReporterVisitors.cpp +++ b/lib/Analysis/BugReporterVisitors.cpp @@ -24,7 +24,7 @@ using namespace clang; // Utility functions. //===----------------------------------------------------------------------===// -const Stmt *clang::bugreporter::GetDerefExpr(const ExplodedNode *N) { +const Stmt *clang::bugreporter::GetDerefExpr(const ExplodedNode *N) { // Pattern match for a few useful cases (do something smarter later): // a[0], p->f, *p const Stmt *S = N->getLocationAs()->getStmt(); @@ -46,7 +46,7 @@ const Stmt *clang::bugreporter::GetDerefExpr(const ExplodedNode *N) { } const Stmt* -clang::bugreporter::GetReceiverExpr(const ExplodedNode *N){ +clang::bugreporter::GetReceiverExpr(const ExplodedNode *N){ const Stmt *S = N->getLocationAs()->getStmt(); if (const ObjCMessageExpr *ME = dyn_cast(S)) return ME->getReceiver(); @@ -54,7 +54,7 @@ clang::bugreporter::GetReceiverExpr(const ExplodedNode *N){ } const Stmt* -clang::bugreporter::GetDenomExpr(const ExplodedNode *N) { +clang::bugreporter::GetDenomExpr(const ExplodedNode *N) { const Stmt *S = N->getLocationAs()->getStmt(); if (const BinaryOperator *BE = dyn_cast(S)) return BE->getRHS(); @@ -62,7 +62,7 @@ clang::bugreporter::GetDenomExpr(const ExplodedNode *N) { } const Stmt* -clang::bugreporter::GetCalleeExpr(const ExplodedNode *N) { +clang::bugreporter::GetCalleeExpr(const ExplodedNode *N) { const Stmt *S = N->getLocationAs()->getStmt(); if (const CallExpr *CE = dyn_cast(S)) return CE->getCallee(); @@ -70,7 +70,7 @@ clang::bugreporter::GetCalleeExpr(const ExplodedNode *N) { } const Stmt* -clang::bugreporter::GetRetValExpr(const ExplodedNode *N) { +clang::bugreporter::GetRetValExpr(const ExplodedNode *N) { const Stmt *S = N->getLocationAs()->getStmt(); if (const ReturnStmt *RS = dyn_cast(S)) return RS->getRetValue(); @@ -86,20 +86,20 @@ class VISIBILITY_HIDDEN FindLastStoreBRVisitor : public BugReporterVisitor { const MemRegion *R; SVal V; bool satisfied; - const ExplodedNode *StoreSite; + const ExplodedNode *StoreSite; public: FindLastStoreBRVisitor(SVal v, const MemRegion *r) : R(r), V(v), satisfied(false), StoreSite(0) {} - PathDiagnosticPiece* VisitNode(const ExplodedNode *N, - const ExplodedNode *PrevN, + PathDiagnosticPiece* VisitNode(const ExplodedNode *N, + const ExplodedNode *PrevN, BugReporterContext& BRC) { if (satisfied) return NULL; if (!StoreSite) { - const ExplodedNode *Node = N, *Last = NULL; + const ExplodedNode *Node = N, *Last = NULL; for ( ; Node ; Last = Node, Node = Node->getFirstPred()) { @@ -234,8 +234,8 @@ public: TrackConstraintBRVisitor(SVal constraint, bool assumption) : Constraint(constraint), Assumption(assumption), isSatisfied(false) {} - PathDiagnosticPiece* VisitNode(const ExplodedNode *N, - const ExplodedNode *PrevN, + PathDiagnosticPiece* VisitNode(const ExplodedNode *N, + const ExplodedNode *PrevN, BugReporterContext& BRC) { if (isSatisfied) return NULL; @@ -297,7 +297,7 @@ static void registerTrackConstraint(BugReporterContext& BRC, SVal Constraint, void clang::bugreporter::registerTrackNullOrUndefValue(BugReporterContext& BRC, const Stmt *S, - const ExplodedNode* N) { + const ExplodedNode* N) { if (!S) return; diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp index 23482ca4af..0b8b488bf0 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -178,8 +178,8 @@ public: GenericNodeBuilder(GREndPathNodeBuilder &enb) : SNB(0), S(0), tag(0), ENB(&enb) {} - ExplodedNode *MakeNode(const GRState *state, - ExplodedNode *Pred) { + ExplodedNode *MakeNode(const GRState *state, + ExplodedNode *Pred) { if (SNB) return SNB->generateNode(PostStmt(S, tag), state, Pred); @@ -1853,21 +1853,21 @@ private: const GRState * Update(const GRState * state, SymbolRef sym, RefVal V, ArgEffect E, RefVal::Kind& hasErr); - void ProcessNonLeakError(ExplodedNodeSet& Dst, + void ProcessNonLeakError(ExplodedNodeSet& Dst, GRStmtNodeBuilder& Builder, Expr* NodeExpr, Expr* ErrorExpr, - ExplodedNode* Pred, + ExplodedNode* Pred, const GRState* St, RefVal::Kind hasErr, SymbolRef Sym); const GRState * HandleSymbolDeath(const GRState * state, SymbolRef sid, RefVal V, llvm::SmallVectorImpl &Leaked); - ExplodedNode* ProcessLeaks(const GRState * state, + ExplodedNode* ProcessLeaks(const GRState * state, llvm::SmallVectorImpl &Leaked, GenericNodeBuilder &Builder, GRExprEngine &Eng, - ExplodedNode *Pred = 0); + ExplodedNode *Pred = 0); public: CFRefCount(ASTContext& Ctx, bool gcenabled, const LangOptions& lopts) @@ -1888,40 +1888,40 @@ public: bool isGCEnabled() const { return Summaries.isGCEnabled(); } const LangOptions& getLangOptions() const { return LOpts; } - const RetainSummary *getSummaryOfNode(const ExplodedNode *N) const { + const RetainSummary *getSummaryOfNode(const ExplodedNode *N) const { SummaryLogTy::const_iterator I = SummaryLog.find(N); return I == SummaryLog.end() ? 0 : I->second; } // Calls. - void EvalSummary(ExplodedNodeSet& Dst, + void EvalSummary(ExplodedNodeSet& Dst, GRExprEngine& Eng, GRStmtNodeBuilder& Builder, Expr* Ex, Expr* Receiver, const RetainSummary& Summ, ExprIterator arg_beg, ExprIterator arg_end, - ExplodedNode* Pred); + ExplodedNode* Pred); - virtual void EvalCall(ExplodedNodeSet& Dst, + virtual void EvalCall(ExplodedNodeSet& Dst, GRExprEngine& Eng, GRStmtNodeBuilder& Builder, CallExpr* CE, SVal L, - ExplodedNode* Pred); + ExplodedNode* Pred); - virtual void EvalObjCMessageExpr(ExplodedNodeSet& Dst, + virtual void EvalObjCMessageExpr(ExplodedNodeSet& Dst, GRExprEngine& Engine, GRStmtNodeBuilder& Builder, ObjCMessageExpr* ME, - ExplodedNode* Pred); + ExplodedNode* Pred); - bool EvalObjCMessageExprAux(ExplodedNodeSet& Dst, + bool EvalObjCMessageExprAux(ExplodedNodeSet& Dst, GRExprEngine& Engine, GRStmtNodeBuilder& Builder, ObjCMessageExpr* ME, - ExplodedNode* Pred); + ExplodedNode* Pred); // Stores. virtual void EvalBind(GRStmtNodeBuilderRef& B, SVal location, SVal val); @@ -1931,24 +1931,24 @@ public: virtual void EvalEndPath(GRExprEngine& Engine, GREndPathNodeBuilder& Builder); - virtual void EvalDeadSymbols(ExplodedNodeSet& Dst, + virtual void EvalDeadSymbols(ExplodedNodeSet& Dst, GRExprEngine& Engine, GRStmtNodeBuilder& Builder, - ExplodedNode* Pred, + ExplodedNode* Pred, Stmt* S, const GRState* state, SymbolReaper& SymReaper); - std::pair*, const GRState *> + std::pair HandleAutoreleaseCounts(const GRState * state, GenericNodeBuilder Bd, - ExplodedNode* Pred, GRExprEngine &Eng, + ExplodedNode* Pred, GRExprEngine &Eng, SymbolRef Sym, RefVal V, bool &stop); // Return statements. - virtual void EvalReturn(ExplodedNodeSet& Dst, + virtual void EvalReturn(ExplodedNodeSet& Dst, GRExprEngine& Engine, GRStmtNodeBuilder& Builder, ReturnStmt* S, - ExplodedNode* Pred); + ExplodedNode* Pred); // Assumptions. @@ -2123,11 +2123,11 @@ namespace { const CFRefCount &TF; public: CFRefReport(CFRefBug& D, const CFRefCount &tf, - ExplodedNode *n, SymbolRef sym) + ExplodedNode *n, SymbolRef sym) : RangedBugReport(D, D.getDescription(), n), Sym(sym), TF(tf) {} CFRefReport(CFRefBug& D, const CFRefCount &tf, - ExplodedNode *n, SymbolRef sym, const char* endText) + ExplodedNode *n, SymbolRef sym, const char* endText) : RangedBugReport(D, D.getDescription(), endText, n), Sym(sym), TF(tf) {} virtual ~CFRefReport() {} @@ -2151,12 +2151,12 @@ namespace { SymbolRef getSymbol() const { return Sym; } PathDiagnosticPiece* getEndPath(BugReporterContext& BRC, - const ExplodedNode* N); + const ExplodedNode* N); std::pair getExtraDescriptiveText(); - PathDiagnosticPiece* VisitNode(const ExplodedNode* N, - const ExplodedNode* PrevN, + PathDiagnosticPiece* VisitNode(const ExplodedNode* N, + const ExplodedNode* PrevN, BugReporterContext& BRC); }; @@ -2165,11 +2165,11 @@ namespace { const MemRegion* AllocBinding; public: CFRefLeakReport(CFRefBug& D, const CFRefCount &tf, - ExplodedNode *n, SymbolRef sym, + ExplodedNode *n, SymbolRef sym, GRExprEngine& Eng); PathDiagnosticPiece* getEndPath(BugReporterContext& BRC, - const ExplodedNode* N); + const ExplodedNode* N); SourceLocation getLocation() const { return AllocSite; } }; @@ -2273,8 +2273,8 @@ static inline bool contains(const llvm::SmallVectorImpl& V, return false; } -PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N, - const ExplodedNode* PrevN, +PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N, + const ExplodedNode* PrevN, BugReporterContext& BRC) { if (!isa(N->getLocation())) @@ -2548,13 +2548,13 @@ namespace { }; } -static std::pair*,const MemRegion*> -GetAllocationSite(GRStateManager& StateMgr, const ExplodedNode* N, +static std::pair +GetAllocationSite(GRStateManager& StateMgr, const ExplodedNode* N, SymbolRef Sym) { // Find both first node that referred to the tracked symbol and the // memory location that value was store to. - const ExplodedNode* Last = N; + const ExplodedNode* Last = N; const MemRegion* FirstBinding = 0; while (N) { @@ -2577,7 +2577,7 @@ GetAllocationSite(GRStateManager& StateMgr, const ExplodedNode* N, PathDiagnosticPiece* CFRefReport::getEndPath(BugReporterContext& BRC, - const ExplodedNode* EndN) { + const ExplodedNode* EndN) { // Tell the BugReporterContext to report cases when the tracked symbol is // assigned to different variables, etc. BRC.addNotableSymbol(Sym); @@ -2586,7 +2586,7 @@ CFRefReport::getEndPath(BugReporterContext& BRC, PathDiagnosticPiece* CFRefLeakReport::getEndPath(BugReporterContext& BRC, - const ExplodedNode* EndN){ + const ExplodedNode* EndN){ // Tell the BugReporterContext to report cases when the tracked symbol is // assigned to different variables, etc. @@ -2595,7 +2595,7 @@ CFRefLeakReport::getEndPath(BugReporterContext& BRC, // We are reporting a leak. Walk up the graph to get to the first node where // the symbol appeared, and also get the first VarDecl that tracked object // is stored to. - const ExplodedNode* AllocNode = 0; + const ExplodedNode* AllocNode = 0; const MemRegion* FirstBinding = 0; llvm::tie(AllocNode, FirstBinding) = @@ -2611,7 +2611,7 @@ CFRefLeakReport::getEndPath(BugReporterContext& BRC, // Compute an actual location for the leak. Sometimes a leak doesn't // occur at an actual statement (e.g., transition between blocks; end // of function) so we need to walk the graph and compute a real location. - const ExplodedNode* LeakN = EndN; + const ExplodedNode* LeakN = EndN; PathDiagnosticLocation L; while (LeakN) { @@ -2674,7 +2674,7 @@ CFRefLeakReport::getEndPath(BugReporterContext& BRC, } CFRefLeakReport::CFRefLeakReport(CFRefBug& D, const CFRefCount &tf, - ExplodedNode *n, + ExplodedNode *n, SymbolRef sym, GRExprEngine& Eng) : CFRefReport(D, tf, n, sym) { @@ -2687,7 +2687,7 @@ CFRefLeakReport::CFRefLeakReport(CFRefBug& D, const CFRefCount &tf, // Note that this is *not* the trimmed graph; we are guaranteed, however, // that all ancestor nodes that represent the allocation site have the // same SourceLocation. - const ExplodedNode* AllocNode = 0; + const ExplodedNode* AllocNode = 0; llvm::tie(AllocNode, AllocBinding) = // Set AllocBinding. GetAllocationSite(Eng.getStateManager(), getEndNode(), getSymbol()); @@ -2741,14 +2741,14 @@ static QualType GetReturnType(const Expr* RetE, ASTContext& Ctx) { return RetTy; } -void CFRefCount::EvalSummary(ExplodedNodeSet& Dst, +void CFRefCount::EvalSummary(ExplodedNodeSet& Dst, GRExprEngine& Eng, GRStmtNodeBuilder& Builder, Expr* Ex, Expr* Receiver, const RetainSummary& Summ, ExprIterator arg_beg, ExprIterator arg_end, - ExplodedNode* Pred) { + ExplodedNode* Pred) { // Get the state. const GRState *state = Builder.GetState(Pred); @@ -2962,11 +2962,11 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst, } -void CFRefCount::EvalCall(ExplodedNodeSet& Dst, +void CFRefCount::EvalCall(ExplodedNodeSet& Dst, GRExprEngine& Eng, GRStmtNodeBuilder& Builder, CallExpr* CE, SVal L, - ExplodedNode* Pred) { + ExplodedNode* Pred) { const FunctionDecl* FD = L.getAsFunctionDecl(); RetainSummary* Summ = !FD ? Summaries.getDefaultSummary() : Summaries.getSummary(const_cast(FD)); @@ -2976,11 +2976,11 @@ void CFRefCount::EvalCall(ExplodedNodeSet& Dst, CE->arg_begin(), CE->arg_end(), Pred); } -void CFRefCount::EvalObjCMessageExpr(ExplodedNodeSet& Dst, +void CFRefCount::EvalObjCMessageExpr(ExplodedNodeSet& Dst, GRExprEngine& Eng, GRStmtNodeBuilder& Builder, ObjCMessageExpr* ME, - ExplodedNode* Pred) { + ExplodedNode* Pred) { RetainSummary* Summ = 0; if (Expr* Receiver = ME->getReceiver()) { @@ -3096,11 +3096,11 @@ void CFRefCount::EvalBind(GRStmtNodeBuilderRef& B, SVal location, SVal val) { // Return statements. -void CFRefCount::EvalReturn(ExplodedNodeSet& Dst, +void CFRefCount::EvalReturn(ExplodedNodeSet& Dst, GRExprEngine& Eng, GRStmtNodeBuilder& Builder, ReturnStmt* S, - ExplodedNode* Pred) { + ExplodedNode* Pred) { Expr* RetE = S->getRetValue(); if (!RetE) @@ -3202,7 +3202,7 @@ void CFRefCount::EvalReturn(ExplodedNodeSet& Dst, // Generate an error node. static int ReturnOwnLeakTag = 0; state = state->set(Sym, X); - ExplodedNode *N = + ExplodedNode *N = Builder.generateNode(PostStmt(S, &ReturnOwnLeakTag), state, Pred); if (N) { CFRefReport *report = @@ -3223,7 +3223,7 @@ void CFRefCount::EvalReturn(ExplodedNodeSet& Dst, static int ReturnNotOwnedForOwnedTag = 0; state = state->set(Sym, X ^ RefVal::ErrorReturnedNotOwned); - if (ExplodedNode *N = + if (ExplodedNode *N = Builder.generateNode(PostStmt(S, &ReturnNotOwnedForOwnedTag), state, Pred)) { CFRefReport *report = @@ -3403,9 +3403,9 @@ const GRState * CFRefCount::Update(const GRState * state, SymbolRef sym, // Handle dead symbols and end-of-path. //===----------------------------------------------------------------------===// -std::pair*, const GRState *> +std::pair CFRefCount::HandleAutoreleaseCounts(const GRState * state, GenericNodeBuilder Bd, - ExplodedNode* Pred, + ExplodedNode* Pred, GRExprEngine &Eng, SymbolRef Sym, RefVal V, bool &stop) { @@ -3437,7 +3437,7 @@ CFRefCount::HandleAutoreleaseCounts(const GRState * state, GenericNodeBuilder Bd V.setAutoreleaseCount(0); } state = state->set(Sym, V); - ExplodedNode *N = Bd.MakeNode(state, Pred); + ExplodedNode *N = Bd.MakeNode(state, Pred); stop = (N == 0); return std::make_pair(N, state); } @@ -3448,7 +3448,7 @@ CFRefCount::HandleAutoreleaseCounts(const GRState * state, GenericNodeBuilder Bd V = V ^ RefVal::ErrorOverAutorelease; state = state->set(Sym, V); - if (ExplodedNode *N = Bd.MakeNode(state, Pred)) { + if (ExplodedNode *N = Bd.MakeNode(state, Pred)) { N->markAsSink(); std::string sbuf; @@ -3469,7 +3469,7 @@ CFRefCount::HandleAutoreleaseCounts(const GRState * state, GenericNodeBuilder Bd BR->EmitReport(report); } - return std::make_pair((ExplodedNode*)0, state); + return std::make_pair((ExplodedNode*)0, state); } const GRState * @@ -3486,18 +3486,18 @@ CFRefCount::HandleSymbolDeath(const GRState * state, SymbolRef sid, RefVal V, return state->set(sid, V ^ RefVal::ErrorLeak); } -ExplodedNode* +ExplodedNode* CFRefCount::ProcessLeaks(const GRState * state, llvm::SmallVectorImpl &Leaked, GenericNodeBuilder &Builder, GRExprEngine& Eng, - ExplodedNode *Pred) { + ExplodedNode *Pred) { if (Leaked.empty()) return Pred; // Generate an intermediate node representing the leak point. - ExplodedNode *N = Builder.MakeNode(state, Pred); + ExplodedNode *N = Builder.MakeNode(state, Pred); if (N) { for (llvm::SmallVectorImpl::iterator @@ -3520,7 +3520,7 @@ void CFRefCount::EvalEndPath(GRExprEngine& Eng, const GRState *state = Builder.getState(); GenericNodeBuilder Bd(Builder); RefBindings B = state->get(); - ExplodedNode *Pred = 0; + ExplodedNode *Pred = 0; for (RefBindings::iterator I = B.begin(), E = B.end(); I != E; ++I) { bool stop = false; @@ -3541,10 +3541,10 @@ void CFRefCount::EvalEndPath(GRExprEngine& Eng, ProcessLeaks(state, Leaked, Bd, Eng, Pred); } -void CFRefCount::EvalDeadSymbols(ExplodedNodeSet& Dst, +void CFRefCount::EvalDeadSymbols(ExplodedNodeSet& Dst, GRExprEngine& Eng, GRStmtNodeBuilder& Builder, - ExplodedNode* Pred, + ExplodedNode* Pred, Stmt* S, const GRState* state, SymbolReaper& SymReaper) { @@ -3596,10 +3596,10 @@ void CFRefCount::EvalDeadSymbols(ExplodedNodeSet& Dst, Builder.MakeNode(Dst, S, Pred, state); } -void CFRefCount::ProcessNonLeakError(ExplodedNodeSet& Dst, +void CFRefCount::ProcessNonLeakError(ExplodedNodeSet& Dst, GRStmtNodeBuilder& Builder, - Expr* NodeExpr, Expr* ErrorExpr, - ExplodedNode* Pred, + Expr* NodeExpr, Expr* ErrorExpr, + ExplodedNode* Pred, const GRState* St, RefVal::Kind hasErr, SymbolRef Sym) { Builder.BuildSinks = true; diff --git a/lib/Analysis/ExplodedGraph.cpp b/lib/Analysis/ExplodedGraph.cpp index 20de6c48c3..c0c0f0636b 100644 --- a/lib/Analysis/ExplodedGraph.cpp +++ b/lib/Analysis/ExplodedGraph.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "clang/Analysis/PathSensitive/ExplodedGraph.h" +#include "clang/Analysis/PathSensitive/GRState.h" #include "clang/AST/Stmt.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/DenseMap.h" @@ -26,27 +27,34 @@ using namespace clang; //===----------------------------------------------------------------------===// // An out of line virtual method to provide a home for the class vtable. -ExplodedNodeImpl::Auditor::~Auditor() {} +ExplodedNode::Auditor::~Auditor() {} #ifndef NDEBUG -static ExplodedNodeImpl::Auditor* NodeAuditor = 0; +static ExplodedNode::Auditor* NodeAuditor = 0; #endif -void ExplodedNodeImpl::SetAuditor(ExplodedNodeImpl::Auditor* A) { +void ExplodedNode::SetAuditor(ExplodedNode::Auditor* A) { #ifndef NDEBUG NodeAuditor = A; #endif } //===----------------------------------------------------------------------===// -// ExplodedNodeImpl. +// ExplodedNode. //===----------------------------------------------------------------------===// -static inline std::vector& getVector(void* P) { - return *reinterpret_cast*>(P); +static inline std::vector& getVector(void* P) { + return *reinterpret_cast*>(P); } -void ExplodedNodeImpl::addPredecessor(ExplodedNodeImpl* V) { +void ExplodedNode::Profile(llvm::FoldingSetNodeID& ID, + const ProgramPoint& Loc, + const GRState* state) { + ID.Add(Loc); + state->Profile(ID); +} + +void ExplodedNode::addPredecessor(ExplodedNode* V) { assert (!V->isSink()); Preds.addNode(V); V->Succs.addNode(this); @@ -55,14 +63,14 @@ void ExplodedNodeImpl::addPredecessor(ExplodedNodeImpl* V) { #endif } -void ExplodedNodeImpl::NodeGroup::addNode(ExplodedNodeImpl* N) { +void ExplodedNode::NodeGroup::addNode(ExplodedNode* N) { assert ((reinterpret_cast(N) & Mask) == 0x0); assert (!getFlag()); if (getKind() == Size1) { - if (ExplodedNodeImpl* NOld = getNode()) { - std::vector* V = new std::vector(); + if (ExplodedNode* NOld = getNode()) { + std::vector* V = new std::vector(); assert ((reinterpret_cast(V) & Mask) == 0x0); V->push_back(NOld); V->push_back(N); @@ -82,7 +90,7 @@ void ExplodedNodeImpl::NodeGroup::addNode(ExplodedNodeImpl* N) { } -unsigned ExplodedNodeImpl::NodeGroup::size() const { +unsigned ExplodedNode::NodeGroup::size() const { if (getFlag()) return 0; @@ -92,50 +100,50 @@ unsigned ExplodedNodeImpl::NodeGroup::size() const { return getVector(getPtr()).size(); } -ExplodedNodeImpl** ExplodedNodeImpl::NodeGroup::begin() const { +ExplodedNode** ExplodedNode::NodeGroup::begin() const { if (getFlag()) return NULL; if (getKind() == Size1) - return (ExplodedNodeImpl**) (getPtr() ? &P : NULL); + return (ExplodedNode**) (getPtr() ? &P : NULL); else - return const_cast(&*(getVector(getPtr()).begin())); + return const_cast(&*(getVector(getPtr()).begin())); } -ExplodedNodeImpl** ExplodedNodeImpl::NodeGroup::end() const { +ExplodedNode** ExplodedNode::NodeGroup::end() const { if (getFlag()) return NULL; if (getKind() == Size1) - return (ExplodedNodeImpl**) (getPtr() ? &P+1 : NULL); + return (ExplodedNode**) (getPtr() ? &P+1 : NULL); else { // Dereferencing end() is undefined behaviour. The vector is not empty, so // we can dereference the last elem and then add 1 to the result. - return const_cast(&getVector(getPtr()).back()) + 1; + return const_cast(&getVector(getPtr()).back()) + 1; } } -ExplodedNodeImpl::NodeGroup::~NodeGroup() { +ExplodedNode::NodeGroup::~NodeGroup() { if (getKind() == SizeOther) delete &getVector(getPtr()); } ExplodedGraphImpl* -ExplodedGraphImpl::Trim(const ExplodedNodeImpl* const* BeginSources, - const ExplodedNodeImpl* const* EndSources, +ExplodedGraphImpl::Trim(const ExplodedNode* const* BeginSources, + const ExplodedNode* const* EndSources, InterExplodedGraphMapImpl* M, llvm::DenseMap *InverseMap) const { - typedef llvm::DenseSet Pass1Ty; + typedef llvm::DenseSet Pass1Ty; Pass1Ty Pass1; - typedef llvm::DenseMap Pass2Ty; + typedef llvm::DenseMap Pass2Ty; Pass2Ty& Pass2 = M->M; - llvm::SmallVector WL1, WL2; + llvm::SmallVector WL1, WL2; // ===- Pass 1 (reverse DFS) -=== - for (const ExplodedNodeImpl* const* I = BeginSources; I != EndSources; ++I) { + for (const ExplodedNode* const* I = BeginSources; I != EndSources; ++I) { assert(*I); WL1.push_back(*I); } @@ -143,7 +151,7 @@ const { // Process the first worklist until it is empty. Because it is a std::list // it acts like a FIFO queue. while (!WL1.empty()) { - const ExplodedNodeImpl *N = WL1.back(); + const ExplodedNode *N = WL1.back(); WL1.pop_back(); // Have we already visited this node? If so, continue to the next one. @@ -160,7 +168,7 @@ const { } // Visit our predecessors and enqueue them. - for (ExplodedNodeImpl** I=N->Preds.begin(), **E=N->Preds.end(); I!=E; ++I) + for (ExplodedNode** I=N->Preds.begin(), **E=N->Preds.end(); I!=E; ++I) WL1.push_back(*I); } @@ -173,7 +181,7 @@ const { // ===- Pass 2 (forward DFS to construct the new graph) -=== while (!WL2.empty()) { - const ExplodedNodeImpl* N = WL2.back(); + const ExplodedNode* N = WL2.back(); WL2.pop_back(); // Skip this node if we have already processed it. @@ -182,7 +190,7 @@ const { // Create the corresponding node in the new graph and record the mapping // from the old node to the new node. - ExplodedNodeImpl* NewN = G->getNodeImpl(N->getLocation(), N->State, NULL); + ExplodedNode* NewN = G->getNodeImpl(N->getLocation(), N->State, NULL); Pass2[N] = NewN; // Also record the reverse mapping from the new node to the old node. @@ -197,7 +205,7 @@ const { // Walk through the predecessors of 'N' and hook up their corresponding // nodes in the new graph (if any) to the freshly created node. - for (ExplodedNodeImpl **I=N->Preds.begin(), **E=N->Preds.end(); I!=E; ++I) { + for (ExplodedNode **I=N->Preds.begin(), **E=N->Preds.end(); I!=E; ++I) { Pass2Ty::iterator PI = Pass2.find(*I); if (PI == Pass2.end()) continue; @@ -209,7 +217,7 @@ const { // been created, we should hook them up as successors. Otherwise, enqueue // the new nodes from the original graph that should have nodes created // in the new graph. - for (ExplodedNodeImpl **I=N->Succs.begin(), **E=N->Succs.end(); I!=E; ++I) { + for (ExplodedNode **I=N->Succs.begin(), **E=N->Succs.end(); I!=E; ++I) { Pass2Ty::iterator PI = Pass2.find(*I); if (PI != Pass2.end()) { PI->second->addPredecessor(NewN); @@ -229,9 +237,9 @@ const { return G; } -ExplodedNodeImpl* -InterExplodedGraphMapImpl::getMappedImplNode(const ExplodedNodeImpl* N) const { - llvm::DenseMap::iterator I = +ExplodedNode* +InterExplodedGraphMapImpl::getMappedImplNode(const ExplodedNode* N) const { + llvm::DenseMap::iterator I = M.find(N); return I == M.end() ? 0 : I->second; diff --git a/lib/Analysis/GRCoreEngine.cpp b/lib/Analysis/GRCoreEngine.cpp index 5a92143e18..e0b53a8a7f 100644 --- a/lib/Analysis/GRCoreEngine.cpp +++ b/lib/Analysis/GRCoreEngine.cpp @@ -155,7 +155,7 @@ bool GRCoreEngineImpl::ExecuteWorkList(unsigned Steps) { WList->setBlockCounter(WU.getBlockCounter()); // Retrieve the node. - ExplodedNodeImpl* Node = WU.getNode(); + ExplodedNode* Node = WU.getNode(); // Dispatch on the location type. switch (Node->getLocation().getKind()) { @@ -183,7 +183,7 @@ bool GRCoreEngineImpl::ExecuteWorkList(unsigned Steps) { } void GRCoreEngineImpl::HandleBlockEdge(const BlockEdge& L, - ExplodedNodeImpl* Pred) { + ExplodedNode* Pred) { CFGBlock* Blk = L.getDst(); @@ -208,7 +208,7 @@ void GRCoreEngineImpl::HandleBlockEdge(const BlockEdge& L, } void GRCoreEngineImpl::HandleBlockEntrance(const BlockEntrance& L, - ExplodedNodeImpl* Pred) { + ExplodedNode* Pred) { // Increment the block counter. GRBlockCounter Counter = WList->getBlockCounter(); @@ -228,7 +228,7 @@ GRCoreEngineImpl::~GRCoreEngineImpl() { delete WList; } -void GRCoreEngineImpl::HandleBlockExit(CFGBlock * B, ExplodedNodeImpl* Pred) { +void GRCoreEngineImpl::HandleBlockExit(CFGBlock * B, ExplodedNode* Pred) { if (Stmt* Term = B->getTerminator()) { switch (Term->getStmtClass()) { @@ -317,7 +317,7 @@ void GRCoreEngineImpl::HandleBlockExit(CFGBlock * B, ExplodedNodeImpl* Pred) { } void GRCoreEngineImpl::HandleBranch(Stmt* Cond, Stmt* Term, CFGBlock * B, - ExplodedNodeImpl* Pred) { + ExplodedNode* Pred) { assert (B->succ_size() == 2); GRBranchNodeBuilderImpl Builder(B, *(B->succ_begin()), *(B->succ_begin()+1), @@ -327,7 +327,7 @@ void GRCoreEngineImpl::HandleBranch(Stmt* Cond, Stmt* Term, CFGBlock * B, } void GRCoreEngineImpl::HandlePostStmt(const PostStmt& L, CFGBlock* B, - unsigned StmtIdx, ExplodedNodeImpl* Pred) { + unsigned StmtIdx, ExplodedNode* Pred) { assert (!B->empty()); @@ -342,10 +342,10 @@ void GRCoreEngineImpl::HandlePostStmt(const PostStmt& L, CFGBlock* B, /// GenerateNode - Utility method to generate nodes, hook up successors, /// and add nodes to the worklist. void GRCoreEngineImpl::GenerateNode(const ProgramPoint& Loc, const void* State, - ExplodedNodeImpl* Pred) { + ExplodedNode* Pred) { bool IsNew; - ExplodedNodeImpl* Node = G->getNodeImpl(Loc, State, &IsNew); + ExplodedNode* Node = G->getNodeImpl(Loc, State, &IsNew); if (Pred) Node->addPredecessor(Pred); // Link 'Node' with its predecessor. @@ -359,7 +359,7 @@ void GRCoreEngineImpl::GenerateNode(const ProgramPoint& Loc, const void* State, } GRStmtNodeBuilderImpl::GRStmtNodeBuilderImpl(CFGBlock* b, unsigned idx, - ExplodedNodeImpl* N, GRCoreEngineImpl* e) + ExplodedNode* N, GRCoreEngineImpl* e) : Eng(*e), B(*b), Idx(idx), Pred(N), LastNode(N) { Deferred.insert(N); } @@ -370,7 +370,7 @@ GRStmtNodeBuilderImpl::~GRStmtNodeBuilderImpl() { GenerateAutoTransition(*I); } -void GRStmtNodeBuilderImpl::GenerateAutoTransition(ExplodedNodeImpl* N) { +void GRStmtNodeBuilderImpl::GenerateAutoTransition(ExplodedNode* N) { assert (!N->isSink()); PostStmt Loc(getStmt()); @@ -383,7 +383,7 @@ void GRStmtNodeBuilderImpl::GenerateAutoTransition(ExplodedNodeImpl* N) { } bool IsNew; - ExplodedNodeImpl* Succ = Eng.G->getNodeImpl(Loc, N->State, &IsNew); + ExplodedNode* Succ = Eng.G->getNodeImpl(Loc, N->State, &IsNew); Succ->addPredecessor(N); if (IsNew) @@ -425,9 +425,9 @@ static inline PostStmt GetPostLoc(const Stmt* S, ProgramPoint::Kind K, } } -ExplodedNodeImpl* +ExplodedNode* GRStmtNodeBuilderImpl::generateNodeImpl(const Stmt* S, const void* State, - ExplodedNodeImpl* Pred, + ExplodedNode* Pred, ProgramPoint::Kind K, const void *tag) { return K == ProgramPoint::PreStmtKind @@ -435,12 +435,12 @@ GRStmtNodeBuilderImpl::generateNodeImpl(const Stmt* S, const void* State, : generateNodeImpl(GetPostLoc(S, K, tag), State, Pred); } -ExplodedNodeImpl* +ExplodedNode* GRStmtNodeBuilderImpl::generateNodeImpl(const ProgramPoint &Loc, const void* State, - ExplodedNodeImpl* Pred) { + ExplodedNode* Pred) { bool IsNew; - ExplodedNodeImpl* N = Eng.G->getNodeImpl(Loc, State, &IsNew); + ExplodedNode* N = Eng.G->getNodeImpl(Loc, State, &IsNew); N->addPredecessor(Pred); Deferred.erase(Pred); @@ -454,7 +454,7 @@ GRStmtNodeBuilderImpl::generateNodeImpl(const ProgramPoint &Loc, return NULL; } -ExplodedNodeImpl* GRBranchNodeBuilderImpl::generateNodeImpl(const void* State, +ExplodedNode* GRBranchNodeBuilderImpl::generateNodeImpl(const void* State, bool branch) { // If the branch has been marked infeasible we should not generate a node. @@ -463,7 +463,7 @@ ExplodedNodeImpl* GRBranchNodeBuilderImpl::generateNodeImpl(const void* State, bool IsNew; - ExplodedNodeImpl* Succ = + ExplodedNode* Succ = Eng.G->getNodeImpl(BlockEdge(Src, branch ? DstT : DstF), State, &IsNew); Succ->addPredecessor(Pred); @@ -490,13 +490,13 @@ GRBranchNodeBuilderImpl::~GRBranchNodeBuilderImpl() { } -ExplodedNodeImpl* +ExplodedNode* GRIndirectGotoNodeBuilderImpl::generateNodeImpl(const Iterator& I, const void* St, bool isSink) { bool IsNew; - ExplodedNodeImpl* Succ = + ExplodedNode* Succ = Eng.G->getNodeImpl(BlockEdge(Src, I.getBlock()), St, &IsNew); Succ->addPredecessor(Pred); @@ -515,13 +515,13 @@ GRIndirectGotoNodeBuilderImpl::generateNodeImpl(const Iterator& I, } -ExplodedNodeImpl* +ExplodedNode* GRSwitchNodeBuilderImpl::generateCaseStmtNodeImpl(const Iterator& I, const void* St) { bool IsNew; - ExplodedNodeImpl* Succ = Eng.G->getNodeImpl(BlockEdge(Src, I.getBlock()), + ExplodedNode* Succ = Eng.G->getNodeImpl(BlockEdge(Src, I.getBlock()), St, &IsNew); Succ->addPredecessor(Pred); @@ -534,7 +534,7 @@ GRSwitchNodeBuilderImpl::generateCaseStmtNodeImpl(const Iterator& I, } -ExplodedNodeImpl* +ExplodedNode* GRSwitchNodeBuilderImpl::generateDefaultCaseNodeImpl(const void* St, bool isSink) { @@ -544,7 +544,7 @@ GRSwitchNodeBuilderImpl::generateDefaultCaseNodeImpl(const void* St, bool IsNew; - ExplodedNodeImpl* Succ = Eng.G->getNodeImpl(BlockEdge(Src, DefaultBlock), + ExplodedNode* Succ = Eng.G->getNodeImpl(BlockEdge(Src, DefaultBlock), St, &IsNew); Succ->addPredecessor(Pred); @@ -565,14 +565,14 @@ GREndPathNodeBuilderImpl::~GREndPathNodeBuilderImpl() { if (!HasGeneratedNode) generateNodeImpl(Pred->State); } -ExplodedNodeImpl* +ExplodedNode* GREndPathNodeBuilderImpl::generateNodeImpl(const void* State, const void *tag, - ExplodedNodeImpl* P) { + ExplodedNode* P) { HasGeneratedNode = true; bool IsNew; - ExplodedNodeImpl* Node = + ExplodedNode* Node = Eng.G->getNodeImpl(BlockEntrance(&B, tag), State, &IsNew); Node->addPredecessor(P ? P : Pred); diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index 2f51170895..bf24248251 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -1298,11 +1298,11 @@ GRExprEngine::NodeTy* GRExprEngine::EvalLocation(Stmt* Ex, NodeTy* Pred, // http://developer.apple.com/documentation/Darwin/Reference/Manpages/man3 // atomic.3.html // -static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet& Dst, +static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet& Dst, GRExprEngine& Engine, GRStmtNodeBuilder& Builder, CallExpr* CE, SVal L, - ExplodedNode* Pred) { + ExplodedNode* Pred) { // Not enough arguments to match OSAtomicCompareAndSwap? if (CE->getNumArgs() != 3) @@ -1342,14 +1342,14 @@ static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet& Dst, // Load 'theValue'. const GRState *state = Pred->getState(); - ExplodedNodeSet Tmp; + ExplodedNodeSet Tmp; SVal location = state->getSVal(theValueExpr); Engine.EvalLoad(Tmp, theValueExpr, Pred, state, location, OSAtomicLoadTag); - for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); + for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I != E; ++I) { - ExplodedNode *N = *I; + ExplodedNode *N = *I; const GRState *stateLoad = N->getState(); SVal theValueVal = stateLoad->getSVal(theValueExpr); SVal oldValueVal = stateLoad->getSVal(oldValueExpr); @@ -1368,7 +1368,7 @@ static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet& Dst, // Were they equal? if (stateEqual) { // Perform the store. - ExplodedNodeSet TmpStore; + ExplodedNodeSet TmpStore; SVal val = stateEqual->getSVal(newValueExpr); // Handle implicit value casts. @@ -1383,9 +1383,9 @@ static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet& Dst, val, OSAtomicStoreTag); // Now bind the result of the comparison. - for (ExplodedNodeSet::iterator I2 = TmpStore.begin(), + for (ExplodedNodeSet::iterator I2 = TmpStore.begin(), E2 = TmpStore.end(); I2 != E2; ++I2) { - ExplodedNode *predNew = *I2; + ExplodedNode *predNew = *I2; const GRState *stateNew = predNew->getState(); SVal Res = Engine.getValueManager().makeTruthVal(true, CE->getType()); Engine.MakeNode(Dst, CE, predNew, stateNew->bindExpr(CE, Res)); @@ -1402,11 +1402,11 @@ static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet& Dst, return true; } -static bool EvalOSAtomic(ExplodedNodeSet& Dst, +static bool EvalOSAtomic(ExplodedNodeSet& Dst, GRExprEngine& Engine, GRStmtNodeBuilder& Builder, CallExpr* CE, SVal L, - ExplodedNode* Pred) { + ExplodedNode* Pred) { const FunctionDecl* FD = L.getAsFunctionDecl(); if (!FD) return false; diff --git a/lib/Analysis/GRExprEngineInternalChecks.cpp b/lib/Analysis/GRExprEngineInternalChecks.cpp index f3ee5b6418..f07a385330 100644 --- a/lib/Analysis/GRExprEngineInternalChecks.cpp +++ b/lib/Analysis/GRExprEngineInternalChecks.cpp @@ -28,12 +28,12 @@ using namespace clang::bugreporter; //===----------------------------------------------------------------------===// template inline -ExplodedNode* GetNode(ITERATOR I) { +ExplodedNode* GetNode(ITERATOR I) { return *I; } template <> inline -ExplodedNode* GetNode(GRExprEngine::undef_arg_iterator I) { +ExplodedNode* GetNode(GRExprEngine::undef_arg_iterator I) { return I->first; } @@ -46,15 +46,15 @@ namespace { class VISIBILITY_HIDDEN BuiltinBugReport : public RangedBugReport { public: BuiltinBugReport(BugType& bt, const char* desc, - ExplodedNode *n) + ExplodedNode *n) : RangedBugReport(bt, desc, n) {} BuiltinBugReport(BugType& bt, const char *shortDesc, const char *desc, - ExplodedNode *n) + ExplodedNode *n) : RangedBugReport(bt, shortDesc, desc, n) {} void registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode* N); + const ExplodedNode* N); }; class VISIBILITY_HIDDEN BuiltinBug : public BugType { @@ -73,7 +73,7 @@ public: void FlushReports(BugReporter& BR) { FlushReportsImpl(BR, Eng); } virtual void registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode* N, + const ExplodedNode* N, BuiltinBugReport *R) {} template void Emit(BugReporter& BR, ITER I, ITER E); @@ -87,7 +87,7 @@ void BuiltinBug::Emit(BugReporter& BR, ITER I, ITER E) { } void BuiltinBugReport::registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode* N) { + const ExplodedNode* N) { static_cast(getBugType()).registerInitialVisitors(BRC, N, this); } @@ -101,7 +101,7 @@ public: } void registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode* N, + const ExplodedNode* N, BuiltinBugReport *R) { registerTrackNullOrUndefValue(BRC, GetDerefExpr(N), N); } @@ -133,7 +133,7 @@ public: } void registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode* N, + const ExplodedNode* N, BuiltinBugReport *R) { registerTrackNullOrUndefValue(BRC, GetReceiverExpr(N), N); } @@ -167,7 +167,7 @@ public: } } void registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode* N, + const ExplodedNode* N, BuiltinBugReport *R) { registerTrackNullOrUndefValue(BRC, GetReceiverExpr(N), N); } @@ -183,7 +183,7 @@ public: } void registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode* N, + const ExplodedNode* N, BuiltinBugReport *R) { registerTrackNullOrUndefValue(BRC, GetDerefExpr(N), N); } @@ -200,7 +200,7 @@ public: } void registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode* N, + const ExplodedNode* N, BuiltinBugReport *R) { registerTrackNullOrUndefValue(BRC, GetDenomExpr(N), N); } @@ -227,7 +227,7 @@ public: } void registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode* N, + const ExplodedNode* N, BuiltinBugReport *R) { registerTrackNullOrUndefValue(BRC, GetCalleeExpr(N), N); } @@ -237,12 +237,12 @@ public: class VISIBILITY_HIDDEN ArgReport : public BuiltinBugReport { const Stmt *Arg; public: - ArgReport(BugType& bt, const char* desc, ExplodedNode *n, + ArgReport(BugType& bt, const char* desc, ExplodedNode *n, const Stmt *arg) : BuiltinBugReport(bt, desc, n), Arg(arg) {} ArgReport(BugType& bt, const char *shortDesc, const char *desc, - ExplodedNode *n, const Stmt *arg) + ExplodedNode *n, const Stmt *arg) : BuiltinBugReport(bt, shortDesc, desc, n), Arg(arg) {} const Stmt *getArg() const { return Arg; } @@ -268,7 +268,7 @@ public: } void registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode* N, + const ExplodedNode* N, BuiltinBugReport *R) { registerTrackNullOrUndefValue(BRC, static_cast(R)->getArg(), N); @@ -304,7 +304,7 @@ public: // Generate a report for this bug. BuiltinBugReport *report = new BuiltinBugReport(*this, desc.c_str(), *I); - ExplodedNode* N = *I; + ExplodedNode* N = *I; const Stmt *S = cast(N->getLocation()).getStmt(); const Expr* E = cast(S)->getReceiver(); assert (E && "Receiver cannot be NULL"); @@ -314,7 +314,7 @@ public: } void registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode* N, + const ExplodedNode* N, BuiltinBugReport *R) { registerTrackNullOrUndefValue(BRC, GetReceiverExpr(N), N); } @@ -329,7 +329,7 @@ public: for (GRExprEngine::ret_stackaddr_iterator I=Eng.ret_stackaddr_begin(), End = Eng.ret_stackaddr_end(); I!=End; ++I) { - ExplodedNode* N = *I; + ExplodedNode* N = *I; const Stmt *S = cast(N->getLocation()).getStmt(); const Expr* E = cast(S)->getRetValue(); assert(E && "Return expression cannot be NULL"); @@ -387,7 +387,7 @@ public: } void registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode* N, + const ExplodedNode* N, BuiltinBugReport *R) { registerTrackNullOrUndefValue(BRC, GetRetValExpr(N), N); } @@ -443,7 +443,7 @@ public: // Note: any predecessor will do. They should have identical state, // since all the BlockEdge did was act as an error sink since the value // had to already be undefined. - ExplodedNode *N = *(*I)->pred_begin(); + ExplodedNode *N = *(*I)->pred_begin(); ProgramPoint P = N->getLocation(); const GRState* St = (*I)->getState(); @@ -461,7 +461,7 @@ public: } void registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode* N, + const ExplodedNode* N, BuiltinBugReport *R) { registerTrackNullOrUndefValue(BRC, static_cast(R)->getArg(), N); @@ -527,7 +527,7 @@ public: } void registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode* N, + const ExplodedNode* N, BuiltinBugReport *R) { registerTrackNullOrUndefValue(BRC, static_cast(R)->getArg(), N); @@ -583,7 +583,7 @@ public: if (stateNull && !stateNotNull) { // Generate an error node. Check for a null node in case // we cache out. - if (ExplodedNode *errorNode = C.generateNode(CE, stateNull)) { + if (ExplodedNode *errorNode = C.generateNode(CE, stateNull)) { // Lazily allocate the BugType object if it hasn't already been // created. Ownership is transferred to the BugReporter object once diff --git a/lib/Frontend/AnalysisConsumer.cpp b/lib/Frontend/AnalysisConsumer.cpp index 1ab3690745..11ffdebb2b 100644 --- a/lib/Frontend/AnalysisConsumer.cpp +++ b/lib/Frontend/AnalysisConsumer.cpp @@ -39,7 +39,7 @@ using namespace clang; -static ExplodedNodeImpl::Auditor* CreateUbiViz(); +static ExplodedNode::Auditor* CreateUbiViz(); //===----------------------------------------------------------------------===// // Basic type definitions. @@ -308,10 +308,10 @@ static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf, } // Set the graph auditor. - llvm::OwningPtr Auditor; + llvm::OwningPtr Auditor; if (mgr.shouldVisualizeUbigraph()) { Auditor.reset(CreateUbiViz()); - ExplodedNodeImpl::SetAuditor(Auditor.get()); + ExplodedNode::SetAuditor(Auditor.get()); } // Execute the worklist algorithm. @@ -319,7 +319,7 @@ static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf, // Release the auditor (if any) so that it doesn't monitor the graph // created BugReporter. - ExplodedNodeImpl::SetAuditor(0); + ExplodedNode::SetAuditor(0); // Visualize the exploded graph. if (mgr.shouldVisualizeGraphviz()) @@ -443,7 +443,7 @@ ASTConsumer* clang::CreateAnalysisConsumer(Diagnostic &diags, Preprocessor* pp, namespace { -class UbigraphViz : public ExplodedNodeImpl::Auditor { +class UbigraphViz : public ExplodedNode::Auditor { llvm::OwningPtr Out; llvm::sys::Path Dir, Filename; unsigned Cntr; @@ -457,12 +457,12 @@ public: ~UbigraphViz(); - virtual void AddEdge(ExplodedNodeImpl* Src, ExplodedNodeImpl* Dst); + virtual void AddEdge(ExplodedNode* Src, ExplodedNode* Dst); }; } // end anonymous namespace -static ExplodedNodeImpl::Auditor* CreateUbiViz() { +static ExplodedNode::Auditor* CreateUbiViz() { std::string ErrMsg; llvm::sys::Path Dir = llvm::sys::Path::GetTemporaryDirectory(&ErrMsg); @@ -489,7 +489,7 @@ static ExplodedNodeImpl::Auditor* CreateUbiViz() { return new UbigraphViz(Stream.take(), Dir, Filename); } -void UbigraphViz::AddEdge(ExplodedNodeImpl* Src, ExplodedNodeImpl* Dst) { +void UbigraphViz::AddEdge(ExplodedNode* Src, ExplodedNode* Dst) { assert (Src != Dst && "Self-edges are not allowed.");