diff options
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); |