diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-07-17 07:36:20 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-07-17 07:36:20 +0000 |
commit | 7f66bd28b5e9016f2f6f4ddc52e083352f90ed11 (patch) | |
tree | b2798ed5b7fc6d9d923bac7993515bb1d66cbb8e /lib | |
parent | a00425414e8c209cabc25d1826b200aeb94259af (diff) |
As suggested by Argyrios, revert r76159 and make "FindImmediateParent"
a public static method of ASTLocation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76166 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/CallGraph.cpp | 5 | ||||
-rw-r--r-- | lib/Index/ASTLocation.cpp | 12 |
2 files changed, 5 insertions, 12 deletions
diff --git a/lib/Analysis/CallGraph.cpp b/lib/Analysis/CallGraph.cpp index d49e8ec11b..2ec6d2014d 100644 --- a/lib/Analysis/CallGraph.cpp +++ b/lib/Analysis/CallGraph.cpp @@ -69,7 +69,10 @@ void CGBuilder::VisitCallExpr(CallExpr *CE) { if (FunctionDecl *CalleeDecl = CE->getDirectCallee()) { Entity *Ent = Entity::get(CalleeDecl, G.getProgram()); CallGraphNode *CalleeNode = G.getOrInsertFunction(Ent); - CallerNode->addCallee(ASTLocation(FD, CE), CalleeNode); + + Decl *Parent = ASTLocation::FindImmediateParent(FD, CE); + + CallerNode->addCallee(ASTLocation(Parent, CE), CalleeNode); } } diff --git a/lib/Index/ASTLocation.cpp b/lib/Index/ASTLocation.cpp index 3beff3f31a..41846055da 100644 --- a/lib/Index/ASTLocation.cpp +++ b/lib/Index/ASTLocation.cpp @@ -33,7 +33,7 @@ static bool isContainedInStatement(Stmt *Node, Stmt *Parent) { return false; } -static Decl *FindImmediateParent(Decl *D, Stmt *Node) { +Decl *ASTLocation::FindImmediateParent(Decl *D, Stmt *Node) { assert(D && Node && "Passed null Decl or null Stmt"); if (VarDecl *VD = dyn_cast<VarDecl>(D)) { @@ -61,16 +61,6 @@ static Decl *FindImmediateParent(Decl *D, Stmt *Node) { return 0; } -ASTLocation::ASTLocation(const Decl *d, const Stmt *stm) - : D(const_cast<Decl*>(d)), Stm(const_cast<Stmt*>(stm)) { - if (Stm) { - Decl *Parent = FindImmediateParent(D, Stm); - assert(Parent); - D = Parent; - } -} - - bool ASTLocation::isImmediateParent(Decl *D, Stmt *Node) { assert(D && Node && "Passed null Decl or null Stmt"); return D == FindImmediateParent(D, Node); |