Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 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 | |
Eli Friedman | 0ec78fa | 2009-05-19 21:10:40 +0000 | [diff] [blame] | 14 | #include "clang/Frontend/AnalysisConsumer.h" |
Daniel Dunbar | e1bd4e6 | 2009-03-02 06:16:29 +0000 | [diff] [blame] | 15 | #include "clang/Frontend/PathDiagnosticClients.h" |
| 16 | #include "clang/Frontend/ManagerRegistry.h" |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 17 | #include "clang/AST/ASTConsumer.h" |
| 18 | #include "clang/AST/Decl.h" |
| 19 | #include "clang/AST/DeclObjC.h" |
Ted Kremenek | e41611a | 2009-07-16 18:13:04 +0000 | [diff] [blame] | 20 | #include "clang/Analysis/CFG.h" |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 21 | #include "clang/Analysis/Analyses/LiveVariables.h" |
| 22 | #include "clang/Analysis/PathDiagnostic.h" |
| 23 | #include "clang/Basic/SourceManager.h" |
| 24 | #include "clang/Basic/FileManager.h" |
| 25 | #include "clang/AST/ParentMap.h" |
Zhongxing Xu | fda7832 | 2009-07-30 09:11:52 +0000 | [diff] [blame] | 26 | #include "clang/Analysis/PathSensitive/AnalysisManager.h" |
Ted Kremenek | c095997 | 2008-07-02 21:24:01 +0000 | [diff] [blame] | 27 | #include "clang/Analysis/PathSensitive/BugReporter.h" |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 28 | #include "clang/Analysis/Analyses/LiveVariables.h" |
| 29 | #include "clang/Analysis/LocalCheckers.h" |
| 30 | #include "clang/Analysis/PathSensitive/GRTransferFuncs.h" |
| 31 | #include "clang/Analysis/PathSensitive/GRExprEngine.h" |
Zhongxing Xu | ff944a8 | 2008-12-22 01:52:37 +0000 | [diff] [blame] | 32 | #include "llvm/Support/CommandLine.h" |
Benjamin Kramer | 6cb7c1a | 2009-08-23 12:08:50 +0000 | [diff] [blame] | 33 | #include "llvm/Support/Compiler.h" |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 34 | #include "llvm/Support/raw_ostream.h" |
| 35 | #include "llvm/System/Path.h" |
Ted Kremenek | 710ad93 | 2008-08-28 03:54:51 +0000 | [diff] [blame] | 36 | #include "llvm/System/Program.h" |
Benjamin Kramer | 6cb7c1a | 2009-08-23 12:08:50 +0000 | [diff] [blame] | 37 | #include "llvm/ADT/OwningPtr.h" |
Ted Kremenek | db09a4d | 2008-07-03 04:29:21 +0000 | [diff] [blame] | 38 | |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 39 | using namespace clang; |
| 40 | |
Zhongxing Xu | c5619d9 | 2009-08-06 01:32:16 +0000 | [diff] [blame] | 41 | static ExplodedNode::Auditor* CreateUbiViz(); |
Zhongxing Xu | ff944a8 | 2008-12-22 01:52:37 +0000 | [diff] [blame] | 42 | |
Ted Kremenek | be1fe1e | 2009-02-17 04:27:41 +0000 | [diff] [blame] | 43 | //===----------------------------------------------------------------------===// |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 44 | // Basic type definitions. |
| 45 | //===----------------------------------------------------------------------===// |
| 46 | |
Ted Kremenek | fb9a48c | 2008-07-14 23:41:13 +0000 | [diff] [blame] | 47 | namespace { |
Ted Kremenek | fb9a48c | 2008-07-14 23:41:13 +0000 | [diff] [blame] | 48 | typedef void (*CodeAction)(AnalysisManager& Mgr); |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 49 | } // end anonymous namespace |
| 50 | |
| 51 | //===----------------------------------------------------------------------===// |
Ted Kremenek | f755606 | 2009-07-27 22:13:39 +0000 | [diff] [blame] | 52 | // Special PathDiagnosticClients. |
| 53 | //===----------------------------------------------------------------------===// |
| 54 | |
| 55 | static PathDiagnosticClient* |
| 56 | CreatePlistHTMLDiagnosticClient(const std::string& prefix, Preprocessor* PP, |
| 57 | PreprocessorFactory* PPF) { |
| 58 | llvm::sys::Path F(prefix); |
| 59 | PathDiagnosticClientFactory *PF = |
| 60 | CreateHTMLDiagnosticClientFactory(F.getDirname(), PP, PPF); |
| 61 | return CreatePlistDiagnosticClient(prefix, PP, PPF, PF); |
| 62 | } |
| 63 | |
| 64 | //===----------------------------------------------------------------------===// |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 65 | // AnalysisConsumer declaration. |
| 66 | //===----------------------------------------------------------------------===// |
| 67 | |
| 68 | namespace { |
| 69 | |
| 70 | class VISIBILITY_HIDDEN AnalysisConsumer : public ASTConsumer { |
Ted Kremenek | db09a4d | 2008-07-03 04:29:21 +0000 | [diff] [blame] | 71 | typedef std::vector<CodeAction> Actions; |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 72 | Actions FunctionActions; |
| 73 | Actions ObjCMethodActions; |
Ted Kremenek | db09a4d | 2008-07-03 04:29:21 +0000 | [diff] [blame] | 74 | Actions ObjCImplementationActions; |
Ted Kremenek | daac634 | 2008-11-07 02:09:25 +0000 | [diff] [blame] | 75 | Actions TranslationUnitActions; |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 76 | |
| 77 | public: |
Ted Kremenek | 95c7b00 | 2008-10-24 01:04:59 +0000 | [diff] [blame] | 78 | const LangOptions& LOpts; |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 79 | Diagnostic &Diags; |
| 80 | ASTContext* Ctx; |
| 81 | Preprocessor* PP; |
| 82 | PreprocessorFactory* PPF; |
Ted Kremenek | be1fe1e | 2009-02-17 04:27:41 +0000 | [diff] [blame] | 83 | const std::string OutDir; |
Eli Friedman | e71b85f | 2009-05-19 10:18:02 +0000 | [diff] [blame] | 84 | AnalyzerOptions Opts; |
Zhongxing Xu | fda7832 | 2009-07-30 09:11:52 +0000 | [diff] [blame] | 85 | |
Zhongxing Xu | d07a0d0 | 2009-08-03 03:27:37 +0000 | [diff] [blame] | 86 | |
| 87 | // PD is owned by AnalysisManager. |
| 88 | PathDiagnosticClient *PD; |
| 89 | |
Zhongxing Xu | fda7832 | 2009-07-30 09:11:52 +0000 | [diff] [blame] | 90 | StoreManagerCreator CreateStoreMgr; |
| 91 | ConstraintManagerCreator CreateConstraintMgr; |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 92 | |
Zhongxing Xu | c471e7b | 2009-08-03 03:13:46 +0000 | [diff] [blame] | 93 | llvm::OwningPtr<AnalysisManager> Mgr; |
| 94 | |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 95 | AnalysisConsumer(Diagnostic &diags, Preprocessor* pp, |
| 96 | PreprocessorFactory* ppf, |
| 97 | const LangOptions& lopts, |
Eli Friedman | e71b85f | 2009-05-19 10:18:02 +0000 | [diff] [blame] | 98 | const std::string& outdir, |
| 99 | const AnalyzerOptions& opts) |
Ted Kremenek | be1fe1e | 2009-02-17 04:27:41 +0000 | [diff] [blame] | 100 | : LOpts(lopts), Diags(diags), |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 101 | Ctx(0), PP(pp), PPF(ppf), |
Douglas Gregor | 17edea8 | 2009-07-30 16:10:26 +0000 | [diff] [blame] | 102 | OutDir(outdir), Opts(opts), PD(0) { |
Zhongxing Xu | fda7832 | 2009-07-30 09:11:52 +0000 | [diff] [blame] | 103 | DigestAnalyzerOptions(); |
| 104 | } |
| 105 | |
| 106 | void DigestAnalyzerOptions() { |
| 107 | // Create the PathDiagnosticClient. |
| 108 | if (!OutDir.empty()) { |
| 109 | switch (Opts.AnalysisDiagOpt) { |
| 110 | default: |
| 111 | #define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN, AUTOCREATE) \ |
Zhongxing Xu | d07a0d0 | 2009-08-03 03:27:37 +0000 | [diff] [blame] | 112 | case PD_##NAME: PD = CREATEFN(OutDir, PP, PPF); break; |
Zhongxing Xu | fda7832 | 2009-07-30 09:11:52 +0000 | [diff] [blame] | 113 | #include "clang/Frontend/Analyses.def" |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | // Create the analyzer component creators. |
| 118 | if (ManagerRegistry::StoreMgrCreator != 0) { |
| 119 | CreateStoreMgr = ManagerRegistry::StoreMgrCreator; |
| 120 | } |
| 121 | else { |
| 122 | switch (Opts.AnalysisStoreOpt) { |
| 123 | default: |
| 124 | assert(0 && "Unknown store manager."); |
| 125 | #define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATEFN) \ |
| 126 | case NAME##Model: CreateStoreMgr = CREATEFN; break; |
| 127 | #include "clang/Frontend/Analyses.def" |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | if (ManagerRegistry::ConstraintMgrCreator != 0) |
| 132 | CreateConstraintMgr = ManagerRegistry::ConstraintMgrCreator; |
| 133 | else { |
| 134 | switch (Opts.AnalysisConstraintsOpt) { |
| 135 | default: |
| 136 | assert(0 && "Unknown store manager."); |
| 137 | #define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATEFN) \ |
| 138 | case NAME##Model: CreateConstraintMgr = CREATEFN; break; |
| 139 | #include "clang/Frontend/Analyses.def" |
| 140 | } |
| 141 | } |
| 142 | } |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 143 | |
| 144 | void addCodeAction(CodeAction action) { |
Ted Kremenek | db09a4d | 2008-07-03 04:29:21 +0000 | [diff] [blame] | 145 | FunctionActions.push_back(action); |
| 146 | ObjCMethodActions.push_back(action); |
| 147 | } |
| 148 | |
| 149 | void addObjCImplementationAction(CodeAction action) { |
| 150 | ObjCImplementationActions.push_back(action); |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 151 | } |
| 152 | |
Ted Kremenek | daac634 | 2008-11-07 02:09:25 +0000 | [diff] [blame] | 153 | void addTranslationUnitAction(CodeAction action) { |
| 154 | TranslationUnitActions.push_back(action); |
| 155 | } |
| 156 | |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 157 | virtual void Initialize(ASTContext &Context) { |
| 158 | Ctx = &Context; |
Zhongxing Xu | d07a0d0 | 2009-08-03 03:27:37 +0000 | [diff] [blame] | 159 | Mgr.reset(new AnalysisManager(*Ctx, Diags, LOpts, PD, |
Zhongxing Xu | c471e7b | 2009-08-03 03:13:46 +0000 | [diff] [blame] | 160 | CreateStoreMgr, CreateConstraintMgr, |
| 161 | Opts.AnalyzerDisplayProgress, |
| 162 | Opts.VisualizeEGDot, Opts.VisualizeEGUbi, |
| 163 | Opts.PurgeDead, Opts.EagerlyAssume, |
| 164 | Opts.TrimGraph)); |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 165 | } |
| 166 | |
Chris Lattner | 682bf92 | 2009-03-29 16:50:03 +0000 | [diff] [blame] | 167 | virtual void HandleTopLevelDecl(DeclGroupRef D) { |
| 168 | for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I) |
| 169 | HandleTopLevelSingleDecl(*I); |
| 170 | } |
| 171 | |
| 172 | void HandleTopLevelSingleDecl(Decl *D); |
Chris Lattner | dacbc5d | 2009-03-28 04:11:33 +0000 | [diff] [blame] | 173 | virtual void HandleTranslationUnit(ASTContext &C); |
Ted Kremenek | db09a4d | 2008-07-03 04:29:21 +0000 | [diff] [blame] | 174 | |
Ted Kremenek | 81922f0 | 2009-02-02 20:52:40 +0000 | [diff] [blame] | 175 | void HandleCode(Decl* D, Stmt* Body, Actions& actions); |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 176 | }; |
| 177 | |
| 178 | |
Zhongxing Xu | 22438a8 | 2008-11-27 01:55:08 +0000 | [diff] [blame] | 179 | |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 180 | } // end anonymous namespace |
| 181 | |
| 182 | namespace llvm { |
| 183 | template <> struct FoldingSetTrait<CodeAction> { |
| 184 | static inline void Profile(CodeAction X, FoldingSetNodeID& ID) { |
| 185 | ID.AddPointer(reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(X))); |
| 186 | } |
| 187 | }; |
| 188 | } |
| 189 | |
| 190 | //===----------------------------------------------------------------------===// |
| 191 | // AnalysisConsumer implementation. |
| 192 | //===----------------------------------------------------------------------===// |
| 193 | |
Chris Lattner | 682bf92 | 2009-03-29 16:50:03 +0000 | [diff] [blame] | 194 | void AnalysisConsumer::HandleTopLevelSingleDecl(Decl *D) { |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 195 | switch (D->getKind()) { |
| 196 | case Decl::Function: { |
| 197 | FunctionDecl* FD = cast<FunctionDecl>(D); |
Ted Kremenek | 235e031 | 2008-07-02 18:11:29 +0000 | [diff] [blame] | 198 | |
Eli Friedman | e71b85f | 2009-05-19 10:18:02 +0000 | [diff] [blame] | 199 | if (Opts.AnalyzeSpecificFunction.size() > 0 && |
| 200 | Opts.AnalyzeSpecificFunction != FD->getIdentifier()->getName()) |
Ted Kremenek | 235e031 | 2008-07-02 18:11:29 +0000 | [diff] [blame] | 201 | break; |
| 202 | |
Argyrios Kyrtzidis | 6fb0aee | 2009-06-30 02:35:26 +0000 | [diff] [blame] | 203 | Stmt* Body = FD->getBody(); |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 204 | if (Body) HandleCode(FD, Body, FunctionActions); |
| 205 | break; |
| 206 | } |
| 207 | |
| 208 | case Decl::ObjCMethod: { |
| 209 | ObjCMethodDecl* MD = cast<ObjCMethodDecl>(D); |
Ted Kremenek | 235e031 | 2008-07-02 18:11:29 +0000 | [diff] [blame] | 210 | |
Eli Friedman | e71b85f | 2009-05-19 10:18:02 +0000 | [diff] [blame] | 211 | if (Opts.AnalyzeSpecificFunction.size() > 0 && |
| 212 | Opts.AnalyzeSpecificFunction != MD->getSelector().getAsString()) |
Ted Kremenek | 235e031 | 2008-07-02 18:11:29 +0000 | [diff] [blame] | 213 | return; |
| 214 | |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 215 | Stmt* Body = MD->getBody(); |
| 216 | if (Body) HandleCode(MD, Body, ObjCMethodActions); |
| 217 | break; |
| 218 | } |
| 219 | |
| 220 | default: |
| 221 | break; |
| 222 | } |
| 223 | } |
| 224 | |
Chris Lattner | dacbc5d | 2009-03-28 04:11:33 +0000 | [diff] [blame] | 225 | void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) { |
Ted Kremenek | daac634 | 2008-11-07 02:09:25 +0000 | [diff] [blame] | 226 | if(!TranslationUnitActions.empty()) { |
Ted Kremenek | daac634 | 2008-11-07 02:09:25 +0000 | [diff] [blame] | 227 | for (Actions::iterator I = TranslationUnitActions.begin(), |
| 228 | E = TranslationUnitActions.end(); I != E; ++I) |
Zhongxing Xu | c471e7b | 2009-08-03 03:13:46 +0000 | [diff] [blame] | 229 | (*I)(*Mgr); |
Ted Kremenek | daac634 | 2008-11-07 02:09:25 +0000 | [diff] [blame] | 230 | } |
| 231 | |
Chris Lattner | e907787 | 2009-03-28 03:29:40 +0000 | [diff] [blame] | 232 | if (!ObjCImplementationActions.empty()) { |
Chris Lattner | dacbc5d | 2009-03-28 04:11:33 +0000 | [diff] [blame] | 233 | TranslationUnitDecl *TUD = C.getTranslationUnitDecl(); |
Chris Lattner | e907787 | 2009-03-28 03:29:40 +0000 | [diff] [blame] | 234 | |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 235 | for (DeclContext::decl_iterator I = TUD->decls_begin(), |
| 236 | E = TUD->decls_end(); |
Chris Lattner | e907787 | 2009-03-28 03:29:40 +0000 | [diff] [blame] | 237 | I != E; ++I) |
Ted Kremenek | 4d53a53 | 2009-02-13 00:51:30 +0000 | [diff] [blame] | 238 | if (ObjCImplementationDecl* ID = dyn_cast<ObjCImplementationDecl>(*I)) |
| 239 | HandleCode(ID, 0, ObjCImplementationActions); |
Chris Lattner | e907787 | 2009-03-28 03:29:40 +0000 | [diff] [blame] | 240 | } |
Zhongxing Xu | d07a0d0 | 2009-08-03 03:27:37 +0000 | [diff] [blame] | 241 | |
Ted Kremenek | 690a7f4 | 2009-08-02 05:43:14 +0000 | [diff] [blame] | 242 | // Explicitly destroy the PathDiagnosticClient. This will flush its output. |
| 243 | // FIXME: This should be replaced with something that doesn't rely on |
| 244 | // side-effects in PathDiagnosticClient's destructor. |
Zhongxing Xu | d07a0d0 | 2009-08-03 03:27:37 +0000 | [diff] [blame] | 245 | Mgr.reset(NULL); |
Ted Kremenek | db09a4d | 2008-07-03 04:29:21 +0000 | [diff] [blame] | 246 | } |
| 247 | |
Ted Kremenek | 81922f0 | 2009-02-02 20:52:40 +0000 | [diff] [blame] | 248 | void AnalysisConsumer::HandleCode(Decl* D, Stmt* Body, Actions& actions) { |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 249 | |
| 250 | // Don't run the actions if an error has occured with parsing the file. |
| 251 | if (Diags.hasErrorOccurred()) |
| 252 | return; |
Ted Kremenek | 81922f0 | 2009-02-02 20:52:40 +0000 | [diff] [blame] | 253 | |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 254 | // Don't run the actions on declarations in header files unless |
| 255 | // otherwise specified. |
Eli Friedman | e71b85f | 2009-05-19 10:18:02 +0000 | [diff] [blame] | 256 | if (!Opts.AnalyzeAll && |
| 257 | !Ctx->getSourceManager().isFromMainFile(D->getLocation())) |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 258 | return; |
| 259 | |
Zhongxing Xu | 25e695b | 2009-08-15 03:17:38 +0000 | [diff] [blame] | 260 | Mgr->setEntryContext(D); |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 261 | |
| 262 | // Dispatch on the actions. |
Zhongxing Xu | 3702af5 | 2008-10-30 05:03:28 +0000 | [diff] [blame] | 263 | for (Actions::iterator I = actions.begin(), E = actions.end(); I != E; ++I) |
Zhongxing Xu | c471e7b | 2009-08-03 03:13:46 +0000 | [diff] [blame] | 264 | (*I)(*Mgr); |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | //===----------------------------------------------------------------------===// |
| 268 | // Analyses |
| 269 | //===----------------------------------------------------------------------===// |
| 270 | |
Ted Kremenek | fb9a48c | 2008-07-14 23:41:13 +0000 | [diff] [blame] | 271 | static void ActionWarnDeadStores(AnalysisManager& mgr) { |
Ted Kremenek | 7032f46 | 2008-07-03 05:26:14 +0000 | [diff] [blame] | 272 | if (LiveVariables* L = mgr.getLiveVariables()) { |
| 273 | BugReporter BR(mgr); |
| 274 | CheckDeadStores(*L, BR); |
| 275 | } |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 276 | } |
| 277 | |
Ted Kremenek | fb9a48c | 2008-07-14 23:41:13 +0000 | [diff] [blame] | 278 | static void ActionWarnUninitVals(AnalysisManager& mgr) { |
Ted Kremenek | 7032f46 | 2008-07-03 05:26:14 +0000 | [diff] [blame] | 279 | if (CFG* c = mgr.getCFG()) |
Zhongxing Xu | 5032ffe | 2009-08-25 06:51:30 +0000 | [diff] [blame] | 280 | CheckUninitializedValues(*c, mgr.getASTContext(), mgr.getDiagnostic()); |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 281 | } |
| 282 | |
Ted Kremenek | b35a74a | 2008-07-02 00:44:58 +0000 | [diff] [blame] | 283 | |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 284 | static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf, |
| 285 | bool StandardWarnings = true) { |
Ted Kremenek | b35a74a | 2008-07-02 00:44:58 +0000 | [diff] [blame] | 286 | |
Ted Kremenek | 7032f46 | 2008-07-03 05:26:14 +0000 | [diff] [blame] | 287 | |
Ted Kremenek | bc46f34 | 2008-07-02 16:35:50 +0000 | [diff] [blame] | 288 | llvm::OwningPtr<GRTransferFuncs> TF(tf); |
Ted Kremenek | 7032f46 | 2008-07-03 05:26:14 +0000 | [diff] [blame] | 289 | |
Ted Kremenek | 8ffc8a5 | 2008-11-24 20:53:32 +0000 | [diff] [blame] | 290 | // Display progress. |
| 291 | mgr.DisplayFunction(); |
| 292 | |
Ted Kremenek | 7032f46 | 2008-07-03 05:26:14 +0000 | [diff] [blame] | 293 | // Construct the analysis engine. |
| 294 | LiveVariables* L = mgr.getLiveVariables(); |
| 295 | if (!L) return; |
Ted Kremenek | 8ffc8a5 | 2008-11-24 20:53:32 +0000 | [diff] [blame] | 296 | |
Zhongxing Xu | 5032ffe | 2009-08-25 06:51:30 +0000 | [diff] [blame] | 297 | GRExprEngine Eng(mgr); |
Ted Kremenek | 95c7b00 | 2008-10-24 01:04:59 +0000 | [diff] [blame] | 298 | |
Ted Kremenek | bc46f34 | 2008-07-02 16:35:50 +0000 | [diff] [blame] | 299 | Eng.setTransferFunctions(tf); |
| 300 | |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 301 | if (StandardWarnings) { |
| 302 | Eng.RegisterInternalChecks(); |
Zhongxing Xu | 5ab128b | 2009-08-21 02:18:44 +0000 | [diff] [blame] | 303 | RegisterAppleChecks(Eng, *mgr.getCodeDecl()); |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 304 | } |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 305 | |
| 306 | // Set the graph auditor. |
Zhongxing Xu | c5619d9 | 2009-08-06 01:32:16 +0000 | [diff] [blame] | 307 | llvm::OwningPtr<ExplodedNode::Auditor> Auditor; |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 308 | if (mgr.shouldVisualizeUbigraph()) { |
| 309 | Auditor.reset(CreateUbiViz()); |
Zhongxing Xu | c5619d9 | 2009-08-06 01:32:16 +0000 | [diff] [blame] | 310 | ExplodedNode::SetAuditor(Auditor.get()); |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 311 | } |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 312 | |
Ted Kremenek | b35a74a | 2008-07-02 00:44:58 +0000 | [diff] [blame] | 313 | // Execute the worklist algorithm. |
Zhongxing Xu | 25e695b | 2009-08-15 03:17:38 +0000 | [diff] [blame] | 314 | Eng.ExecuteWorkList(mgr.getEntryStackFrame()); |
Ted Kremenek | bc46f34 | 2008-07-02 16:35:50 +0000 | [diff] [blame] | 315 | |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 316 | // Release the auditor (if any) so that it doesn't monitor the graph |
| 317 | // created BugReporter. |
Zhongxing Xu | c5619d9 | 2009-08-06 01:32:16 +0000 | [diff] [blame] | 318 | ExplodedNode::SetAuditor(0); |
Ted Kremenek | 3df6421 | 2009-03-11 01:42:29 +0000 | [diff] [blame] | 319 | |
Ted Kremenek | 34d7734 | 2008-07-02 16:49:11 +0000 | [diff] [blame] | 320 | // Visualize the exploded graph. |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 321 | if (mgr.shouldVisualizeGraphviz()) |
Ted Kremenek | 34d7734 | 2008-07-02 16:49:11 +0000 | [diff] [blame] | 322 | Eng.ViewGraph(mgr.shouldTrimGraph()); |
Ted Kremenek | 3df6421 | 2009-03-11 01:42:29 +0000 | [diff] [blame] | 323 | |
| 324 | // Display warnings. |
| 325 | Eng.getBugReporter().FlushReports(); |
Ted Kremenek | bc46f34 | 2008-07-02 16:35:50 +0000 | [diff] [blame] | 326 | } |
| 327 | |
Ted Kremenek | fb9a48c | 2008-07-14 23:41:13 +0000 | [diff] [blame] | 328 | static void ActionCheckerCFRefAux(AnalysisManager& mgr, bool GCEnabled, |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 329 | bool StandardWarnings) { |
| 330 | |
Zhongxing Xu | 5032ffe | 2009-08-25 06:51:30 +0000 | [diff] [blame] | 331 | GRTransferFuncs* TF = MakeCFRefCountTF(mgr.getASTContext(), |
Ted Kremenek | bc46f34 | 2008-07-02 16:35:50 +0000 | [diff] [blame] | 332 | GCEnabled, |
Ted Kremenek | bc46f34 | 2008-07-02 16:35:50 +0000 | [diff] [blame] | 333 | mgr.getLangOptions()); |
| 334 | |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 335 | ActionGRExprEngine(mgr, TF, StandardWarnings); |
Ted Kremenek | b35a74a | 2008-07-02 00:44:58 +0000 | [diff] [blame] | 336 | } |
| 337 | |
Ted Kremenek | fb9a48c | 2008-07-14 23:41:13 +0000 | [diff] [blame] | 338 | static void ActionCheckerCFRef(AnalysisManager& mgr) { |
Ted Kremenek | b35a74a | 2008-07-02 00:44:58 +0000 | [diff] [blame] | 339 | |
| 340 | switch (mgr.getLangOptions().getGCMode()) { |
| 341 | default: |
| 342 | assert (false && "Invalid GC mode."); |
| 343 | case LangOptions::NonGC: |
Ted Kremenek | fb9a48c | 2008-07-14 23:41:13 +0000 | [diff] [blame] | 344 | ActionCheckerCFRefAux(mgr, false, true); |
Ted Kremenek | b35a74a | 2008-07-02 00:44:58 +0000 | [diff] [blame] | 345 | break; |
| 346 | |
| 347 | case LangOptions::GCOnly: |
Ted Kremenek | fb9a48c | 2008-07-14 23:41:13 +0000 | [diff] [blame] | 348 | ActionCheckerCFRefAux(mgr, true, true); |
Ted Kremenek | b35a74a | 2008-07-02 00:44:58 +0000 | [diff] [blame] | 349 | break; |
| 350 | |
| 351 | case LangOptions::HybridGC: |
Ted Kremenek | fb9a48c | 2008-07-14 23:41:13 +0000 | [diff] [blame] | 352 | ActionCheckerCFRefAux(mgr, false, true); |
| 353 | ActionCheckerCFRefAux(mgr, true, false); |
Ted Kremenek | b35a74a | 2008-07-02 00:44:58 +0000 | [diff] [blame] | 354 | break; |
| 355 | } |
| 356 | } |
| 357 | |
Ted Kremenek | fb9a48c | 2008-07-14 23:41:13 +0000 | [diff] [blame] | 358 | static void ActionDisplayLiveVariables(AnalysisManager& mgr) { |
Ted Kremenek | 7032f46 | 2008-07-03 05:26:14 +0000 | [diff] [blame] | 359 | if (LiveVariables* L = mgr.getLiveVariables()) { |
| 360 | mgr.DisplayFunction(); |
| 361 | L->dumpBlockLiveness(mgr.getSourceManager()); |
| 362 | } |
Ted Kremenek | 235e031 | 2008-07-02 18:11:29 +0000 | [diff] [blame] | 363 | } |
| 364 | |
Ted Kremenek | 902141f | 2008-07-02 18:23:21 +0000 | [diff] [blame] | 365 | static void ActionCFGDump(AnalysisManager& mgr) { |
Ted Kremenek | 7032f46 | 2008-07-03 05:26:14 +0000 | [diff] [blame] | 366 | if (CFG* c = mgr.getCFG()) { |
| 367 | mgr.DisplayFunction(); |
Zhongxing Xu | 7d49c71 | 2009-07-30 09:14:54 +0000 | [diff] [blame] | 368 | c->dump(mgr.getLangOptions()); |
Ted Kremenek | 7032f46 | 2008-07-03 05:26:14 +0000 | [diff] [blame] | 369 | } |
Ted Kremenek | 902141f | 2008-07-02 18:23:21 +0000 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | static void ActionCFGView(AnalysisManager& mgr) { |
Ted Kremenek | 7032f46 | 2008-07-03 05:26:14 +0000 | [diff] [blame] | 373 | if (CFG* c = mgr.getCFG()) { |
| 374 | mgr.DisplayFunction(); |
Zhongxing Xu | 7d49c71 | 2009-07-30 09:14:54 +0000 | [diff] [blame] | 375 | c->viewCFG(mgr.getLangOptions()); |
Ted Kremenek | 7032f46 | 2008-07-03 05:26:14 +0000 | [diff] [blame] | 376 | } |
Ted Kremenek | 902141f | 2008-07-02 18:23:21 +0000 | [diff] [blame] | 377 | } |
| 378 | |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 379 | static void ActionSecuritySyntacticChecks(AnalysisManager &mgr) { |
| 380 | BugReporter BR(mgr); |
| 381 | CheckSecuritySyntaxOnly(mgr.getCodeDecl(), BR); |
| 382 | } |
| 383 | |
Ted Kremenek | fb9a48c | 2008-07-14 23:41:13 +0000 | [diff] [blame] | 384 | static void ActionWarnObjCDealloc(AnalysisManager& mgr) { |
Ted Kremenek | 4f4e7e4 | 2008-08-04 17:14:10 +0000 | [diff] [blame] | 385 | if (mgr.getLangOptions().getGCMode() == LangOptions::GCOnly) |
| 386 | return; |
| 387 | |
Ted Kremenek | db09a4d | 2008-07-03 04:29:21 +0000 | [diff] [blame] | 388 | BugReporter BR(mgr); |
Ted Kremenek | 3cd483c | 2008-07-03 14:35:01 +0000 | [diff] [blame] | 389 | |
| 390 | CheckObjCDealloc(cast<ObjCImplementationDecl>(mgr.getCodeDecl()), |
| 391 | mgr.getLangOptions(), BR); |
Ted Kremenek | db09a4d | 2008-07-03 04:29:21 +0000 | [diff] [blame] | 392 | } |
| 393 | |
Ted Kremenek | 395aaf2 | 2008-07-23 00:45:26 +0000 | [diff] [blame] | 394 | static void ActionWarnObjCUnusedIvars(AnalysisManager& mgr) { |
| 395 | BugReporter BR(mgr); |
| 396 | CheckObjCUnusedIvar(cast<ObjCImplementationDecl>(mgr.getCodeDecl()), BR); |
| 397 | } |
| 398 | |
Ted Kremenek | fb9a48c | 2008-07-14 23:41:13 +0000 | [diff] [blame] | 399 | static void ActionWarnObjCMethSigs(AnalysisManager& mgr) { |
Ted Kremenek | 0d8019e | 2008-07-11 22:40:47 +0000 | [diff] [blame] | 400 | BugReporter BR(mgr); |
| 401 | |
| 402 | CheckObjCInstMethSignature(cast<ObjCImplementationDecl>(mgr.getCodeDecl()), |
| 403 | BR); |
| 404 | } |
| 405 | |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 406 | //===----------------------------------------------------------------------===// |
| 407 | // AnalysisConsumer creation. |
| 408 | //===----------------------------------------------------------------------===// |
| 409 | |
Ted Kremenek | be1fe1e | 2009-02-17 04:27:41 +0000 | [diff] [blame] | 410 | ASTConsumer* clang::CreateAnalysisConsumer(Diagnostic &diags, Preprocessor* pp, |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 411 | PreprocessorFactory* ppf, |
| 412 | const LangOptions& lopts, |
Eli Friedman | e71b85f | 2009-05-19 10:18:02 +0000 | [diff] [blame] | 413 | const std::string& OutDir, |
| 414 | const AnalyzerOptions& Opts) { |
Ted Kremenek | be1fe1e | 2009-02-17 04:27:41 +0000 | [diff] [blame] | 415 | |
| 416 | llvm::OwningPtr<AnalysisConsumer> C(new AnalysisConsumer(diags, pp, ppf, |
Eli Friedman | e71b85f | 2009-05-19 10:18:02 +0000 | [diff] [blame] | 417 | lopts, OutDir, |
| 418 | Opts)); |
Ted Kremenek | be1fe1e | 2009-02-17 04:27:41 +0000 | [diff] [blame] | 419 | |
Eli Friedman | e71b85f | 2009-05-19 10:18:02 +0000 | [diff] [blame] | 420 | for (unsigned i = 0; i < Opts.AnalysisList.size(); ++i) |
| 421 | switch (Opts.AnalysisList[i]) { |
Ted Kremenek | f7f3c20 | 2008-07-15 00:46:02 +0000 | [diff] [blame] | 422 | #define ANALYSIS(NAME, CMD, DESC, SCOPE)\ |
Ted Kremenek | fb9a48c | 2008-07-14 23:41:13 +0000 | [diff] [blame] | 423 | case NAME:\ |
Ted Kremenek | f7f3c20 | 2008-07-15 00:46:02 +0000 | [diff] [blame] | 424 | C->add ## SCOPE ## Action(&Action ## NAME);\ |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 425 | break; |
Eli Friedman | 4df2c42 | 2009-05-19 21:16:18 +0000 | [diff] [blame] | 426 | #include "clang/Frontend/Analyses.def" |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 427 | default: break; |
| 428 | } |
Ted Kremenek | 2c4036e | 2009-05-07 19:02:53 +0000 | [diff] [blame] | 429 | |
| 430 | // Last, disable the effects of '-Werror' when using the AnalysisConsumer. |
| 431 | diags.setWarningsAsErrors(false); |
Ted Kremenek | be1fe1e | 2009-02-17 04:27:41 +0000 | [diff] [blame] | 432 | |
Ted Kremenek | f4381fd | 2008-07-02 00:03:09 +0000 | [diff] [blame] | 433 | return C.take(); |
| 434 | } |
| 435 | |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 436 | //===----------------------------------------------------------------------===// |
| 437 | // Ubigraph Visualization. FIXME: Move to separate file. |
| 438 | //===----------------------------------------------------------------------===// |
| 439 | |
| 440 | namespace { |
| 441 | |
Zhongxing Xu | c5619d9 | 2009-08-06 01:32:16 +0000 | [diff] [blame] | 442 | class UbigraphViz : public ExplodedNode::Auditor { |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 443 | llvm::OwningPtr<llvm::raw_ostream> Out; |
Ted Kremenek | 710ad93 | 2008-08-28 03:54:51 +0000 | [diff] [blame] | 444 | llvm::sys::Path Dir, Filename; |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 445 | unsigned Cntr; |
| 446 | |
| 447 | typedef llvm::DenseMap<void*,unsigned> VMap; |
| 448 | VMap M; |
| 449 | |
| 450 | public: |
Ted Kremenek | 710ad93 | 2008-08-28 03:54:51 +0000 | [diff] [blame] | 451 | UbigraphViz(llvm::raw_ostream* out, llvm::sys::Path& dir, |
Ted Kremenek | 56b9871 | 2008-08-28 05:02:09 +0000 | [diff] [blame] | 452 | llvm::sys::Path& filename); |
Ted Kremenek | 710ad93 | 2008-08-28 03:54:51 +0000 | [diff] [blame] | 453 | |
| 454 | ~UbigraphViz(); |
| 455 | |
Zhongxing Xu | c5619d9 | 2009-08-06 01:32:16 +0000 | [diff] [blame] | 456 | virtual void AddEdge(ExplodedNode* Src, ExplodedNode* Dst); |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 457 | }; |
| 458 | |
| 459 | } // end anonymous namespace |
| 460 | |
Zhongxing Xu | c5619d9 | 2009-08-06 01:32:16 +0000 | [diff] [blame] | 461 | static ExplodedNode::Auditor* CreateUbiViz() { |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 462 | std::string ErrMsg; |
| 463 | |
Ted Kremenek | 710ad93 | 2008-08-28 03:54:51 +0000 | [diff] [blame] | 464 | llvm::sys::Path Dir = llvm::sys::Path::GetTemporaryDirectory(&ErrMsg); |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 465 | if (!ErrMsg.empty()) |
| 466 | return 0; |
| 467 | |
Ted Kremenek | 710ad93 | 2008-08-28 03:54:51 +0000 | [diff] [blame] | 468 | llvm::sys::Path Filename = Dir; |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 469 | Filename.appendComponent("llvm_ubi"); |
| 470 | Filename.makeUnique(true,&ErrMsg); |
| 471 | |
| 472 | if (!ErrMsg.empty()) |
| 473 | return 0; |
| 474 | |
Chris Lattner | d57a7ef | 2009-08-23 22:45:33 +0000 | [diff] [blame] | 475 | llvm::errs() << "Writing '" << Filename.str() << "'.\n"; |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 476 | |
| 477 | llvm::OwningPtr<llvm::raw_fd_ostream> Stream; |
Chris Lattner | d57a7ef | 2009-08-23 22:45:33 +0000 | [diff] [blame] | 478 | Stream.reset(new llvm::raw_fd_ostream(Filename.c_str(), ErrMsg, |
Chris Lattner | 92bcc27 | 2009-08-23 02:59:41 +0000 | [diff] [blame] | 479 | llvm::raw_fd_ostream::F_Force)); |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 480 | |
| 481 | if (!ErrMsg.empty()) |
| 482 | return 0; |
| 483 | |
Ted Kremenek | 710ad93 | 2008-08-28 03:54:51 +0000 | [diff] [blame] | 484 | return new UbigraphViz(Stream.take(), Dir, Filename); |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 485 | } |
| 486 | |
Zhongxing Xu | c5619d9 | 2009-08-06 01:32:16 +0000 | [diff] [blame] | 487 | void UbigraphViz::AddEdge(ExplodedNode* Src, ExplodedNode* Dst) { |
Ted Kremenek | 45479c8 | 2008-08-28 18:34:41 +0000 | [diff] [blame] | 488 | |
| 489 | assert (Src != Dst && "Self-edges are not allowed."); |
| 490 | |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 491 | // Lookup the Src. If it is a new node, it's a root. |
| 492 | VMap::iterator SrcI= M.find(Src); |
| 493 | unsigned SrcID; |
| 494 | |
| 495 | if (SrcI == M.end()) { |
| 496 | M[Src] = SrcID = Cntr++; |
| 497 | *Out << "('vertex', " << SrcID << ", ('color','#00ff00'))\n"; |
| 498 | } |
| 499 | else |
| 500 | SrcID = SrcI->second; |
| 501 | |
| 502 | // Lookup the Dst. |
| 503 | VMap::iterator DstI= M.find(Dst); |
| 504 | unsigned DstID; |
| 505 | |
| 506 | if (DstI == M.end()) { |
| 507 | M[Dst] = DstID = Cntr++; |
| 508 | *Out << "('vertex', " << DstID << ")\n"; |
| 509 | } |
Ted Kremenek | 56b9871 | 2008-08-28 05:02:09 +0000 | [diff] [blame] | 510 | else { |
| 511 | // We have hit DstID before. Change its style to reflect a cache hit. |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 512 | DstID = DstI->second; |
Ted Kremenek | 56b9871 | 2008-08-28 05:02:09 +0000 | [diff] [blame] | 513 | *Out << "('change_vertex_style', " << DstID << ", 1)\n"; |
| 514 | } |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 515 | |
| 516 | // Add the edge. |
Ted Kremenek | d128932 | 2008-08-27 22:46:55 +0000 | [diff] [blame] | 517 | *Out << "('edge', " << SrcID << ", " << DstID |
| 518 | << ", ('arrow','true'), ('oriented', 'true'))\n"; |
Ted Kremenek | f8ce699 | 2008-08-27 22:31:43 +0000 | [diff] [blame] | 519 | } |
| 520 | |
Ted Kremenek | 56b9871 | 2008-08-28 05:02:09 +0000 | [diff] [blame] | 521 | UbigraphViz::UbigraphViz(llvm::raw_ostream* out, llvm::sys::Path& dir, |
| 522 | llvm::sys::Path& filename) |
| 523 | : Out(out), Dir(dir), Filename(filename), Cntr(0) { |
| 524 | |
| 525 | *Out << "('vertex_style_attribute', 0, ('shape', 'icosahedron'))\n"; |
| 526 | *Out << "('vertex_style', 1, 0, ('shape', 'sphere'), ('color', '#ffcc66')," |
| 527 | " ('size', '1.5'))\n"; |
| 528 | } |
| 529 | |
Ted Kremenek | 710ad93 | 2008-08-28 03:54:51 +0000 | [diff] [blame] | 530 | UbigraphViz::~UbigraphViz() { |
| 531 | Out.reset(0); |
Benjamin Kramer | 6cb7c1a | 2009-08-23 12:08:50 +0000 | [diff] [blame] | 532 | llvm::errs() << "Running 'ubiviz' program... "; |
Ted Kremenek | 710ad93 | 2008-08-28 03:54:51 +0000 | [diff] [blame] | 533 | std::string ErrMsg; |
| 534 | llvm::sys::Path Ubiviz = llvm::sys::Program::FindProgramByName("ubiviz"); |
| 535 | std::vector<const char*> args; |
| 536 | args.push_back(Ubiviz.c_str()); |
| 537 | args.push_back(Filename.c_str()); |
| 538 | args.push_back(0); |
| 539 | |
| 540 | if (llvm::sys::Program::ExecuteAndWait(Ubiviz, &args[0],0,0,0,0,&ErrMsg)) { |
Benjamin Kramer | 6cb7c1a | 2009-08-23 12:08:50 +0000 | [diff] [blame] | 541 | llvm::errs() << "Error viewing graph: " << ErrMsg << "\n"; |
Ted Kremenek | 710ad93 | 2008-08-28 03:54:51 +0000 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | // Delete the directory. |
| 545 | Dir.eraseFromDisk(true); |
Daniel Dunbar | 932680e | 2008-08-29 03:45:59 +0000 | [diff] [blame] | 546 | } |