]> granicus.if.org Git - clang/commitdiff
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)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76940 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 8c437c5261b68254a1a700e58ed495d65e36f075..fabeea38d597a23d25acfa9b566b13de6abaf707 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 07c2b35349f966c8b84e30753e1f37de4c72e7b5..1e28411eb4668ee06b05b96e4747e1e72297d1a0 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()) {