diff options
Diffstat (limited to 'lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | lib/Frontend/CompilerInstance.cpp | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 3bc5661..7b4932d 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -107,15 +107,13 @@ void BinaryDiagnosticSerializer::HandleDiagnostic(Diagnostic::Level DiagLevel, static void SetUpBuildDumpLog(const DiagnosticOptions &DiagOpts, unsigned argc, char **argv, - llvm::OwningPtr<DiagnosticClient> &DiagClient) { + Diagnostic &Diags) { std::string ErrorInfo; - llvm::raw_ostream *OS = - new llvm::raw_fd_ostream(DiagOpts.DumpBuildInformation.c_str(), ErrorInfo); + llvm::OwningPtr<llvm::raw_ostream> OS( + new llvm::raw_fd_ostream(DiagOpts.DumpBuildInformation.c_str(), ErrorInfo)); if (!ErrorInfo.empty()) { - // FIXME: Do not fail like this. - llvm::errs() << "error opening -dump-build-information file '" - << DiagOpts.DumpBuildInformation << "', option ignored!\n"; - delete OS; + Diags.Report(diag::err_fe_unable_to_open_logfile) + << DiagOpts.DumpBuildInformation << ErrorInfo; return; } @@ -126,8 +124,8 @@ static void SetUpBuildDumpLog(const DiagnosticOptions &DiagOpts, // Chain in a diagnostic client which will log the diagnostics. DiagnosticClient *Logger = - new TextDiagnosticPrinter(*OS, DiagOpts, /*OwnsOutputStream=*/true); - DiagClient.reset(new ChainedDiagnosticClient(DiagClient.take(), Logger)); + new TextDiagnosticPrinter(*OS.take(), DiagOpts, /*OwnsOutputStream=*/true); + Diags.setClient(new ChainedDiagnosticClient(Diags.getClient(), Logger)); } void CompilerInstance::createDiagnostics(int Argc, char **Argv) { @@ -165,13 +163,12 @@ Diagnostic *CompilerInstance::createDiagnostics(const DiagnosticOptions &Opts, if (Opts.VerifyDiagnostics) DiagClient.reset(new VerifyDiagnosticsClient(*Diags, DiagClient.take())); + Diags->setClient(DiagClient.take()); if (!Opts.DumpBuildInformation.empty()) - SetUpBuildDumpLog(Opts, Argc, Argv, DiagClient); + SetUpBuildDumpLog(Opts, Argc, Argv, *Diags); // Configure our handling of diagnostics. - Diags->setClient(DiagClient.take()); - if (ProcessWarningOptions(*Diags, Opts)) - return 0; + ProcessWarningOptions(*Diags, Opts); return Diags.take(); } @@ -227,6 +224,9 @@ CompilerInstance::createPreprocessor(Diagnostic &Diags, PP->setPTHManager(PTHMgr); } + if (PPOpts.DetailedRecord) + PP->createPreprocessingRecord(); + InitializePreprocessor(*PP, PPOpts, HSOpts, FEOpts); // Handle generating dependencies, if requested. @@ -429,12 +429,7 @@ bool CompilerInstance::InitializeSourceManager(llvm::StringRef InputFile, SourceManager &SourceMgr, const FrontendOptions &Opts) { // Figure out where to get and map in the main file. - if (Opts.EmptyInputOnly) { - const char *EmptyStr = ""; - llvm::MemoryBuffer *SB = - llvm::MemoryBuffer::getMemBuffer(EmptyStr, EmptyStr, "<empty input>"); - SourceMgr.createMainFileIDForMemBuffer(SB); - } else if (InputFile != "-") { + if (InputFile != "-") { const FileEntry *File = FileMgr.getFile(InputFile); if (File) SourceMgr.createMainFileID(File, SourceLocation()); if (SourceMgr.getMainFileID().isInvalid()) { |