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
diff --git a/lib/Analysis/CallGraph.cpp b/lib/Analysis/CallGraph.cpp
index a296f60..422c501 100644
--- a/lib/Analysis/CallGraph.cpp
+++ b/lib/Analysis/CallGraph.cpp
@@ -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';
   }
 }