From: Tim Shen Date: Fri, 19 Aug 2016 21:52:42 +0000 (+0000) Subject: [CallGraph] Use decltype instead of pointer_to_unary_function. NFC. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=74acca8a8962f955e2faca9b9bd6bc22d0af8e24;p=clang [CallGraph] Use decltype instead of pointer_to_unary_function. NFC. Reviewers: dblaikie Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D23726 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@279329 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/CallGraph.h b/include/clang/Analysis/CallGraph.h index 303fbcec52..6ff1e7f939 100644 --- a/include/clang/Analysis/CallGraph.h +++ b/include/clang/Analysis/CallGraph.h @@ -173,26 +173,20 @@ namespace llvm { template <> struct GraphTraits { typedef clang::CallGraphNode NodeType; typedef clang::CallGraphNode *NodeRef; - typedef clang::CallGraphNode::CallRecord CallRecordTy; - typedef std::pointer_to_unary_function CGNDerefFun; + typedef NodeType::iterator ChildIteratorType; + static NodeType *getEntryNode(clang::CallGraphNode *CGN) { return CGN; } - typedef mapped_iterator 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 { 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 @@ template <> struct GraphTraits return CGN->getRoot(); // Start at the external node! } typedef std::pair PairTy; - typedef std::pointer_to_unary_function - 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 nodes_iterator; + typedef mapped_iterator + 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 @@ template <> struct GraphTraits : return CGN->getRoot(); } typedef std::pair PairTy; - typedef std::pointer_to_unary_function - 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 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(); }