Daniel Dunbar | 2a79e16 | 2009-11-13 03:51:44 +0000 | [diff] [blame] | 1 | //===--- CompilerInstance.cpp ---------------------------------------------===// |
| 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 | #include "clang/Frontend/CompilerInstance.h" |
Douglas Gregor | f18d0d8 | 2010-08-12 23:31:19 +0000 | [diff] [blame] | 11 | #include "clang/Sema/Sema.h" |
Daniel Dunbar | 12ce694 | 2009-11-14 02:47:17 +0000 | [diff] [blame] | 12 | #include "clang/AST/ASTConsumer.h" |
Daniel Dunbar | 5eb8100 | 2009-11-13 08:20:47 +0000 | [diff] [blame] | 13 | #include "clang/AST/ASTContext.h" |
Daniel Dunbar | 2a79e16 | 2009-11-13 03:51:44 +0000 | [diff] [blame] | 14 | #include "clang/Basic/Diagnostic.h" |
Daniel Dunbar | 16b7449 | 2009-11-13 04:12:06 +0000 | [diff] [blame] | 15 | #include "clang/Basic/FileManager.h" |
| 16 | #include "clang/Basic/SourceManager.h" |
Daniel Dunbar | 2a79e16 | 2009-11-13 03:51:44 +0000 | [diff] [blame] | 17 | #include "clang/Basic/TargetInfo.h" |
Daniel Dunbar | 0397af2 | 2010-01-13 00:48:06 +0000 | [diff] [blame] | 18 | #include "clang/Basic/Version.h" |
Daniel Dunbar | 22dacfa | 2009-11-13 05:52:11 +0000 | [diff] [blame] | 19 | #include "clang/Lex/HeaderSearch.h" |
| 20 | #include "clang/Lex/Preprocessor.h" |
| 21 | #include "clang/Lex/PTHManager.h" |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 22 | #include "clang/Frontend/ChainedDiagnosticClient.h" |
Daniel Dunbar | 0397af2 | 2010-01-13 00:48:06 +0000 | [diff] [blame] | 23 | #include "clang/Frontend/FrontendAction.h" |
Daniel Dunbar | c2f484f | 2009-11-13 09:36:05 +0000 | [diff] [blame] | 24 | #include "clang/Frontend/FrontendDiagnostic.h" |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 25 | #include "clang/Frontend/TextDiagnosticPrinter.h" |
Daniel Dunbar | f79dced | 2009-11-14 03:24:39 +0000 | [diff] [blame] | 26 | #include "clang/Frontend/VerifyDiagnosticsClient.h" |
Daniel Dunbar | 22dacfa | 2009-11-13 05:52:11 +0000 | [diff] [blame] | 27 | #include "clang/Frontend/Utils.h" |
Sebastian Redl | 6ab7cd8 | 2010-08-18 23:57:17 +0000 | [diff] [blame] | 28 | #include "clang/Serialization/ASTReader.h" |
Daniel Dunbar | c2f484f | 2009-11-13 09:36:05 +0000 | [diff] [blame] | 29 | #include "clang/Sema/CodeCompleteConsumer.h" |
Daniel Dunbar | 2a79e16 | 2009-11-13 03:51:44 +0000 | [diff] [blame] | 30 | #include "llvm/LLVMContext.h" |
Daniel Dunbar | ccb6cb6 | 2009-11-14 07:53:04 +0000 | [diff] [blame] | 31 | #include "llvm/Support/MemoryBuffer.h" |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 32 | #include "llvm/Support/raw_ostream.h" |
Douglas Gregor | 95dd558 | 2010-03-30 17:33:59 +0000 | [diff] [blame] | 33 | #include "llvm/ADT/Statistic.h" |
Kovarththanan Rajaratnam | f79bafa | 2009-11-29 09:57:35 +0000 | [diff] [blame] | 34 | #include "llvm/Support/Timer.h" |
Daniel Dunbar | 0397af2 | 2010-01-13 00:48:06 +0000 | [diff] [blame] | 35 | #include "llvm/System/Host.h" |
Daniel Dunbar | a920483 | 2009-11-13 10:37:48 +0000 | [diff] [blame] | 36 | #include "llvm/System/Path.h" |
Douglas Gregor | 2b4074f | 2009-12-01 05:55:20 +0000 | [diff] [blame] | 37 | #include "llvm/System/Program.h" |
Argyrios Kyrtzidis | dc24572 | 2010-09-17 17:38:48 +0000 | [diff] [blame] | 38 | #include "llvm/System/Signals.h" |
Daniel Dunbar | 2a79e16 | 2009-11-13 03:51:44 +0000 | [diff] [blame] | 39 | using namespace clang; |
| 40 | |
Daniel Dunbar | 42e9f8e4 | 2010-02-16 01:54:47 +0000 | [diff] [blame] | 41 | CompilerInstance::CompilerInstance() |
Sebastian Redl | ffaab3e | 2010-07-30 00:29:29 +0000 | [diff] [blame] | 42 | : Invocation(new CompilerInvocation()) { |
Daniel Dunbar | 6228ca0 | 2010-01-30 21:47:07 +0000 | [diff] [blame] | 43 | } |
Daniel Dunbar | 2a79e16 | 2009-11-13 03:51:44 +0000 | [diff] [blame] | 44 | |
| 45 | CompilerInstance::~CompilerInstance() { |
Daniel Dunbar | 42e9f8e4 | 2010-02-16 01:54:47 +0000 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | void CompilerInstance::setLLVMContext(llvm::LLVMContext *Value) { |
| 49 | LLVMContext.reset(Value); |
Daniel Dunbar | 2a79e16 | 2009-11-13 03:51:44 +0000 | [diff] [blame] | 50 | } |
Daniel Dunbar | 16b7449 | 2009-11-13 04:12:06 +0000 | [diff] [blame] | 51 | |
Daniel Dunbar | 6228ca0 | 2010-01-30 21:47:07 +0000 | [diff] [blame] | 52 | void CompilerInstance::setInvocation(CompilerInvocation *Value) { |
| 53 | Invocation.reset(Value); |
| 54 | } |
| 55 | |
Daniel Dunbar | 8a9f569 | 2009-11-14 01:20:40 +0000 | [diff] [blame] | 56 | void CompilerInstance::setDiagnostics(Diagnostic *Value) { |
Douglas Gregor | 2801977 | 2010-04-05 23:52:57 +0000 | [diff] [blame] | 57 | Diagnostics = Value; |
Daniel Dunbar | 8a9f569 | 2009-11-14 01:20:40 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Daniel Dunbar | 8a9f569 | 2009-11-14 01:20:40 +0000 | [diff] [blame] | 60 | void CompilerInstance::setTarget(TargetInfo *Value) { |
| 61 | Target.reset(Value); |
| 62 | } |
| 63 | |
| 64 | void CompilerInstance::setFileManager(FileManager *Value) { |
| 65 | FileMgr.reset(Value); |
| 66 | } |
| 67 | |
| 68 | void CompilerInstance::setSourceManager(SourceManager *Value) { |
| 69 | SourceMgr.reset(Value); |
| 70 | } |
| 71 | |
| 72 | void CompilerInstance::setPreprocessor(Preprocessor *Value) { |
| 73 | PP.reset(Value); |
| 74 | } |
| 75 | |
| 76 | void CompilerInstance::setASTContext(ASTContext *Value) { |
| 77 | Context.reset(Value); |
| 78 | } |
| 79 | |
Douglas Gregor | f18d0d8 | 2010-08-12 23:31:19 +0000 | [diff] [blame] | 80 | void CompilerInstance::setSema(Sema *S) { |
| 81 | TheSema.reset(S); |
| 82 | } |
| 83 | |
Daniel Dunbar | 12ce694 | 2009-11-14 02:47:17 +0000 | [diff] [blame] | 84 | void CompilerInstance::setASTConsumer(ASTConsumer *Value) { |
| 85 | Consumer.reset(Value); |
| 86 | } |
| 87 | |
Daniel Dunbar | 8a9f569 | 2009-11-14 01:20:40 +0000 | [diff] [blame] | 88 | void CompilerInstance::setCodeCompletionConsumer(CodeCompleteConsumer *Value) { |
| 89 | CompletionConsumer.reset(Value); |
| 90 | } |
| 91 | |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 92 | // Diagnostics |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 93 | static void SetUpBuildDumpLog(const DiagnosticOptions &DiagOpts, |
Axel Naumann | 7d0c4cc | 2010-10-11 09:13:46 +0000 | [diff] [blame] | 94 | unsigned argc, const char* const *argv, |
Kovarththanan Rajaratnam | 3d67b1e | 2010-03-17 09:24:48 +0000 | [diff] [blame] | 95 | Diagnostic &Diags) { |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 96 | std::string ErrorInfo; |
Kovarththanan Rajaratnam | 6924713 | 2010-03-17 09:47:30 +0000 | [diff] [blame] | 97 | llvm::OwningPtr<llvm::raw_ostream> OS( |
| 98 | new llvm::raw_fd_ostream(DiagOpts.DumpBuildInformation.c_str(), ErrorInfo)); |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 99 | if (!ErrorInfo.empty()) { |
Kovarththanan Rajaratnam | 3d67b1e | 2010-03-17 09:24:48 +0000 | [diff] [blame] | 100 | Diags.Report(diag::err_fe_unable_to_open_logfile) |
| 101 | << DiagOpts.DumpBuildInformation << ErrorInfo; |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 102 | return; |
| 103 | } |
| 104 | |
Daniel Dunbar | dd63b28 | 2009-12-11 23:04:35 +0000 | [diff] [blame] | 105 | (*OS) << "clang -cc1 command line arguments: "; |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 106 | for (unsigned i = 0; i != argc; ++i) |
| 107 | (*OS) << argv[i] << ' '; |
| 108 | (*OS) << '\n'; |
| 109 | |
| 110 | // Chain in a diagnostic client which will log the diagnostics. |
| 111 | DiagnosticClient *Logger = |
Kovarththanan Rajaratnam | 6924713 | 2010-03-17 09:47:30 +0000 | [diff] [blame] | 112 | new TextDiagnosticPrinter(*OS.take(), DiagOpts, /*OwnsOutputStream=*/true); |
Douglas Gregor | bdbb004 | 2010-08-18 22:29:43 +0000 | [diff] [blame] | 113 | Diags.setClient(new ChainedDiagnosticClient(Diags.takeClient(), Logger)); |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 114 | } |
| 115 | |
Axel Naumann | 7d0c4cc | 2010-10-11 09:13:46 +0000 | [diff] [blame] | 116 | void CompilerInstance::createDiagnostics(int Argc, const char* const *Argv) { |
Douglas Gregor | 2801977 | 2010-04-05 23:52:57 +0000 | [diff] [blame] | 117 | Diagnostics = createDiagnostics(getDiagnosticOpts(), Argc, Argv); |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 118 | } |
| 119 | |
Douglas Gregor | 2801977 | 2010-04-05 23:52:57 +0000 | [diff] [blame] | 120 | llvm::IntrusiveRefCntPtr<Diagnostic> |
| 121 | CompilerInstance::createDiagnostics(const DiagnosticOptions &Opts, |
Axel Naumann | 7d0c4cc | 2010-10-11 09:13:46 +0000 | [diff] [blame] | 122 | int Argc, const char* const *Argv) { |
Douglas Gregor | 2801977 | 2010-04-05 23:52:57 +0000 | [diff] [blame] | 123 | llvm::IntrusiveRefCntPtr<Diagnostic> Diags(new Diagnostic()); |
Daniel Dunbar | 221c721 | 2009-11-14 07:53:24 +0000 | [diff] [blame] | 124 | |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 125 | // Create the diagnostic client for reporting errors or for |
| 126 | // implementing -verify. |
Douglas Gregor | d93256e | 2010-01-28 06:00:51 +0000 | [diff] [blame] | 127 | llvm::OwningPtr<DiagnosticClient> DiagClient; |
Douglas Gregor | d3ab63e | 2010-10-11 22:02:06 +0000 | [diff] [blame] | 128 | Diags->setClient(new TextDiagnosticPrinter(llvm::errs(), Opts)); |
Daniel Dunbar | f79dced | 2009-11-14 03:24:39 +0000 | [diff] [blame] | 129 | |
| 130 | // Chain in -verify checker, if requested. |
| 131 | if (Opts.VerifyDiagnostics) |
Douglas Gregor | bdbb004 | 2010-08-18 22:29:43 +0000 | [diff] [blame] | 132 | Diags->setClient(new VerifyDiagnosticsClient(*Diags, Diags->takeClient())); |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 133 | |
| 134 | if (!Opts.DumpBuildInformation.empty()) |
Kovarththanan Rajaratnam | 3d67b1e | 2010-03-17 09:24:48 +0000 | [diff] [blame] | 135 | SetUpBuildDumpLog(Opts, Argc, Argv, *Diags); |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 136 | |
| 137 | // Configure our handling of diagnostics. |
Kovarththanan Rajaratnam | 5bf932b | 2010-03-17 09:36:02 +0000 | [diff] [blame] | 138 | ProcessWarningOptions(*Diags, Opts); |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 139 | |
Douglas Gregor | 2801977 | 2010-04-05 23:52:57 +0000 | [diff] [blame] | 140 | return Diags; |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | // File Manager |
| 144 | |
Daniel Dunbar | 16b7449 | 2009-11-13 04:12:06 +0000 | [diff] [blame] | 145 | void CompilerInstance::createFileManager() { |
| 146 | FileMgr.reset(new FileManager()); |
| 147 | } |
| 148 | |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 149 | // Source Manager |
| 150 | |
Daniel Dunbar | 16b7449 | 2009-11-13 04:12:06 +0000 | [diff] [blame] | 151 | void CompilerInstance::createSourceManager() { |
Douglas Gregor | f715ca1 | 2010-03-16 00:06:06 +0000 | [diff] [blame] | 152 | SourceMgr.reset(new SourceManager(getDiagnostics())); |
Daniel Dunbar | 16b7449 | 2009-11-13 04:12:06 +0000 | [diff] [blame] | 153 | } |
Daniel Dunbar | 22dacfa | 2009-11-13 05:52:11 +0000 | [diff] [blame] | 154 | |
Daniel Dunbar | 0fbb3d9 | 2009-11-13 05:52:34 +0000 | [diff] [blame] | 155 | // Preprocessor |
| 156 | |
Daniel Dunbar | 22dacfa | 2009-11-13 05:52:11 +0000 | [diff] [blame] | 157 | void CompilerInstance::createPreprocessor() { |
| 158 | PP.reset(createPreprocessor(getDiagnostics(), getLangOpts(), |
| 159 | getPreprocessorOpts(), getHeaderSearchOpts(), |
| 160 | getDependencyOutputOpts(), getTarget(), |
Fariborz Jahanian | 7d95747 | 2010-01-13 18:51:17 +0000 | [diff] [blame] | 161 | getFrontendOpts(), getSourceManager(), |
| 162 | getFileManager())); |
Daniel Dunbar | 22dacfa | 2009-11-13 05:52:11 +0000 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | Preprocessor * |
| 166 | CompilerInstance::createPreprocessor(Diagnostic &Diags, |
| 167 | const LangOptions &LangInfo, |
| 168 | const PreprocessorOptions &PPOpts, |
| 169 | const HeaderSearchOptions &HSOpts, |
| 170 | const DependencyOutputOptions &DepOpts, |
| 171 | const TargetInfo &Target, |
Fariborz Jahanian | 7d95747 | 2010-01-13 18:51:17 +0000 | [diff] [blame] | 172 | const FrontendOptions &FEOpts, |
Daniel Dunbar | 22dacfa | 2009-11-13 05:52:11 +0000 | [diff] [blame] | 173 | SourceManager &SourceMgr, |
| 174 | FileManager &FileMgr) { |
| 175 | // Create a PTH manager if we are using some form of a token cache. |
| 176 | PTHManager *PTHMgr = 0; |
Daniel Dunbar | 049d3a0 | 2009-11-17 05:52:41 +0000 | [diff] [blame] | 177 | if (!PPOpts.TokenCache.empty()) |
| 178 | PTHMgr = PTHManager::Create(PPOpts.TokenCache, Diags); |
Daniel Dunbar | 22dacfa | 2009-11-13 05:52:11 +0000 | [diff] [blame] | 179 | |
Daniel Dunbar | 22dacfa | 2009-11-13 05:52:11 +0000 | [diff] [blame] | 180 | // Create the Preprocessor. |
| 181 | HeaderSearch *HeaderInfo = new HeaderSearch(FileMgr); |
| 182 | Preprocessor *PP = new Preprocessor(Diags, LangInfo, Target, |
| 183 | SourceMgr, *HeaderInfo, PTHMgr, |
| 184 | /*OwnsHeaderSearch=*/true); |
| 185 | |
| 186 | // Note that this is different then passing PTHMgr to Preprocessor's ctor. |
| 187 | // That argument is used as the IdentifierInfoLookup argument to |
| 188 | // IdentifierTable's ctor. |
| 189 | if (PTHMgr) { |
| 190 | PTHMgr->setPreprocessor(PP); |
| 191 | PP->setPTHManager(PTHMgr); |
| 192 | } |
| 193 | |
Douglas Gregor | 94dc8f6 | 2010-03-19 16:15:56 +0000 | [diff] [blame] | 194 | if (PPOpts.DetailedRecord) |
| 195 | PP->createPreprocessingRecord(); |
| 196 | |
Fariborz Jahanian | 7d95747 | 2010-01-13 18:51:17 +0000 | [diff] [blame] | 197 | InitializePreprocessor(*PP, PPOpts, HSOpts, FEOpts); |
Daniel Dunbar | 22dacfa | 2009-11-13 05:52:11 +0000 | [diff] [blame] | 198 | |
| 199 | // Handle generating dependencies, if requested. |
| 200 | if (!DepOpts.OutputFile.empty()) |
| 201 | AttachDependencyFileGen(*PP, DepOpts); |
| 202 | |
| 203 | return PP; |
| 204 | } |
Daniel Dunbar | 5eb8100 | 2009-11-13 08:20:47 +0000 | [diff] [blame] | 205 | |
| 206 | // ASTContext |
| 207 | |
| 208 | void CompilerInstance::createASTContext() { |
| 209 | Preprocessor &PP = getPreprocessor(); |
| 210 | Context.reset(new ASTContext(getLangOpts(), PP.getSourceManager(), |
| 211 | getTarget(), PP.getIdentifierTable(), |
| 212 | PP.getSelectorTable(), PP.getBuiltinInfo(), |
Daniel Dunbar | 5eb8100 | 2009-11-13 08:20:47 +0000 | [diff] [blame] | 213 | /*size_reserve=*/ 0)); |
| 214 | } |
Daniel Dunbar | 0f80039 | 2009-11-13 08:21:10 +0000 | [diff] [blame] | 215 | |
| 216 | // ExternalASTSource |
| 217 | |
Douglas Gregor | fae3b2f | 2010-07-27 00:27:13 +0000 | [diff] [blame] | 218 | void CompilerInstance::createPCHExternalASTSource(llvm::StringRef Path, |
Sebastian Redl | ffaab3e | 2010-07-30 00:29:29 +0000 | [diff] [blame] | 219 | bool DisablePCHValidation, |
| 220 | void *DeserializationListener){ |
Daniel Dunbar | 0f80039 | 2009-11-13 08:21:10 +0000 | [diff] [blame] | 221 | llvm::OwningPtr<ExternalASTSource> Source; |
Sebastian Redl | 1d9f1fe | 2010-10-05 16:15:19 +0000 | [diff] [blame] | 222 | bool Preamble = getPreprocessorOpts().PrecompiledPreambleBytes.first != 0; |
Daniel Dunbar | 0f80039 | 2009-11-13 08:21:10 +0000 | [diff] [blame] | 223 | Source.reset(createPCHExternalASTSource(Path, getHeaderSearchOpts().Sysroot, |
Douglas Gregor | fae3b2f | 2010-07-27 00:27:13 +0000 | [diff] [blame] | 224 | DisablePCHValidation, |
Sebastian Redl | ffaab3e | 2010-07-30 00:29:29 +0000 | [diff] [blame] | 225 | getPreprocessor(), getASTContext(), |
Sebastian Redl | 1d9f1fe | 2010-10-05 16:15:19 +0000 | [diff] [blame] | 226 | DeserializationListener, |
| 227 | Preamble)); |
Daniel Dunbar | 0f80039 | 2009-11-13 08:21:10 +0000 | [diff] [blame] | 228 | getASTContext().setExternalSource(Source); |
| 229 | } |
| 230 | |
| 231 | ExternalASTSource * |
| 232 | CompilerInstance::createPCHExternalASTSource(llvm::StringRef Path, |
| 233 | const std::string &Sysroot, |
Douglas Gregor | fae3b2f | 2010-07-27 00:27:13 +0000 | [diff] [blame] | 234 | bool DisablePCHValidation, |
Daniel Dunbar | 0f80039 | 2009-11-13 08:21:10 +0000 | [diff] [blame] | 235 | Preprocessor &PP, |
Sebastian Redl | ffaab3e | 2010-07-30 00:29:29 +0000 | [diff] [blame] | 236 | ASTContext &Context, |
Sebastian Redl | 1d9f1fe | 2010-10-05 16:15:19 +0000 | [diff] [blame] | 237 | void *DeserializationListener, |
| 238 | bool Preamble) { |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 239 | llvm::OwningPtr<ASTReader> Reader; |
| 240 | Reader.reset(new ASTReader(PP, &Context, |
Douglas Gregor | fae3b2f | 2010-07-27 00:27:13 +0000 | [diff] [blame] | 241 | Sysroot.empty() ? 0 : Sysroot.c_str(), |
| 242 | DisablePCHValidation)); |
Daniel Dunbar | 0f80039 | 2009-11-13 08:21:10 +0000 | [diff] [blame] | 243 | |
Sebastian Redl | ffaab3e | 2010-07-30 00:29:29 +0000 | [diff] [blame] | 244 | Reader->setDeserializationListener( |
Sebastian Redl | 571db7f | 2010-08-18 23:56:56 +0000 | [diff] [blame] | 245 | static_cast<ASTDeserializationListener *>(DeserializationListener)); |
Sebastian Redl | 1d9f1fe | 2010-10-05 16:15:19 +0000 | [diff] [blame] | 246 | switch (Reader->ReadAST(Path, |
| 247 | Preamble ? ASTReader::Preamble : ASTReader::PCH)) { |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 248 | case ASTReader::Success: |
Daniel Dunbar | 0f80039 | 2009-11-13 08:21:10 +0000 | [diff] [blame] | 249 | // Set the predefines buffer as suggested by the PCH reader. Typically, the |
| 250 | // predefines buffer will be empty. |
| 251 | PP.setPredefines(Reader->getSuggestedPredefines()); |
| 252 | return Reader.take(); |
| 253 | |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 254 | case ASTReader::Failure: |
Daniel Dunbar | 0f80039 | 2009-11-13 08:21:10 +0000 | [diff] [blame] | 255 | // Unrecoverable failure: don't even try to process the input file. |
| 256 | break; |
| 257 | |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 258 | case ASTReader::IgnorePCH: |
Daniel Dunbar | 0f80039 | 2009-11-13 08:21:10 +0000 | [diff] [blame] | 259 | // No suitable PCH file could be found. Return an error. |
| 260 | break; |
| 261 | } |
| 262 | |
| 263 | return 0; |
| 264 | } |
Daniel Dunbar | c2f484f | 2009-11-13 09:36:05 +0000 | [diff] [blame] | 265 | |
| 266 | // Code Completion |
| 267 | |
Douglas Gregor | 1abc6bc | 2010-08-04 16:47:14 +0000 | [diff] [blame] | 268 | static bool EnableCodeCompletion(Preprocessor &PP, |
| 269 | const std::string &Filename, |
| 270 | unsigned Line, |
| 271 | unsigned Column) { |
| 272 | // Tell the source manager to chop off the given file at a specific |
| 273 | // line and column. |
| 274 | const FileEntry *Entry = PP.getFileManager().getFile(Filename); |
| 275 | if (!Entry) { |
| 276 | PP.getDiagnostics().Report(diag::err_fe_invalid_code_complete_file) |
| 277 | << Filename; |
| 278 | return true; |
| 279 | } |
| 280 | |
| 281 | // Truncate the named file at the given line/column. |
| 282 | PP.SetCodeCompletionPoint(Entry, Line, Column); |
| 283 | return false; |
| 284 | } |
| 285 | |
Daniel Dunbar | c2f484f | 2009-11-13 09:36:05 +0000 | [diff] [blame] | 286 | void CompilerInstance::createCodeCompletionConsumer() { |
| 287 | const ParsedSourceLocation &Loc = getFrontendOpts().CodeCompletionAt; |
Douglas Gregor | 1abc6bc | 2010-08-04 16:47:14 +0000 | [diff] [blame] | 288 | if (!CompletionConsumer) { |
| 289 | CompletionConsumer.reset( |
| 290 | createCodeCompletionConsumer(getPreprocessor(), |
| 291 | Loc.FileName, Loc.Line, Loc.Column, |
Douglas Gregor | 1abc6bc | 2010-08-04 16:47:14 +0000 | [diff] [blame] | 292 | getFrontendOpts().ShowMacrosInCodeCompletion, |
Douglas Gregor | d8e8a58 | 2010-05-25 21:41:55 +0000 | [diff] [blame] | 293 | getFrontendOpts().ShowCodePatternsInCodeCompletion, |
Douglas Gregor | 8071e42 | 2010-08-15 06:18:01 +0000 | [diff] [blame] | 294 | getFrontendOpts().ShowGlobalSymbolsInCodeCompletion, |
Douglas Gregor | 1abc6bc | 2010-08-04 16:47:14 +0000 | [diff] [blame] | 295 | llvm::outs())); |
| 296 | if (!CompletionConsumer) |
| 297 | return; |
| 298 | } else if (EnableCodeCompletion(getPreprocessor(), Loc.FileName, |
| 299 | Loc.Line, Loc.Column)) { |
| 300 | CompletionConsumer.reset(); |
Douglas Gregor | c3d43b7 | 2010-03-16 06:04:47 +0000 | [diff] [blame] | 301 | return; |
Douglas Gregor | 1abc6bc | 2010-08-04 16:47:14 +0000 | [diff] [blame] | 302 | } |
Douglas Gregor | 2b4074f | 2009-12-01 05:55:20 +0000 | [diff] [blame] | 303 | |
| 304 | if (CompletionConsumer->isOutputBinary() && |
| 305 | llvm::sys::Program::ChangeStdoutToBinary()) { |
| 306 | getPreprocessor().getDiagnostics().Report(diag::err_fe_stdout_binary); |
| 307 | CompletionConsumer.reset(); |
| 308 | } |
Daniel Dunbar | c2f484f | 2009-11-13 09:36:05 +0000 | [diff] [blame] | 309 | } |
| 310 | |
Kovarththanan Rajaratnam | f79bafa | 2009-11-29 09:57:35 +0000 | [diff] [blame] | 311 | void CompilerInstance::createFrontendTimer() { |
| 312 | FrontendTimer.reset(new llvm::Timer("Clang front-end timer")); |
| 313 | } |
| 314 | |
Daniel Dunbar | c2f484f | 2009-11-13 09:36:05 +0000 | [diff] [blame] | 315 | CodeCompleteConsumer * |
| 316 | CompilerInstance::createCodeCompletionConsumer(Preprocessor &PP, |
| 317 | const std::string &Filename, |
| 318 | unsigned Line, |
| 319 | unsigned Column, |
Daniel Dunbar | c2f484f | 2009-11-13 09:36:05 +0000 | [diff] [blame] | 320 | bool ShowMacros, |
Douglas Gregor | d8e8a58 | 2010-05-25 21:41:55 +0000 | [diff] [blame] | 321 | bool ShowCodePatterns, |
Douglas Gregor | 8071e42 | 2010-08-15 06:18:01 +0000 | [diff] [blame] | 322 | bool ShowGlobals, |
Daniel Dunbar | c2f484f | 2009-11-13 09:36:05 +0000 | [diff] [blame] | 323 | llvm::raw_ostream &OS) { |
Douglas Gregor | 1abc6bc | 2010-08-04 16:47:14 +0000 | [diff] [blame] | 324 | if (EnableCodeCompletion(PP, Filename, Line, Column)) |
Daniel Dunbar | c2f484f | 2009-11-13 09:36:05 +0000 | [diff] [blame] | 325 | return 0; |
Daniel Dunbar | c2f484f | 2009-11-13 09:36:05 +0000 | [diff] [blame] | 326 | |
| 327 | // Set up the creation routine for code-completion. |
Douglas Gregor | a9f4f62 | 2010-10-11 22:12:15 +0000 | [diff] [blame] | 328 | return new PrintingCodeCompleteConsumer(ShowMacros, ShowCodePatterns, |
Douglas Gregor | 8071e42 | 2010-08-15 06:18:01 +0000 | [diff] [blame] | 329 | ShowGlobals, OS); |
Daniel Dunbar | c2f484f | 2009-11-13 09:36:05 +0000 | [diff] [blame] | 330 | } |
Daniel Dunbar | a920483 | 2009-11-13 10:37:48 +0000 | [diff] [blame] | 331 | |
Douglas Gregor | f18d0d8 | 2010-08-12 23:31:19 +0000 | [diff] [blame] | 332 | void CompilerInstance::createSema(bool CompleteTranslationUnit, |
| 333 | CodeCompleteConsumer *CompletionConsumer) { |
| 334 | TheSema.reset(new Sema(getPreprocessor(), getASTContext(), getASTConsumer(), |
| 335 | CompleteTranslationUnit, CompletionConsumer)); |
| 336 | } |
| 337 | |
Daniel Dunbar | a920483 | 2009-11-13 10:37:48 +0000 | [diff] [blame] | 338 | // Output Files |
| 339 | |
Argyrios Kyrtzidis | dc24572 | 2010-09-17 17:38:48 +0000 | [diff] [blame] | 340 | void CompilerInstance::addOutputFile(const OutputFile &OutFile) { |
| 341 | assert(OutFile.OS && "Attempt to add empty stream to output list!"); |
| 342 | OutputFiles.push_back(OutFile); |
Daniel Dunbar | a920483 | 2009-11-13 10:37:48 +0000 | [diff] [blame] | 343 | } |
| 344 | |
Kovarththanan Rajaratnam | e51dd7b | 2010-03-06 12:07:48 +0000 | [diff] [blame] | 345 | void CompilerInstance::clearOutputFiles(bool EraseFiles) { |
Argyrios Kyrtzidis | dc24572 | 2010-09-17 17:38:48 +0000 | [diff] [blame] | 346 | for (std::list<OutputFile>::iterator |
Daniel Dunbar | a920483 | 2009-11-13 10:37:48 +0000 | [diff] [blame] | 347 | it = OutputFiles.begin(), ie = OutputFiles.end(); it != ie; ++it) { |
Argyrios Kyrtzidis | dc24572 | 2010-09-17 17:38:48 +0000 | [diff] [blame] | 348 | delete it->OS; |
| 349 | if (!it->TempFilename.empty()) { |
| 350 | llvm::sys::Path TempPath(it->TempFilename); |
| 351 | if (EraseFiles) |
| 352 | TempPath.eraseFromDisk(); |
| 353 | else { |
| 354 | std::string Error; |
| 355 | if (TempPath.renamePathOnDisk(llvm::sys::Path(it->Filename), &Error)) { |
| 356 | getDiagnostics().Report(diag::err_fe_unable_to_rename_temp) |
| 357 | << it->TempFilename << it->Filename << Error; |
| 358 | TempPath.eraseFromDisk(); |
| 359 | } |
| 360 | } |
| 361 | } else if (!it->Filename.empty() && EraseFiles) |
| 362 | llvm::sys::Path(it->Filename).eraseFromDisk(); |
| 363 | |
Daniel Dunbar | a920483 | 2009-11-13 10:37:48 +0000 | [diff] [blame] | 364 | } |
| 365 | OutputFiles.clear(); |
| 366 | } |
| 367 | |
Daniel Dunbar | f482d59 | 2009-11-13 18:32:08 +0000 | [diff] [blame] | 368 | llvm::raw_fd_ostream * |
| 369 | CompilerInstance::createDefaultOutputFile(bool Binary, |
| 370 | llvm::StringRef InFile, |
| 371 | llvm::StringRef Extension) { |
| 372 | return createOutputFile(getFrontendOpts().OutputFile, Binary, |
| 373 | InFile, Extension); |
| 374 | } |
| 375 | |
| 376 | llvm::raw_fd_ostream * |
| 377 | CompilerInstance::createOutputFile(llvm::StringRef OutputPath, |
| 378 | bool Binary, |
| 379 | llvm::StringRef InFile, |
| 380 | llvm::StringRef Extension) { |
Argyrios Kyrtzidis | dc24572 | 2010-09-17 17:38:48 +0000 | [diff] [blame] | 381 | std::string Error, OutputPathName, TempPathName; |
Daniel Dunbar | f482d59 | 2009-11-13 18:32:08 +0000 | [diff] [blame] | 382 | llvm::raw_fd_ostream *OS = createOutputFile(OutputPath, Error, Binary, |
| 383 | InFile, Extension, |
Argyrios Kyrtzidis | dc24572 | 2010-09-17 17:38:48 +0000 | [diff] [blame] | 384 | &OutputPathName, |
| 385 | &TempPathName); |
Daniel Dunbar | f482d59 | 2009-11-13 18:32:08 +0000 | [diff] [blame] | 386 | if (!OS) { |
Daniel Dunbar | 3604359 | 2009-12-03 09:13:30 +0000 | [diff] [blame] | 387 | getDiagnostics().Report(diag::err_fe_unable_to_open_output) |
| 388 | << OutputPath << Error; |
| 389 | return 0; |
Daniel Dunbar | f482d59 | 2009-11-13 18:32:08 +0000 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | // Add the output file -- but don't try to remove "-", since this means we are |
| 393 | // using stdin. |
Argyrios Kyrtzidis | dc24572 | 2010-09-17 17:38:48 +0000 | [diff] [blame] | 394 | addOutputFile(OutputFile((OutputPathName != "-") ? OutputPathName : "", |
| 395 | TempPathName, OS)); |
Daniel Dunbar | f482d59 | 2009-11-13 18:32:08 +0000 | [diff] [blame] | 396 | |
| 397 | return OS; |
| 398 | } |
| 399 | |
| 400 | llvm::raw_fd_ostream * |
| 401 | CompilerInstance::createOutputFile(llvm::StringRef OutputPath, |
| 402 | std::string &Error, |
| 403 | bool Binary, |
| 404 | llvm::StringRef InFile, |
| 405 | llvm::StringRef Extension, |
Argyrios Kyrtzidis | dc24572 | 2010-09-17 17:38:48 +0000 | [diff] [blame] | 406 | std::string *ResultPathName, |
| 407 | std::string *TempPathName) { |
| 408 | std::string OutFile, TempFile; |
Daniel Dunbar | f482d59 | 2009-11-13 18:32:08 +0000 | [diff] [blame] | 409 | if (!OutputPath.empty()) { |
| 410 | OutFile = OutputPath; |
| 411 | } else if (InFile == "-") { |
| 412 | OutFile = "-"; |
| 413 | } else if (!Extension.empty()) { |
| 414 | llvm::sys::Path Path(InFile); |
| 415 | Path.eraseSuffix(); |
| 416 | Path.appendSuffix(Extension); |
| 417 | OutFile = Path.str(); |
| 418 | } else { |
| 419 | OutFile = "-"; |
| 420 | } |
Argyrios Kyrtzidis | dc24572 | 2010-09-17 17:38:48 +0000 | [diff] [blame] | 421 | |
| 422 | if (OutFile != "-") { |
| 423 | llvm::sys::Path OutPath(OutFile); |
| 424 | // Only create the temporary if we can actually write to OutPath, otherwise |
| 425 | // we want to fail early. |
| 426 | if (!OutPath.exists() || |
| 427 | (OutPath.isRegularFile() && OutPath.canWrite())) { |
| 428 | // Create a temporary file. |
| 429 | llvm::sys::Path TempPath(OutFile); |
| 430 | if (!TempPath.createTemporaryFileOnDisk()) |
| 431 | TempFile = TempPath.str(); |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | std::string OSFile = OutFile; |
| 436 | if (!TempFile.empty()) |
| 437 | OSFile = TempFile; |
Daniel Dunbar | f482d59 | 2009-11-13 18:32:08 +0000 | [diff] [blame] | 438 | |
Daniel Dunbar | fc97102 | 2009-11-20 22:32:38 +0000 | [diff] [blame] | 439 | llvm::OwningPtr<llvm::raw_fd_ostream> OS( |
Argyrios Kyrtzidis | dc24572 | 2010-09-17 17:38:48 +0000 | [diff] [blame] | 440 | new llvm::raw_fd_ostream(OSFile.c_str(), Error, |
Daniel Dunbar | fc97102 | 2009-11-20 22:32:38 +0000 | [diff] [blame] | 441 | (Binary ? llvm::raw_fd_ostream::F_Binary : 0))); |
| 442 | if (!Error.empty()) |
Daniel Dunbar | f482d59 | 2009-11-13 18:32:08 +0000 | [diff] [blame] | 443 | return 0; |
| 444 | |
Argyrios Kyrtzidis | dc24572 | 2010-09-17 17:38:48 +0000 | [diff] [blame] | 445 | // Make sure the out stream file gets removed if we crash. |
| 446 | llvm::sys::RemoveFileOnSignal(llvm::sys::Path(OSFile)); |
| 447 | |
Daniel Dunbar | f482d59 | 2009-11-13 18:32:08 +0000 | [diff] [blame] | 448 | if (ResultPathName) |
| 449 | *ResultPathName = OutFile; |
Argyrios Kyrtzidis | dc24572 | 2010-09-17 17:38:48 +0000 | [diff] [blame] | 450 | if (TempPathName) |
| 451 | *TempPathName = TempFile; |
Daniel Dunbar | f482d59 | 2009-11-13 18:32:08 +0000 | [diff] [blame] | 452 | |
Daniel Dunbar | fc97102 | 2009-11-20 22:32:38 +0000 | [diff] [blame] | 453 | return OS.take(); |
Daniel Dunbar | f482d59 | 2009-11-13 18:32:08 +0000 | [diff] [blame] | 454 | } |
Daniel Dunbar | ccb6cb6 | 2009-11-14 07:53:04 +0000 | [diff] [blame] | 455 | |
| 456 | // Initialization Utilities |
| 457 | |
| 458 | bool CompilerInstance::InitializeSourceManager(llvm::StringRef InputFile) { |
| 459 | return InitializeSourceManager(InputFile, getDiagnostics(), getFileManager(), |
| 460 | getSourceManager(), getFrontendOpts()); |
| 461 | } |
| 462 | |
| 463 | bool CompilerInstance::InitializeSourceManager(llvm::StringRef InputFile, |
| 464 | Diagnostic &Diags, |
| 465 | FileManager &FileMgr, |
| 466 | SourceManager &SourceMgr, |
| 467 | const FrontendOptions &Opts) { |
| 468 | // Figure out where to get and map in the main file. |
Daniel Dunbar | 2758595 | 2010-03-19 19:44:04 +0000 | [diff] [blame] | 469 | if (InputFile != "-") { |
Daniel Dunbar | ccb6cb6 | 2009-11-14 07:53:04 +0000 | [diff] [blame] | 470 | const FileEntry *File = FileMgr.getFile(InputFile); |
Dan Gohman | 694137c | 2010-10-26 21:13:51 +0000 | [diff] [blame] | 471 | if (!File) { |
Daniel Dunbar | ccb6cb6 | 2009-11-14 07:53:04 +0000 | [diff] [blame] | 472 | Diags.Report(diag::err_fe_error_reading) << InputFile; |
| 473 | return false; |
| 474 | } |
Dan Gohman | 694137c | 2010-10-26 21:13:51 +0000 | [diff] [blame] | 475 | SourceMgr.createMainFileID(File); |
Daniel Dunbar | ccb6cb6 | 2009-11-14 07:53:04 +0000 | [diff] [blame] | 476 | } else { |
| 477 | llvm::MemoryBuffer *SB = llvm::MemoryBuffer::getSTDIN(); |
Dan Gohman | 694137c | 2010-10-26 21:13:51 +0000 | [diff] [blame] | 478 | if (!SB) { |
Daniel Dunbar | ccb6cb6 | 2009-11-14 07:53:04 +0000 | [diff] [blame] | 479 | Diags.Report(diag::err_fe_error_reading_stdin); |
| 480 | return false; |
| 481 | } |
Dan Gohman | 90d9081 | 2010-10-26 23:21:25 +0000 | [diff] [blame] | 482 | const FileEntry *File = FileMgr.getVirtualFile(SB->getBufferIdentifier(), |
| 483 | SB->getBufferSize(), 0); |
| 484 | SourceMgr.createMainFileID(File); |
| 485 | SourceMgr.overrideFileContents(File, SB); |
Daniel Dunbar | ccb6cb6 | 2009-11-14 07:53:04 +0000 | [diff] [blame] | 486 | } |
| 487 | |
Dan Gohman | 694137c | 2010-10-26 21:13:51 +0000 | [diff] [blame] | 488 | assert(!SourceMgr.getMainFileID().isInvalid() && |
| 489 | "Couldn't establish MainFileID!"); |
Daniel Dunbar | ccb6cb6 | 2009-11-14 07:53:04 +0000 | [diff] [blame] | 490 | return true; |
| 491 | } |
Daniel Dunbar | 0397af2 | 2010-01-13 00:48:06 +0000 | [diff] [blame] | 492 | |
| 493 | // High-Level Operations |
| 494 | |
| 495 | bool CompilerInstance::ExecuteAction(FrontendAction &Act) { |
| 496 | assert(hasDiagnostics() && "Diagnostics engine is not initialized!"); |
| 497 | assert(!getFrontendOpts().ShowHelp && "Client must handle '-help'!"); |
| 498 | assert(!getFrontendOpts().ShowVersion && "Client must handle '-version'!"); |
| 499 | |
| 500 | // FIXME: Take this as an argument, once all the APIs we used have moved to |
| 501 | // taking it as an input instead of hard-coding llvm::errs. |
| 502 | llvm::raw_ostream &OS = llvm::errs(); |
| 503 | |
| 504 | // Create the target instance. |
| 505 | setTarget(TargetInfo::CreateTargetInfo(getDiagnostics(), getTargetOpts())); |
| 506 | if (!hasTarget()) |
| 507 | return false; |
| 508 | |
| 509 | // Inform the target of the language options. |
| 510 | // |
| 511 | // FIXME: We shouldn't need to do this, the target should be immutable once |
| 512 | // created. This complexity should be lifted elsewhere. |
| 513 | getTarget().setForcedLangOptions(getLangOpts()); |
| 514 | |
| 515 | // Validate/process some options. |
| 516 | if (getHeaderSearchOpts().Verbose) |
| 517 | OS << "clang -cc1 version " CLANG_VERSION_STRING |
| 518 | << " based upon " << PACKAGE_STRING |
| 519 | << " hosted on " << llvm::sys::getHostTriple() << "\n"; |
| 520 | |
| 521 | if (getFrontendOpts().ShowTimers) |
| 522 | createFrontendTimer(); |
| 523 | |
Douglas Gregor | 95dd558 | 2010-03-30 17:33:59 +0000 | [diff] [blame] | 524 | if (getFrontendOpts().ShowStats) |
| 525 | llvm::EnableStatistics(); |
| 526 | |
Daniel Dunbar | 0397af2 | 2010-01-13 00:48:06 +0000 | [diff] [blame] | 527 | for (unsigned i = 0, e = getFrontendOpts().Inputs.size(); i != e; ++i) { |
| 528 | const std::string &InFile = getFrontendOpts().Inputs[i].second; |
| 529 | |
Daniel Dunbar | 2056048 | 2010-06-07 23:23:50 +0000 | [diff] [blame] | 530 | // Reset the ID tables if we are reusing the SourceManager. |
| 531 | if (hasSourceManager()) |
| 532 | getSourceManager().clearIDTables(); |
Daniel Dunbar | 0397af2 | 2010-01-13 00:48:06 +0000 | [diff] [blame] | 533 | |
Daniel Dunbar | d3598a6 | 2010-06-07 23:23:06 +0000 | [diff] [blame] | 534 | if (Act.BeginSourceFile(*this, InFile, getFrontendOpts().Inputs[i].first)) { |
Daniel Dunbar | 0397af2 | 2010-01-13 00:48:06 +0000 | [diff] [blame] | 535 | Act.Execute(); |
| 536 | Act.EndSourceFile(); |
| 537 | } |
| 538 | } |
| 539 | |
Chris Lattner | 53eee7b | 2010-04-07 18:47:42 +0000 | [diff] [blame] | 540 | if (getDiagnosticOpts().ShowCarets) { |
| 541 | unsigned NumWarnings = getDiagnostics().getNumWarnings(); |
Douglas Gregor | 1864f2e | 2010-04-14 22:19:45 +0000 | [diff] [blame] | 542 | unsigned NumErrors = getDiagnostics().getNumErrors() - |
| 543 | getDiagnostics().getNumErrorsSuppressed(); |
Chris Lattner | 53eee7b | 2010-04-07 18:47:42 +0000 | [diff] [blame] | 544 | |
| 545 | if (NumWarnings) |
| 546 | OS << NumWarnings << " warning" << (NumWarnings == 1 ? "" : "s"); |
| 547 | if (NumWarnings && NumErrors) |
| 548 | OS << " and "; |
| 549 | if (NumErrors) |
| 550 | OS << NumErrors << " error" << (NumErrors == 1 ? "" : "s"); |
| 551 | if (NumWarnings || NumErrors) |
| 552 | OS << " generated.\n"; |
| 553 | } |
Daniel Dunbar | 0397af2 | 2010-01-13 00:48:06 +0000 | [diff] [blame] | 554 | |
Daniel Dunbar | 2056048 | 2010-06-07 23:23:50 +0000 | [diff] [blame] | 555 | if (getFrontendOpts().ShowStats && hasFileManager()) { |
Daniel Dunbar | 0397af2 | 2010-01-13 00:48:06 +0000 | [diff] [blame] | 556 | getFileManager().PrintStats(); |
| 557 | OS << "\n"; |
| 558 | } |
| 559 | |
| 560 | // Return the appropriate status when verifying diagnostics. |
| 561 | // |
| 562 | // FIXME: If we could make getNumErrors() do the right thing, we wouldn't need |
| 563 | // this. |
| 564 | if (getDiagnosticOpts().VerifyDiagnostics) |
| 565 | return !static_cast<VerifyDiagnosticsClient&>( |
| 566 | getDiagnosticClient()).HadErrors(); |
| 567 | |
| 568 | return !getDiagnostics().getNumErrors(); |
| 569 | } |
| 570 | |
| 571 | |