This revision was automatically updated to reflect the committed changes. Closed by commit rL279329: [CallGraph] Use decltype instead of pointer_to_unary_function. NFC. (authored by timshen).
Changed prior to commit: https://reviews.llvm.org/D23726?vs=68733&id=68736#toc Repository: rL LLVM https://reviews.llvm.org/D23726 Files: cfe/trunk/include/clang/Analysis/CallGraph.h Index: cfe/trunk/include/clang/Analysis/CallGraph.h =================================================================== --- cfe/trunk/include/clang/Analysis/CallGraph.h +++ cfe/trunk/include/clang/Analysis/CallGraph.h @@ -173,26 +173,20 @@ template <> struct GraphTraits<clang::CallGraphNode*> { typedef clang::CallGraphNode NodeType; typedef clang::CallGraphNode *NodeRef; - typedef clang::CallGraphNode::CallRecord CallRecordTy; - typedef std::pointer_to_unary_function<CallRecordTy, - clang::CallGraphNode*> CGNDerefFun; + typedef NodeType::iterator ChildIteratorType; + static NodeType *getEntryNode(clang::CallGraphNode *CGN) { return CGN; } - typedef mapped_iterator<NodeType::iterator, CGNDerefFun> ChildIteratorType; static inline ChildIteratorType child_begin(NodeType *N) { - return map_iterator(N->begin(), CGNDerefFun(CGNDeref)); - } - static inline ChildIteratorType child_end (NodeType *N) { - return map_iterator(N->end(), CGNDerefFun(CGNDeref)); - } - static clang::CallGraphNode *CGNDeref(CallRecordTy P) { - return P; + return N->begin(); } + static inline ChildIteratorType child_end(NodeType *N) { return N->end(); } }; template <> struct GraphTraits<const clang::CallGraphNode*> { typedef const clang::CallGraphNode NodeType; typedef const clang::CallGraphNode *NodeRef; typedef NodeType::const_iterator ChildIteratorType; + static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; } static inline ChildIteratorType child_begin(NodeType *N) { return N->begin();} static inline ChildIteratorType child_end(NodeType *N) { return N->end(); } @@ -205,18 +199,19 @@ return CGN->getRoot(); // Start at the external node! } typedef std::pair<const clang::Decl*, clang::CallGraphNode*> PairTy; - typedef std::pointer_to_unary_function<PairTy, clang::CallGraphNode *> - DerefFun; + + static clang::CallGraphNode *CGGetValue(PairTy P) { return P.second; } + // nodes_iterator/begin/end - Allow iteration over all nodes in the graph - typedef mapped_iterator<clang::CallGraph::iterator, DerefFun> nodes_iterator; + typedef mapped_iterator<clang::CallGraph::iterator, decltype(&CGGetValue)> + nodes_iterator; static nodes_iterator nodes_begin(clang::CallGraph *CG) { - return map_iterator(CG->begin(), DerefFun(CGdereference)); + return nodes_iterator(CG->begin(), &CGGetValue); } static nodes_iterator nodes_end (clang::CallGraph *CG) { - return map_iterator(CG->end(), DerefFun(CGdereference)); + return nodes_iterator(CG->end(), &CGGetValue); } - static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; } static unsigned size(clang::CallGraph *CG) { return CG->size(); @@ -229,20 +224,20 @@ return CGN->getRoot(); } typedef std::pair<const clang::Decl*, clang::CallGraphNode*> PairTy; - typedef std::pointer_to_unary_function<PairTy, clang::CallGraphNode *> - DerefFun; + + static clang::CallGraphNode *CGGetValue(PairTy P) { return P.second; } + // nodes_iterator/begin/end - Allow iteration over all nodes in the graph typedef mapped_iterator<clang::CallGraph::const_iterator, - DerefFun> nodes_iterator; + decltype(&CGGetValue)> + nodes_iterator; static nodes_iterator nodes_begin(const clang::CallGraph *CG) { - return map_iterator(CG->begin(), DerefFun(CGdereference)); + return nodes_iterator(CG->begin(), &CGGetValue); } static nodes_iterator nodes_end(const clang::CallGraph *CG) { - return map_iterator(CG->end(), DerefFun(CGdereference)); + return nodes_iterator(CG->end(), &CGGetValue); } - static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; } - static unsigned size(const clang::CallGraph *CG) { return CG->size(); }
Index: cfe/trunk/include/clang/Analysis/CallGraph.h =================================================================== --- cfe/trunk/include/clang/Analysis/CallGraph.h +++ cfe/trunk/include/clang/Analysis/CallGraph.h @@ -173,26 +173,20 @@ template <> struct GraphTraits<clang::CallGraphNode*> { typedef clang::CallGraphNode NodeType; typedef clang::CallGraphNode *NodeRef; - typedef clang::CallGraphNode::CallRecord CallRecordTy; - typedef std::pointer_to_unary_function<CallRecordTy, - clang::CallGraphNode*> CGNDerefFun; + typedef NodeType::iterator ChildIteratorType; + static NodeType *getEntryNode(clang::CallGraphNode *CGN) { return CGN; } - typedef mapped_iterator<NodeType::iterator, CGNDerefFun> ChildIteratorType; static inline ChildIteratorType child_begin(NodeType *N) { - return map_iterator(N->begin(), CGNDerefFun(CGNDeref)); - } - static inline ChildIteratorType child_end (NodeType *N) { - return map_iterator(N->end(), CGNDerefFun(CGNDeref)); - } - static clang::CallGraphNode *CGNDeref(CallRecordTy P) { - return P; + return N->begin(); } + static inline ChildIteratorType child_end(NodeType *N) { return N->end(); } }; template <> struct GraphTraits<const clang::CallGraphNode*> { typedef const clang::CallGraphNode NodeType; typedef const clang::CallGraphNode *NodeRef; typedef NodeType::const_iterator ChildIteratorType; + static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; } static inline ChildIteratorType child_begin(NodeType *N) { return N->begin();} static inline ChildIteratorType child_end(NodeType *N) { return N->end(); } @@ -205,18 +199,19 @@ return CGN->getRoot(); // Start at the external node! } typedef std::pair<const clang::Decl*, clang::CallGraphNode*> PairTy; - typedef std::pointer_to_unary_function<PairTy, clang::CallGraphNode *> - DerefFun; + + static clang::CallGraphNode *CGGetValue(PairTy P) { return P.second; } + // nodes_iterator/begin/end - Allow iteration over all nodes in the graph - typedef mapped_iterator<clang::CallGraph::iterator, DerefFun> nodes_iterator; + typedef mapped_iterator<clang::CallGraph::iterator, decltype(&CGGetValue)> + nodes_iterator; static nodes_iterator nodes_begin(clang::CallGraph *CG) { - return map_iterator(CG->begin(), DerefFun(CGdereference)); + return nodes_iterator(CG->begin(), &CGGetValue); } static nodes_iterator nodes_end (clang::CallGraph *CG) { - return map_iterator(CG->end(), DerefFun(CGdereference)); + return nodes_iterator(CG->end(), &CGGetValue); } - static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; } static unsigned size(clang::CallGraph *CG) { return CG->size(); @@ -229,20 +224,20 @@ return CGN->getRoot(); } typedef std::pair<const clang::Decl*, clang::CallGraphNode*> PairTy; - typedef std::pointer_to_unary_function<PairTy, clang::CallGraphNode *> - DerefFun; + + static clang::CallGraphNode *CGGetValue(PairTy P) { return P.second; } + // nodes_iterator/begin/end - Allow iteration over all nodes in the graph typedef mapped_iterator<clang::CallGraph::const_iterator, - DerefFun> nodes_iterator; + decltype(&CGGetValue)> + nodes_iterator; static nodes_iterator nodes_begin(const clang::CallGraph *CG) { - return map_iterator(CG->begin(), DerefFun(CGdereference)); + return nodes_iterator(CG->begin(), &CGGetValue); } static nodes_iterator nodes_end(const clang::CallGraph *CG) { - return map_iterator(CG->end(), DerefFun(CGdereference)); + return nodes_iterator(CG->end(), &CGGetValue); } - static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; } - static unsigned size(const clang::CallGraph *CG) { return CG->size(); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits