[cfe-commits] r107462 - /cfe/trunk/examples/wpa/clang-wpa.cpp

Zhongxing Xu xuzhongxing at gmail.com
Thu Jul 1 23:58:30 PDT 2010


Author: zhongxingxu
Date: Fri Jul  2 01:58:30 2010
New Revision: 107462

URL: http://llvm.org/viewvc/llvm-project?rev=107462&view=rev
Log:
add -view-call-graph option to wpa.

Modified:
    cfe/trunk/examples/wpa/clang-wpa.cpp

Modified: cfe/trunk/examples/wpa/clang-wpa.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/wpa/clang-wpa.cpp?rev=107462&r1=107461&r2=107462&view=diff
==============================================================================
--- cfe/trunk/examples/wpa/clang-wpa.cpp (original)
+++ cfe/trunk/examples/wpa/clang-wpa.cpp Fri Jul  2 01:58:30 2010
@@ -26,6 +26,9 @@
 static llvm::cl::list<std::string>
 InputFilenames(llvm::cl::Positional, llvm::cl::desc("<input AST files>"));
 
+static llvm::cl::opt<bool> ViewCallGraph("view-call-graph", 
+                                     llvm::cl::desc("Display the call graph."));
+
 int main(int argc, char **argv) {
   llvm::cl::ParseCommandLineOptions(argc, argv, "clang-wpa");
   FileManager FileMgr;
@@ -48,11 +51,14 @@
     ASTUnits.push_back(AST.take());
   }
 
-  llvm::OwningPtr<CallGraph> CG;
-  CG.reset(new CallGraph(Prog));
+  if (ViewCallGraph) {
+    llvm::OwningPtr<CallGraph> CG;
+    CG.reset(new CallGraph(Prog));
 
-  for (unsigned i = 0, e = ASTUnits.size(); i != e; ++i)
-    CG->addTU(ASTUnits[i]->getASTContext());
+    for (unsigned i = 0, e = ASTUnits.size(); i != e; ++i)
+      CG->addTU(ASTUnits[i]->getASTContext());
 
-  CG->ViewCallGraph();
+    CG->ViewCallGraph();
+    return 0;
+  }
 }





More information about the cfe-commits mailing list