Index: include/clang/Analysis/Analyses/Dominators.h =================================================================== --- include/clang/Analysis/Analyses/Dominators.h +++ include/clang/Analysis/Analyses/Dominators.h @@ -181,14 +181,15 @@ return N->end(); } - typedef df_iterator< ::clang::DomTreeNode* > nodes_iterator; + typedef llvm::pointer_iterator> + nodes_iterator; static nodes_iterator nodes_begin(::clang::DomTreeNode *N) { - return df_begin(getEntryNode(N)); + return nodes_iterator(df_begin(getEntryNode(N))); } static nodes_iterator nodes_end(::clang::DomTreeNode *N) { - return df_end(getEntryNode(N)); + return nodes_iterator(df_end(getEntryNode(N))); } }; @@ -199,11 +200,11 @@ } static nodes_iterator nodes_begin(::clang::DominatorTree *N) { - return df_begin(getEntryNode(N)); + return nodes_iterator(df_begin(getEntryNode(N))); } static nodes_iterator nodes_end(::clang::DominatorTree *N) { - return df_end(getEntryNode(N)); + return nodes_iterator(df_end(getEntryNode(N))); } }; } // end namespace llvm Index: include/clang/Analysis/CFG.h =================================================================== --- include/clang/Analysis/CFG.h +++ include/clang/Analysis/CFG.h @@ -761,55 +761,6 @@ AddCXXNewAllocator(false), AddCXXDefaultInitExprInCtors(false) {} }; - /// \brief Provides a custom implementation of the iterator class to have the - /// same interface as Function::iterator - iterator returns CFGBlock - /// (not a pointer to CFGBlock). - class graph_iterator { - public: - typedef CFGBlock value_type; - typedef value_type& reference; - typedef value_type* pointer; - typedef BumpVector::iterator ImplTy; - - graph_iterator(const ImplTy &i) : I(i) {} - - bool operator==(const graph_iterator &X) const { return I == X.I; } - bool operator!=(const graph_iterator &X) const { return I != X.I; } - - reference operator*() const { return **I; } - pointer operator->() const { return *I; } - operator CFGBlock* () { return *I; } - - graph_iterator &operator++() { ++I; return *this; } - graph_iterator &operator--() { --I; return *this; } - - private: - ImplTy I; - }; - - class const_graph_iterator { - public: - typedef const CFGBlock value_type; - typedef value_type& reference; - typedef value_type* pointer; - typedef BumpVector::const_iterator ImplTy; - - const_graph_iterator(const ImplTy &i) : I(i) {} - - bool operator==(const const_graph_iterator &X) const { return I == X.I; } - bool operator!=(const const_graph_iterator &X) const { return I != X.I; } - - reference operator*() const { return **I; } - pointer operator->() const { return *I; } - operator CFGBlock* () const { return *I; } - - const_graph_iterator &operator++() { ++I; return *this; } - const_graph_iterator &operator--() { --I; return *this; } - - private: - ImplTy I; - }; - /// buildCFG - Builds a CFG from an AST. static std::unique_ptr buildCFG(const Decl *D, Stmt *AST, ASTContext *C, const BuildOptions &BO); @@ -845,14 +796,10 @@ const_iterator begin() const { return Blocks.begin(); } const_iterator end() const { return Blocks.end(); } - graph_iterator nodes_begin() { return graph_iterator(Blocks.begin()); } - graph_iterator nodes_end() { return graph_iterator(Blocks.end()); } - const_graph_iterator nodes_begin() const { - return const_graph_iterator(Blocks.begin()); - } - const_graph_iterator nodes_end() const { - return const_graph_iterator(Blocks.end()); - } + iterator nodes_begin() { return iterator(Blocks.begin()); } + iterator nodes_end() { return iterator(Blocks.end()); } + const_iterator nodes_begin() const { return const_iterator(Blocks.begin()); } + const_iterator nodes_end() const { return const_iterator(Blocks.end()); } reverse_iterator rbegin() { return Blocks.rbegin(); } reverse_iterator rend() { return Blocks.rend(); } @@ -1062,7 +1009,7 @@ template <> struct GraphTraits< ::clang::CFG* > : public GraphTraits< ::clang::CFGBlock *> { - typedef ::clang::CFG::graph_iterator nodes_iterator; + typedef ::clang::CFG::iterator nodes_iterator; static NodeType *getEntryNode(::clang::CFG* F) { return &F->getEntry(); } static nodes_iterator nodes_begin(::clang::CFG* F) { return F->nodes_begin();} @@ -1073,7 +1020,7 @@ template <> struct GraphTraits : public GraphTraits { - typedef ::clang::CFG::const_graph_iterator nodes_iterator; + typedef ::clang::CFG::const_iterator nodes_iterator; static NodeType *getEntryNode( const ::clang::CFG* F) { return &F->getEntry(); @@ -1092,7 +1039,7 @@ template <> struct GraphTraits > : public GraphTraits > { - typedef ::clang::CFG::graph_iterator nodes_iterator; + typedef ::clang::CFG::iterator nodes_iterator; static NodeType *getEntryNode( ::clang::CFG* F) { return &F->getExit(); } static nodes_iterator nodes_begin( ::clang::CFG* F) {return F->nodes_begin();} @@ -1102,7 +1049,7 @@ template <> struct GraphTraits > : public GraphTraits > { - typedef ::clang::CFG::const_graph_iterator nodes_iterator; + typedef ::clang::CFG::const_iterator nodes_iterator; static NodeType *getEntryNode(const ::clang::CFG* F) { return &F->getExit(); } static nodes_iterator nodes_begin(const ::clang::CFG* F) { Index: include/clang/Analysis/CallGraph.h =================================================================== --- include/clang/Analysis/CallGraph.h +++ include/clang/Analysis/CallGraph.h @@ -205,7 +205,8 @@ return CGN->getRoot(); // Start at the external node! } typedef std::pair PairTy; - typedef std::pointer_to_unary_function DerefFun; + typedef std::pointer_to_unary_function + DerefFun; // nodes_iterator/begin/end - Allow iteration over all nodes in the graph typedef mapped_iterator nodes_iterator; @@ -215,9 +216,7 @@ static nodes_iterator nodes_end (clang::CallGraph *CG) { return map_iterator(CG->end(), DerefFun(CGdereference)); } - static clang::CallGraphNode &CGdereference(PairTy P) { - return *(P.second); - } + static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; } static unsigned size(clang::CallGraph *CG) { return CG->size(); @@ -230,7 +229,8 @@ return CGN->getRoot(); } typedef std::pair PairTy; - typedef std::pointer_to_unary_function DerefFun; + typedef std::pointer_to_unary_function + DerefFun; // nodes_iterator/begin/end - Allow iteration over all nodes in the graph typedef mapped_iterator nodes_iterator; @@ -241,9 +241,7 @@ static nodes_iterator nodes_end(const clang::CallGraph *CG) { return map_iterator(CG->end(), DerefFun(CGdereference)); } - static clang::CallGraphNode &CGdereference(PairTy P) { - return *(P.second); - } + static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; } static unsigned size(const clang::CallGraph *CG) { return CG->size();