From 3c8fa978adee9387a1e3a1f60e8fe5d6b9ccc14a Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Fri, 17 Jul 2009 07:29:51 +0000 Subject: Refactor code into a new CallExpr::getDirectCallee() method. Simplify some code with the new method. llvm-svn: 76164 --- clang/lib/Analysis/CallGraph.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'clang/lib/Analysis/CallGraph.cpp') diff --git a/clang/lib/Analysis/CallGraph.cpp b/clang/lib/Analysis/CallGraph.cpp index 16f14d787f4..d49e8ec11be 100644 --- a/clang/lib/Analysis/CallGraph.cpp +++ b/clang/lib/Analysis/CallGraph.cpp @@ -66,21 +66,10 @@ public: } void CGBuilder::VisitCallExpr(CallExpr *CE) { - Expr *Callee = CE->getCallee(); - - if (CastExpr *CE = dyn_cast(Callee)) - Callee = CE->getSubExpr(); - - if (DeclRefExpr *DRE = dyn_cast(Callee)) { - Decl *D = DRE->getDecl(); - if (FunctionDecl *CalleeDecl = dyn_cast(D)) { - - Entity *Ent = Entity::get(CalleeDecl, G.getProgram()); - - CallGraphNode *CalleeNode = G.getOrInsertFunction(Ent); - - CallerNode->addCallee(ASTLocation(FD, CE), CalleeNode); - } + if (FunctionDecl *CalleeDecl = CE->getDirectCallee()) { + Entity *Ent = Entity::get(CalleeDecl, G.getProgram()); + CallGraphNode *CalleeNode = G.getOrInsertFunction(Ent); + CallerNode->addCallee(ASTLocation(FD, CE), CalleeNode); } } -- cgit v1.2.3