Author: zaks
Date: Fri Mar  9 15:13:53 2012
New Revision: 152439

URL: http://llvm.org/viewvc/llvm-project?rev=152439&view=rev
Log:
CallGraph: Add getNode() method, constify.

Modified:
    cfe/trunk/include/clang/Analysis/CallGraph.h
    cfe/trunk/lib/Analysis/CallGraph.cpp

Modified: cfe/trunk/include/clang/Analysis/CallGraph.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CallGraph.h?rev=152439&r1=152438&r2=152439&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/CallGraph.h (original)
+++ cfe/trunk/include/clang/Analysis/CallGraph.h Fri Mar  9 15:13:53 2012
@@ -27,7 +27,7 @@
 
 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 @@
   /// \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 @@
   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 @@
   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,

Modified: cfe/trunk/lib/Analysis/CallGraph.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CallGraph.cpp?rev=152439&r1=152438&r2=152439&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CallGraph.cpp (original)
+++ cfe/trunk/lib/Analysis/CallGraph.cpp Fri Mar  9 15:13:53 2012
@@ -136,6 +136,10 @@
   }
 }
 
+CallGraphNode *CallGraph::getNode(const Decl *F) const {
+  return FunctionMap.find(F)->second;
+}
+
 CallGraphNode *CallGraph::getOrInsertFunction(Decl *F) {
   CallGraphNode *&Node = FunctionMap[F];
   if (Node)


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to