AnalysisConsumer.cpp revision 7fe8dcef71ae56e43fd7df345db2895f84f2d0ca
1//===--- AnalysisConsumer.cpp - ASTConsumer for running Analyses ----------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// "Meta" ASTConsumer for running different source analyses. 11// 12//===----------------------------------------------------------------------===// 13 14#define DEBUG_TYPE "AnalysisConsumer" 15 16#include "AnalysisConsumer.h" 17#include "clang/AST/ASTConsumer.h" 18#include "clang/AST/Decl.h" 19#include "clang/AST/DeclCXX.h" 20#include "clang/AST/DeclObjC.h" 21#include "clang/AST/ParentMap.h" 22#include "clang/AST/RecursiveASTVisitor.h" 23#include "clang/Analysis/CFG.h" 24#include "clang/Analysis/CallGraph.h" 25#include "clang/StaticAnalyzer/Frontend/CheckerRegistration.h" 26#include "clang/StaticAnalyzer/Core/CheckerManager.h" 27#include "clang/StaticAnalyzer/Checkers/LocalCheckers.h" 28#include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h" 29#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h" 30#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" 31#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h" 32#include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h" 33 34#include "clang/Basic/FileManager.h" 35#include "clang/Basic/SourceManager.h" 36#include "clang/Frontend/AnalyzerOptions.h" 37#include "clang/Lex/Preprocessor.h" 38#include "llvm/Support/raw_ostream.h" 39#include "llvm/Support/Path.h" 40#include "llvm/Support/Program.h" 41#include "llvm/Support/Timer.h" 42#include "llvm/ADT/DepthFirstIterator.h" 43#include "llvm/ADT/OwningPtr.h" 44#include "llvm/ADT/Statistic.h" 45 46#include <queue> 47 48using namespace clang; 49using namespace ento; 50using llvm::SmallPtrSet; 51 52static ExplodedNode::Auditor* CreateUbiViz(); 53 54STATISTIC(NumFunctionTopLevel, "The # of functions at top level."); 55STATISTIC(NumFunctionsAnalyzed, "The # of functions analysed (as top level)."); 56 57//===----------------------------------------------------------------------===// 58// Special PathDiagnosticConsumers. 59//===----------------------------------------------------------------------===// 60 61static PathDiagnosticConsumer* 62createPlistHTMLDiagnosticConsumer(const std::string& prefix, 63 const Preprocessor &PP) { 64 PathDiagnosticConsumer *PD = 65 createHTMLDiagnosticConsumer(llvm::sys::path::parent_path(prefix), PP); 66 return createPlistDiagnosticConsumer(prefix, PP, PD); 67} 68 69//===----------------------------------------------------------------------===// 70// AnalysisConsumer declaration. 71//===----------------------------------------------------------------------===// 72 73namespace { 74 75class AnalysisConsumer : public ASTConsumer, 76 public RecursiveASTVisitor<AnalysisConsumer> { 77 enum AnalysisMode { 78 ANALYSIS_SYNTAX, 79 ANALYSIS_PATH, 80 ANALYSIS_ALL 81 }; 82 83 /// Mode of the analyzes while recursively visiting Decls. 84 AnalysisMode RecVisitorMode; 85 /// Bug Reporter to use while recursively visiting Decls. 86 BugReporter *RecVisitorBR; 87 88public: 89 ASTContext *Ctx; 90 const Preprocessor &PP; 91 const std::string OutDir; 92 AnalyzerOptions Opts; 93 ArrayRef<std::string> Plugins; 94 95 // PD is owned by AnalysisManager. 96 PathDiagnosticConsumer *PD; 97 98 StoreManagerCreator CreateStoreMgr; 99 ConstraintManagerCreator CreateConstraintMgr; 100 101 OwningPtr<CheckerManager> checkerMgr; 102 OwningPtr<AnalysisManager> Mgr; 103 104 /// Time the analyzes time of each translation unit. 105 static llvm::Timer* TUTotalTimer; 106 107 AnalysisConsumer(const Preprocessor& pp, 108 const std::string& outdir, 109 const AnalyzerOptions& opts, 110 ArrayRef<std::string> plugins) 111 : RecVisitorMode(ANALYSIS_ALL), RecVisitorBR(0), 112 Ctx(0), PP(pp), OutDir(outdir), Opts(opts), Plugins(plugins), PD(0) { 113 DigestAnalyzerOptions(); 114 if (Opts.PrintStats) { 115 llvm::EnableStatistics(); 116 TUTotalTimer = new llvm::Timer("Analyzer Total Time"); 117 } 118 } 119 120 ~AnalysisConsumer() { 121 if (Opts.PrintStats) 122 delete TUTotalTimer; 123 } 124 125 void DigestAnalyzerOptions() { 126 // Create the PathDiagnosticConsumer. 127 if (!OutDir.empty()) { 128 switch (Opts.AnalysisDiagOpt) { 129 default: 130#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN, AUTOCREATE) \ 131 case PD_##NAME: PD = CREATEFN(OutDir, PP); break; 132#include "clang/Frontend/Analyses.def" 133 } 134 } else if (Opts.AnalysisDiagOpt == PD_TEXT) { 135 // Create the text client even without a specified output file since 136 // it just uses diagnostic notes. 137 PD = createTextPathDiagnosticConsumer("", PP); 138 } 139 140 // Create the analyzer component creators. 141 switch (Opts.AnalysisStoreOpt) { 142 default: 143 llvm_unreachable("Unknown store manager."); 144#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATEFN) \ 145 case NAME##Model: CreateStoreMgr = CREATEFN; break; 146#include "clang/Frontend/Analyses.def" 147 } 148 149 switch (Opts.AnalysisConstraintsOpt) { 150 default: 151 llvm_unreachable("Unknown store manager."); 152#define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATEFN) \ 153 case NAME##Model: CreateConstraintMgr = CREATEFN; break; 154#include "clang/Frontend/Analyses.def" 155 } 156 } 157 158 void DisplayFunction(const Decl *D, AnalysisMode Mode) { 159 if (!Opts.AnalyzerDisplayProgress) 160 return; 161 162 SourceManager &SM = Mgr->getASTContext().getSourceManager(); 163 PresumedLoc Loc = SM.getPresumedLoc(D->getLocation()); 164 if (Loc.isValid()) { 165 llvm::errs() << "ANALYZE"; 166 switch (Mode) { 167 case ANALYSIS_SYNTAX: llvm::errs() << "(Syntax)"; break; 168 case ANALYSIS_PATH: llvm::errs() << "(Path Sensitive)"; break; 169 case ANALYSIS_ALL: break; 170 }; 171 llvm::errs() << ": " << Loc.getFilename(); 172 if (isa<FunctionDecl>(D) || isa<ObjCMethodDecl>(D)) { 173 const NamedDecl *ND = cast<NamedDecl>(D); 174 llvm::errs() << ' ' << *ND << '\n'; 175 } 176 else if (isa<BlockDecl>(D)) { 177 llvm::errs() << ' ' << "block(line:" << Loc.getLine() << ",col:" 178 << Loc.getColumn() << '\n'; 179 } 180 else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) { 181 Selector S = MD->getSelector(); 182 llvm::errs() << ' ' << S.getAsString(); 183 } 184 } 185 } 186 187 virtual void Initialize(ASTContext &Context) { 188 Ctx = &Context; 189 checkerMgr.reset(createCheckerManager(Opts, PP.getLangOpts(), Plugins, 190 PP.getDiagnostics())); 191 Mgr.reset(new AnalysisManager(*Ctx, PP.getDiagnostics(), 192 PP.getLangOpts(), PD, 193 CreateStoreMgr, CreateConstraintMgr, 194 checkerMgr.get(), 195 /* Indexer */ 0, 196 Opts.MaxNodes, Opts.MaxLoop, 197 Opts.VisualizeEGDot, Opts.VisualizeEGUbi, 198 Opts.AnalysisPurgeOpt, Opts.EagerlyAssume, 199 Opts.TrimGraph, 200 Opts.UnoptimizedCFG, Opts.CFGAddImplicitDtors, 201 Opts.CFGAddInitializers, 202 Opts.EagerlyTrimEGraph, 203 Opts.IPAMode, 204 Opts.InlineMaxStackDepth, 205 Opts.InlineMaxFunctionSize, 206 Opts.InliningMode)); 207 } 208 209 virtual void HandleTranslationUnit(ASTContext &C); 210 211 /// \brief Build the call graph for the TU and use it to define the order 212 /// in which the functions should be visited. 213 void HandleDeclsGallGraph(TranslationUnitDecl *TU); 214 215 /// \brief Run analyzes(syntax or path sensitive) on the given function. 216 /// \param Mode - determines if we are requesting syntax only or path 217 /// sensitive only analysis. 218 /// \param VisitedCallees - The output parameter, which is populated with the 219 /// set of functions which should be considered analyzed after analyzing the 220 /// given root function. 221 void HandleCode(Decl *D, AnalysisMode Mode, SetOfDecls *VisitedCallees = 0); 222 223 /// \brief Check if we should skip (not analyze) the given function. 224 bool skipFunction(Decl *D); 225 226 void RunPathSensitiveChecks(Decl *D, SetOfDecls *VisitedCallees); 227 void ActionExprEngine(Decl *D, bool ObjCGCEnabled, SetOfDecls *VisitedCallees); 228 229 /// Visitors for the RecursiveASTVisitor. 230 231 /// Handle callbacks for arbitrary Decls. 232 bool VisitDecl(Decl *D) { 233 checkerMgr->runCheckersOnASTDecl(D, *Mgr, *RecVisitorBR); 234 return true; 235 } 236 237 bool VisitFunctionDecl(FunctionDecl *FD) { 238 IdentifierInfo *II = FD->getIdentifier(); 239 if (II && II->getName().startswith("__inline")) 240 return true; 241 242 // We skip function template definitions, as their semantics is 243 // only determined when they are instantiated. 244 if (FD->isThisDeclarationADefinition() && 245 !FD->isDependentContext()) { 246 HandleCode(FD, RecVisitorMode); 247 } 248 return true; 249 } 250 251 bool VisitObjCMethodDecl(ObjCMethodDecl *MD) { 252 checkerMgr->runCheckersOnASTDecl(MD, *Mgr, *RecVisitorBR); 253 if (MD->isThisDeclarationADefinition()) 254 HandleCode(MD, RecVisitorMode); 255 return true; 256 } 257}; 258} // end anonymous namespace 259 260 261//===----------------------------------------------------------------------===// 262// AnalysisConsumer implementation. 263//===----------------------------------------------------------------------===// 264llvm::Timer* AnalysisConsumer::TUTotalTimer = 0; 265 266void AnalysisConsumer::HandleDeclsGallGraph(TranslationUnitDecl *TU) { 267 // Otherwise, use the Callgraph to derive the order. 268 // Build the Call Graph. 269 CallGraph CG; 270 CG.addToCallGraph(TU); 271 272 // Find the top level nodes - children of root + the unreachable (parentless) 273 // nodes. 274 llvm::SmallVector<CallGraphNode*, 24> TopLevelFunctions; 275 CallGraphNode *Entry = CG.getRoot(); 276 for (CallGraphNode::iterator I = Entry->begin(), 277 E = Entry->end(); I != E; ++I) { 278 TopLevelFunctions.push_back(*I); 279 NumFunctionTopLevel++; 280 } 281 for (CallGraph::nodes_iterator TI = CG.parentless_begin(), 282 TE = CG.parentless_end(); TI != TE; ++TI) { 283 TopLevelFunctions.push_back(*TI); 284 NumFunctionTopLevel++; 285 } 286 287 std::queue<CallGraphNode*> BFSQueue; 288 for (llvm::SmallVector<CallGraphNode*, 24>::iterator 289 TI = TopLevelFunctions.begin(), TE = TopLevelFunctions.end(); 290 TI != TE; ++TI) 291 BFSQueue.push(*TI); 292 293 // BFS over all of the functions, while skipping the ones inlined into 294 // the previously processed functions. Use external Visited set, which is 295 // also modified when we inline a function. 296 SmallPtrSet<CallGraphNode*,24> Visited; 297 while(!BFSQueue.empty()) { 298 CallGraphNode *N = BFSQueue.front(); 299 BFSQueue.pop(); 300 301 // Skip the functions which have been processed already or previously 302 // inlined. 303 if (Visited.count(N)) 304 continue; 305 306 // Analyze the function. 307 SetOfDecls VisitedCallees; 308 Decl *D = N->getDecl(); 309 assert(D); 310 HandleCode(D, ANALYSIS_PATH, 311 (Mgr->InliningMode == All ? 0 : &VisitedCallees)); 312 313 // Add the visited callees to the global visited set. 314 for (SetOfDecls::const_iterator I = VisitedCallees.begin(), 315 E = VisitedCallees.end(); I != E; ++I) { 316 CallGraphNode *VN = CG.getNode(*I); 317 if (VN) 318 Visited.insert(VN); 319 } 320 Visited.insert(N); 321 322 // Push the children into the queue. 323 for (CallGraphNode::const_iterator CI = N->begin(), 324 CE = N->end(); CI != CE; ++CI) { 325 BFSQueue.push(*CI); 326 } 327 } 328} 329 330void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) { 331 // Don't run the actions if an error has occurred with parsing the file. 332 DiagnosticsEngine &Diags = PP.getDiagnostics(); 333 if (Diags.hasErrorOccurred() || Diags.hasFatalErrorOccurred()) 334 return; 335 336 { 337 if (TUTotalTimer) TUTotalTimer->startTimer(); 338 339 // Introduce a scope to destroy BR before Mgr. 340 BugReporter BR(*Mgr); 341 TranslationUnitDecl *TU = C.getTranslationUnitDecl(); 342 checkerMgr->runCheckersOnASTDecl(TU, *Mgr, BR); 343 344 // Run the AST-only checks using the order in which functions are defined. 345 // If inlining is not turned on, use the simplest function order for path 346 // sensitive analyzes as well. 347 RecVisitorMode = (Mgr->shouldInlineCall() ? ANALYSIS_SYNTAX : ANALYSIS_ALL); 348 RecVisitorBR = &BR; 349 TraverseDecl(TU); 350 351 if (Mgr->shouldInlineCall()) 352 HandleDeclsGallGraph(TU); 353 354 // After all decls handled, run checkers on the entire TranslationUnit. 355 checkerMgr->runCheckersOnEndOfTranslationUnit(TU, *Mgr, BR); 356 357 RecVisitorBR = 0; 358 } 359 360 // Explicitly destroy the PathDiagnosticConsumer. This will flush its output. 361 // FIXME: This should be replaced with something that doesn't rely on 362 // side-effects in PathDiagnosticConsumer's destructor. This is required when 363 // used with option -disable-free. 364 Mgr.reset(NULL); 365 366 if (TUTotalTimer) TUTotalTimer->stopTimer(); 367} 368 369static void FindBlocks(DeclContext *D, SmallVectorImpl<Decl*> &WL) { 370 if (BlockDecl *BD = dyn_cast<BlockDecl>(D)) 371 WL.push_back(BD); 372 373 for (DeclContext::decl_iterator I = D->decls_begin(), E = D->decls_end(); 374 I!=E; ++I) 375 if (DeclContext *DC = dyn_cast<DeclContext>(*I)) 376 FindBlocks(DC, WL); 377} 378 379static std::string getFunctionName(const Decl *D) { 380 if (const ObjCMethodDecl *ID = dyn_cast<ObjCMethodDecl>(D)) { 381 return ID->getSelector().getAsString(); 382 } 383 if (const FunctionDecl *ND = dyn_cast<FunctionDecl>(D)) { 384 IdentifierInfo *II = ND->getIdentifier(); 385 if (II) 386 return II->getName(); 387 } 388 return ""; 389} 390 391bool AnalysisConsumer::skipFunction(Decl *D) { 392 if (!Opts.AnalyzeSpecificFunction.empty() && 393 getFunctionName(D) != Opts.AnalyzeSpecificFunction) 394 return true; 395 396 // Don't run the actions on declarations in header files unless 397 // otherwise specified. 398 SourceManager &SM = Ctx->getSourceManager(); 399 SourceLocation SL = SM.getExpansionLoc(D->getLocation()); 400 if (!Opts.AnalyzeAll && !SM.isFromMainFile(SL)) 401 return true; 402 403 return false; 404} 405 406void AnalysisConsumer::HandleCode(Decl *D, AnalysisMode Mode, 407 SetOfDecls *VisitedCallees) { 408 if (skipFunction(D)) 409 return; 410 411 DisplayFunction(D, Mode); 412 413 // Clear the AnalysisManager of old AnalysisDeclContexts. 414 Mgr->ClearContexts(); 415 416 // Dispatch on the actions. 417 SmallVector<Decl*, 10> WL; 418 WL.push_back(D); 419 420 if (D->hasBody() && Opts.AnalyzeNestedBlocks) 421 FindBlocks(cast<DeclContext>(D), WL); 422 423 BugReporter BR(*Mgr); 424 for (SmallVectorImpl<Decl*>::iterator WI=WL.begin(), WE=WL.end(); 425 WI != WE; ++WI) 426 if ((*WI)->hasBody()) { 427 if (Mode != ANALYSIS_PATH) 428 checkerMgr->runCheckersOnASTBody(*WI, *Mgr, BR); 429 if (Mode != ANALYSIS_SYNTAX && checkerMgr->hasPathSensitiveCheckers()) 430 RunPathSensitiveChecks(*WI, VisitedCallees); 431 } 432 NumFunctionsAnalyzed++; 433} 434 435//===----------------------------------------------------------------------===// 436// Path-sensitive checking. 437//===----------------------------------------------------------------------===// 438 439void AnalysisConsumer::ActionExprEngine(Decl *D, bool ObjCGCEnabled, 440 SetOfDecls *VisitedCallees) { 441 // Construct the analysis engine. First check if the CFG is valid. 442 // FIXME: Inter-procedural analysis will need to handle invalid CFGs. 443 if (!Mgr->getCFG(D)) 444 return; 445 446 ExprEngine Eng(*Mgr, ObjCGCEnabled, VisitedCallees); 447 448 // Set the graph auditor. 449 OwningPtr<ExplodedNode::Auditor> Auditor; 450 if (Mgr->shouldVisualizeUbigraph()) { 451 Auditor.reset(CreateUbiViz()); 452 ExplodedNode::SetAuditor(Auditor.get()); 453 } 454 455 // Execute the worklist algorithm. 456 Eng.ExecuteWorkList(Mgr->getAnalysisDeclContextManager().getStackFrame(D, 0), 457 Mgr->getMaxNodes()); 458 459 // Release the auditor (if any) so that it doesn't monitor the graph 460 // created BugReporter. 461 ExplodedNode::SetAuditor(0); 462 463 // Visualize the exploded graph. 464 if (Mgr->shouldVisualizeGraphviz()) 465 Eng.ViewGraph(Mgr->shouldTrimGraph()); 466 467 // Display warnings. 468 Eng.getBugReporter().FlushReports(); 469} 470 471void AnalysisConsumer::RunPathSensitiveChecks(Decl *D, SetOfDecls *Visited) { 472 473 switch (Mgr->getLangOpts().getGC()) { 474 case LangOptions::NonGC: 475 ActionExprEngine(D, false, Visited); 476 break; 477 478 case LangOptions::GCOnly: 479 ActionExprEngine(D, true, Visited); 480 break; 481 482 case LangOptions::HybridGC: 483 ActionExprEngine(D, false, Visited); 484 ActionExprEngine(D, true, Visited); 485 break; 486 } 487} 488 489//===----------------------------------------------------------------------===// 490// AnalysisConsumer creation. 491//===----------------------------------------------------------------------===// 492 493ASTConsumer* ento::CreateAnalysisConsumer(const Preprocessor& pp, 494 const std::string& outDir, 495 const AnalyzerOptions& opts, 496 ArrayRef<std::string> plugins) { 497 // Disable the effects of '-Werror' when using the AnalysisConsumer. 498 pp.getDiagnostics().setWarningsAsErrors(false); 499 500 return new AnalysisConsumer(pp, outDir, opts, plugins); 501} 502 503//===----------------------------------------------------------------------===// 504// Ubigraph Visualization. FIXME: Move to separate file. 505//===----------------------------------------------------------------------===// 506 507namespace { 508 509class UbigraphViz : public ExplodedNode::Auditor { 510 OwningPtr<raw_ostream> Out; 511 llvm::sys::Path Dir, Filename; 512 unsigned Cntr; 513 514 typedef llvm::DenseMap<void*,unsigned> VMap; 515 VMap M; 516 517public: 518 UbigraphViz(raw_ostream *out, llvm::sys::Path& dir, 519 llvm::sys::Path& filename); 520 521 ~UbigraphViz(); 522 523 virtual void AddEdge(ExplodedNode *Src, ExplodedNode *Dst); 524}; 525 526} // end anonymous namespace 527 528static ExplodedNode::Auditor* CreateUbiViz() { 529 std::string ErrMsg; 530 531 llvm::sys::Path Dir = llvm::sys::Path::GetTemporaryDirectory(&ErrMsg); 532 if (!ErrMsg.empty()) 533 return 0; 534 535 llvm::sys::Path Filename = Dir; 536 Filename.appendComponent("llvm_ubi"); 537 Filename.makeUnique(true,&ErrMsg); 538 539 if (!ErrMsg.empty()) 540 return 0; 541 542 llvm::errs() << "Writing '" << Filename.str() << "'.\n"; 543 544 OwningPtr<llvm::raw_fd_ostream> Stream; 545 Stream.reset(new llvm::raw_fd_ostream(Filename.c_str(), ErrMsg)); 546 547 if (!ErrMsg.empty()) 548 return 0; 549 550 return new UbigraphViz(Stream.take(), Dir, Filename); 551} 552 553void UbigraphViz::AddEdge(ExplodedNode *Src, ExplodedNode *Dst) { 554 555 assert (Src != Dst && "Self-edges are not allowed."); 556 557 // Lookup the Src. If it is a new node, it's a root. 558 VMap::iterator SrcI= M.find(Src); 559 unsigned SrcID; 560 561 if (SrcI == M.end()) { 562 M[Src] = SrcID = Cntr++; 563 *Out << "('vertex', " << SrcID << ", ('color','#00ff00'))\n"; 564 } 565 else 566 SrcID = SrcI->second; 567 568 // Lookup the Dst. 569 VMap::iterator DstI= M.find(Dst); 570 unsigned DstID; 571 572 if (DstI == M.end()) { 573 M[Dst] = DstID = Cntr++; 574 *Out << "('vertex', " << DstID << ")\n"; 575 } 576 else { 577 // We have hit DstID before. Change its style to reflect a cache hit. 578 DstID = DstI->second; 579 *Out << "('change_vertex_style', " << DstID << ", 1)\n"; 580 } 581 582 // Add the edge. 583 *Out << "('edge', " << SrcID << ", " << DstID 584 << ", ('arrow','true'), ('oriented', 'true'))\n"; 585} 586 587UbigraphViz::UbigraphViz(raw_ostream *out, llvm::sys::Path& dir, 588 llvm::sys::Path& filename) 589 : Out(out), Dir(dir), Filename(filename), Cntr(0) { 590 591 *Out << "('vertex_style_attribute', 0, ('shape', 'icosahedron'))\n"; 592 *Out << "('vertex_style', 1, 0, ('shape', 'sphere'), ('color', '#ffcc66')," 593 " ('size', '1.5'))\n"; 594} 595 596UbigraphViz::~UbigraphViz() { 597 Out.reset(0); 598 llvm::errs() << "Running 'ubiviz' program... "; 599 std::string ErrMsg; 600 llvm::sys::Path Ubiviz = llvm::sys::Program::FindProgramByName("ubiviz"); 601 std::vector<const char*> args; 602 args.push_back(Ubiviz.c_str()); 603 args.push_back(Filename.c_str()); 604 args.push_back(0); 605 606 if (llvm::sys::Program::ExecuteAndWait(Ubiviz, &args[0],0,0,0,0,&ErrMsg)) { 607 llvm::errs() << "Error viewing graph: " << ErrMsg << "\n"; 608 } 609 610 // Delete the directory. 611 Dir.eraseFromDisk(true); 612} 613