diff options
author | Alex Lorenz <arphaman@gmail.com> | 2019-06-10 23:32:42 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2019-06-10 23:32:42 +0000 |
commit | 88377d8db79c46658f41dbf2503225265036444e (patch) | |
tree | c5e5c814e78bd99884ff15c6370e1c2597ec0e24 /clang/lib/Frontend/CompilerInstance.cpp | |
parent | 60e52cab86bee81d17a3279b83b8f645dfd8d1a4 (diff) | |
download | bcm5719-llvm-88377d8db79c46658f41dbf2503225265036444e.tar.gz bcm5719-llvm-88377d8db79c46658f41dbf2503225265036444e.zip |
[Frontend] SetUpDiagnosticLog should handle unowned diagnostic consumer
in the compiler
The function SetUpDiagnosticLog that was called from createDiagnostics didn't
handle the case where the diagnostics engine didn't own the diagnostics consumer.
This is a potential problem for a clang tool, in particular some of the follow-up
patches for clang-scan-deps will need this fix.
Differential Revision: https://reviews.llvm.org/D63101
llvm-svn: 363009
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 9c70a70ed7e..fd33b85b31d 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -232,9 +232,13 @@ static void SetUpDiagnosticLog(DiagnosticOptions *DiagOpts, std::move(StreamOwner)); if (CodeGenOpts) Logger->setDwarfDebugFlags(CodeGenOpts->DwarfDebugFlags); - assert(Diags.ownsClient()); - Diags.setClient( - new ChainedDiagnosticConsumer(Diags.takeClient(), std::move(Logger))); + if (Diags.ownsClient()) { + Diags.setClient( + new ChainedDiagnosticConsumer(Diags.takeClient(), std::move(Logger))); + } else { + Diags.setClient( + new ChainedDiagnosticConsumer(Diags.getClient(), std::move(Logger))); + } } static void SetupSerializedDiagnostics(DiagnosticOptions *DiagOpts, |