From a5d531f67de0cfeb56b843da15146f3b4cd75bd9 Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Fri, 9 Mar 2012 21:13:53 +0000 Subject: [PATCH] CallGraph: Add getNode() method, constify. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152439 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Analysis/CallGraph.h | 9 ++++++--- lib/Analysis/CallGraph.cpp | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/clang/Analysis/CallGraph.h b/include/clang/Analysis/CallGraph.h index 156f890e4b..81926b9f87 100644 --- a/include/clang/Analysis/CallGraph.h +++ b/include/clang/Analysis/CallGraph.h @@ -27,7 +27,7 @@ class CallGraphNode; class CallGraph { friend class CallGraphNode; - typedef llvm::DenseMap FunctionMapTy; + typedef llvm::DenseMap FunctionMapTy; /// FunctionMap owns all CallGraphNodes. FunctionMapTy FunctionMap; @@ -51,6 +51,9 @@ public: /// \brief Populate the call graph with the functions in the given DeclContext. void addToCallGraph(DeclContext *DC); + /// \brief Lookup the node for the given declaration. + CallGraphNode *getNode(const Decl *) const; + /// \brief Lookup the node for the given declaration. If none found, insert /// one into the graph. CallGraphNode *getOrInsertFunction(Decl *); @@ -165,7 +168,7 @@ template <> struct GraphTraits static NodeType *getEntryNode(clang::CallGraph *CGN) { return CGN->getRoot(); // Start at the external node! } - typedef std::pair PairTy; + typedef std::pair PairTy; typedef std::pointer_to_unary_function DerefFun; // nodes_iterator/begin/end - Allow iteration over all nodes in the graph typedef mapped_iterator nodes_iterator; @@ -190,7 +193,7 @@ template <> struct GraphTraits : static NodeType *getEntryNode(const clang::CallGraph *CGN) { return CGN->getRoot(); } - typedef std::pair PairTy; + typedef std::pair PairTy; typedef std::pointer_to_unary_function DerefFun; // nodes_iterator/begin/end - Allow iteration over all nodes in the graph typedef mapped_iteratorsecond; +} + CallGraphNode *CallGraph::getOrInsertFunction(Decl *F) { CallGraphNode *&Node = FunctionMap[F]; if (Node) -- 2.40.0