aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-07-17 05:49:16 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-07-17 05:49:16 +0000
commit24ff030f400b261c142bab748bf2d26e5aaa948c (patch)
tree859c6d5da0362a7dcc026b04b2f6a669028abc68
parent6d9828c82c9321f042ab416fd2ffaa3034347d45 (diff)
CallGraph:
- add IfStmt visitor. - print information only when a function has callee. Otherwise its ASTContext map is NULL. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76156 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Analysis/CallGraph.h2
-rw-r--r--lib/Analysis/CallGraph.cpp18
2 files changed, 14 insertions, 6 deletions
diff --git a/include/clang/Analysis/CallGraph.h b/include/clang/Analysis/CallGraph.h
index bf164c0e72..8de0e9f976 100644
--- a/include/clang/Analysis/CallGraph.h
+++ b/include/clang/Analysis/CallGraph.h
@@ -43,6 +43,8 @@ public:
CalledFunctions.push_back(std::make_pair(L, Node));
}
+ bool hasCallee() const { return begin() != end(); }
+
const char *getName(ASTContext &Ctx) { return F->getName(Ctx); }
};
diff --git a/lib/Analysis/CallGraph.cpp b/lib/Analysis/CallGraph.cpp
index a296f60553..422c5013cc 100644
--- a/lib/Analysis/CallGraph.cpp
+++ b/lib/Analysis/CallGraph.cpp
@@ -37,6 +37,10 @@ public:
VisitChildren(S);
}
+ void VisitIfStmt(IfStmt *S) {
+ VisitChildren(S);
+ }
+
void VisitCallExpr(CallExpr *CE);
void VisitChildren(Stmt *S) {
@@ -106,13 +110,15 @@ CallGraphNode *CallGraph::getOrInsertFunction(Entity *F) {
void CallGraph::print(llvm::raw_ostream &os) {
for (iterator I = begin(), E = end(); I != E; ++I) {
- ASTContext &Ctx = *CallerCtx[I->second];
- os << "function: " << I->first->getName(Ctx) << " calls:\n";
- for (CallGraphNode::iterator CI = I->second->begin(), CE = I->second->end();
- CI != CE; ++CI) {
- os << " " << CI->second->getName(Ctx);
+ if (I->second->hasCallee()) {
+ ASTContext &Ctx = *CallerCtx[I->second];
+ os << "function: " << I->first->getName(Ctx) << " calls:\n";
+ for (CallGraphNode::iterator CI = I->second->begin(),
+ CE = I->second->end(); CI != CE; ++CI) {
+ os << " " << CI->second->getName(Ctx);
+ }
+ os << '\n';
}
- os << '\n';
}
}