[cfe-commits] r76156 - in /cfe/trunk: include/clang/Analysis/CallGraph.h lib/Analysis/CallGraph.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Thu Jul 16 22:49:19 PDT 2009
Author: zhongxingxu
Date: Fri Jul 17 00:49:16 2009
New Revision: 76156
URL: http://llvm.org/viewvc/llvm-project?rev=76156&view=rev
Log:
CallGraph:
- add IfStmt visitor.
- print information only when a function has callee. Otherwise its ASTContext
map is NULL.
Modified:
cfe/trunk/include/clang/Analysis/CallGraph.h
cfe/trunk/lib/Analysis/CallGraph.cpp
Modified: cfe/trunk/include/clang/Analysis/CallGraph.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CallGraph.h?rev=76156&r1=76155&r2=76156&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/CallGraph.h (original)
+++ cfe/trunk/include/clang/Analysis/CallGraph.h Fri Jul 17 00:49:16 2009
@@ -43,6 +43,8 @@
CalledFunctions.push_back(std::make_pair(L, Node));
}
+ bool hasCallee() const { return begin() != end(); }
+
const char *getName(ASTContext &Ctx) { return F->getName(Ctx); }
};
Modified: cfe/trunk/lib/Analysis/CallGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CallGraph.cpp?rev=76156&r1=76155&r2=76156&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CallGraph.cpp (original)
+++ cfe/trunk/lib/Analysis/CallGraph.cpp Fri Jul 17 00:49:16 2009
@@ -37,6 +37,10 @@
VisitChildren(S);
}
+ void VisitIfStmt(IfStmt *S) {
+ VisitChildren(S);
+ }
+
void VisitCallExpr(CallExpr *CE);
void VisitChildren(Stmt *S) {
@@ -106,13 +110,15 @@
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';
}
}
More information about the cfe-commits
mailing list