diff options
| author | Justin Bogner <mail@justinbogner.com> | 2014-10-23 22:20:11 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2014-10-23 22:20:11 +0000 |
| commit | 5a6a2fcdeef3f51d98183cb5d737facf91718a4b (patch) | |
| tree | ded5a5ad19666faf2fa3766727ea474c6be924a8 /clang/tools/driver | |
| parent | a182530633c46ef772bb346eca16b471b591c899 (diff) | |
| download | bcm5719-llvm-5a6a2fcdeef3f51d98183cb5d737facf91718a4b.tar.gz bcm5719-llvm-5a6a2fcdeef3f51d98183cb5d737facf91718a4b.zip | |
Driver: Include driver diagnostics when we --serialize-diagnostics
Currently, when --serialize-diagnostics is passed this only includes
the diagnostics from clang -cc1, and driver diagnostics are
dropped. This causes issues for tools that use the serialized
diagnostics, since stderr is lost and these diagnostics aren't seen at
all.
We handle this by merging the diagnostics from the CC1 process and the
driver diagnostics into a single file when the driver invokes CC1.
Fixes rdar://problem/10585062
llvm-svn: 220525
Diffstat (limited to 'clang/tools/driver')
| -rw-r--r-- | clang/tools/driver/driver.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp index de4b07d2141..5a3fed6d984 100644 --- a/clang/tools/driver/driver.cpp +++ b/clang/tools/driver/driver.cpp @@ -19,6 +19,8 @@ #include "clang/Driver/DriverDiagnostic.h" #include "clang/Driver/Options.h" #include "clang/Frontend/CompilerInvocation.h" +#include "clang/Frontend/ChainedDiagnosticConsumer.h" +#include "clang/Frontend/SerializedDiagnosticPrinter.h" #include "clang/Frontend/TextDiagnosticPrinter.h" #include "clang/Frontend/Utils.h" #include "llvm/ADT/ArrayRef.h" @@ -445,6 +447,16 @@ int main(int argc_, const char **argv_) { IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs()); DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagClient); + + if (!DiagOpts->DiagnosticSerializationFile.empty()) { + auto SerializedConsumer = + clang::serialized_diags::create(DiagOpts->DiagnosticSerializationFile, + &*DiagOpts, /*MergeChildRecords=*/true); + Diags.setClient(new ChainedDiagnosticConsumer( + std::unique_ptr<DiagnosticConsumer>(Diags.takeClient()), + std::move(SerializedConsumer))); + } + ProcessWarningOptions(Diags, *DiagOpts, /*ReportDiags=*/false); Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags); @@ -492,10 +504,12 @@ int main(int argc_, const char **argv_) { } } + Diags.getClient()->finish(); + // If any timers were active but haven't been destroyed yet, print their // results now. This happens in -disable-free mode. llvm::TimerGroup::printAll(llvm::errs()); - + llvm::llvm_shutdown(); #ifdef LLVM_ON_WIN32 |

