diff --git a/examples/wpa/clang-wpa.cpp b/examples/wpa/clang-wpa.cpp index c75626dab5..04a706e0a0 100644 --- a/examples/wpa/clang-wpa.cpp +++ b/examples/wpa/clang-wpa.cpp @@ -26,6 +26,9 @@ using namespace idx; static llvm::cl::list InputFilenames(llvm::cl::Positional, llvm::cl::desc("")); +static llvm::cl::opt 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 @@ int main(int argc, char **argv) { ASTUnits.push_back(AST.take()); } - llvm::OwningPtr CG; - CG.reset(new CallGraph(Prog)); + if (ViewCallGraph) { + llvm::OwningPtr 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; + } }