Add getDecl() to CallGraph and CallGraphNode.
authorZhongxing Xu <xuzhongxing@gmail.com>
Fri, 24 Jul 2009 03:41:11 +0000 (03:41 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Fri, 24 Jul 2009 03:41:11 +0000 (03:41 +0000)
llvm-svn: 76940

clang/include/clang/Analysis/CallGraph.h
clang/lib/Analysis/CallGraph.cpp

index 8c437c5..fabeea3 100644 (file)
@@ -49,6 +49,8 @@ public:
   bool hasCallee() const { return begin() != end(); }
 
   std::string getName() const { return F.getPrintableName(); }
+
+  Decl *getDecl(ASTContext &Ctx) const { return F.getDecl(Ctx); }
 };
 
 class CallGraph {
@@ -91,6 +93,8 @@ public:
 
   CallGraphNode *getOrInsertFunction(idx::Entity F);
 
+  Decl *getDecl(CallGraphNode *Node);
+
   void print(llvm::raw_ostream &os);
   void dump();
 
index 07c2b35..1e28411 100644 (file)
@@ -108,6 +108,13 @@ CallGraphNode *CallGraph::getOrInsertFunction(Entity F) {
   return Node = new CallGraphNode(F);
 }
 
+Decl *CallGraph::getDecl(CallGraphNode *Node) {
+  // Get the function's context.
+  ASTContext *Ctx = CallerCtx[Node];
+
+  return Node->getDecl(*Ctx);
+}
+
 void CallGraph::print(llvm::raw_ostream &os) {
   for (iterator I = begin(), E = end(); I != E; ++I) {
     if (I->second->hasCallee()) {