Issue a proper diagnostic if we couldn't open dump file

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98719 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticFrontendKinds.td b/include/clang/Basic/DiagnosticFrontendKinds.td
index b77614b..e6a9f67 100644
--- a/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -57,6 +57,8 @@
     "error at end of module block in PCH file: '%0'">;
 def err_fe_unable_to_open_output : Error<
     "unable to open output file '%0': '%1'">;
+def err_fe_unable_to_open_logfile : Error<
+    "unable to open logfile file '%0': '%1'">;
 def err_fe_pth_file_has_no_source_header : Error<
     "PTH file '%0' does not designate an original source header file for -include-pth">;
 def warn_fe_macro_contains_embedded_newline : Warning<
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index 3bc5661..2f7c248 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -107,14 +107,13 @@
 
 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);
   if (!ErrorInfo.empty()) {
-    // FIXME: Do not fail like this.
-    llvm::errs() << "error opening -dump-build-information file '"
-                 << DiagOpts.DumpBuildInformation << "', option ignored!\n";
+    Diags.Report(diag::err_fe_unable_to_open_logfile)
+                 << DiagOpts.DumpBuildInformation << ErrorInfo;
     delete OS;
     return;
   }
@@ -127,7 +126,7 @@
   // 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));
+  Diags.setClient(new ChainedDiagnosticClient(Diags.getClient(), Logger));
 }
 
 void CompilerInstance::createDiagnostics(int Argc, char **Argv) {
@@ -165,11 +164,11 @@
   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;