aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Analysis/CallGraph.h9
-rw-r--r--lib/Analysis/CallGraph.cpp4
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<Decl *, CallGraphNode *> FunctionMapTy;
+ typedef llvm::DenseMap<const Decl *, CallGraphNode *> 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<clang::CallGraph*>
static NodeType *getEntryNode(clang::CallGraph *CGN) {
return CGN->getRoot(); // Start at the external node!
}
- typedef std::pair<clang::Decl*, clang::CallGraphNode*> PairTy;
+ typedef std::pair<const clang::Decl*, clang::CallGraphNode*> PairTy;
typedef std::pointer_to_unary_function<PairTy, clang::CallGraphNode&> DerefFun;
// nodes_iterator/begin/end - Allow iteration over all nodes in the graph
typedef mapped_iterator<clang::CallGraph::iterator, DerefFun> nodes_iterator;
@@ -190,7 +193,7 @@ template <> struct GraphTraits<const clang::CallGraph*> :
static NodeType *getEntryNode(const clang::CallGraph *CGN) {
return CGN->getRoot();
}
- typedef std::pair<clang::Decl*, clang::CallGraphNode*> PairTy;
+ typedef std::pair<const clang::Decl*, clang::CallGraphNode*> PairTy;
typedef std::pointer_to_unary_function<PairTy, clang::CallGraphNode&> DerefFun;
// nodes_iterator/begin/end - Allow iteration over all nodes in the graph
typedef mapped_iterator<clang::CallGraph::const_iterator,
diff --git a/lib/Analysis/CallGraph.cpp b/lib/Analysis/CallGraph.cpp
index ca73c4a161..cc6e62c388 100644
--- a/lib/Analysis/CallGraph.cpp
+++ b/lib/Analysis/CallGraph.cpp
@@ -136,6 +136,10 @@ void CallGraph::addToCallGraph(DeclContext *DC) {
}
}
+CallGraphNode *CallGraph::getNode(const Decl *F) const {
+ return FunctionMap.find(F)->second;
+}
+
CallGraphNode *CallGraph::getOrInsertFunction(Decl *F) {
CallGraphNode *&Node = FunctionMap[F];
if (Node)