From e3e643f12cc65a70e440bcdbb37b81d5fd022143 Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Fri, 24 Jul 2009 03:41:11 +0000 Subject: [PATCH] Add getDecl() to CallGraph and CallGraphNode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76940 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Analysis/CallGraph.h | 4 ++++ lib/Analysis/CallGraph.cpp | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/include/clang/Analysis/CallGraph.h b/include/clang/Analysis/CallGraph.h index 8c437c5261..fabeea38d5 100644 --- a/include/clang/Analysis/CallGraph.h +++ b/include/clang/Analysis/CallGraph.h @@ -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(); diff --git a/lib/Analysis/CallGraph.cpp b/lib/Analysis/CallGraph.cpp index 07c2b35349..1e28411eb4 100644 --- a/lib/Analysis/CallGraph.cpp +++ b/lib/Analysis/CallGraph.cpp @@ -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()) { -- 2.40.0