summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/Diagnostic.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-12-17 20:23:11 +0000
committerReid Kleckner <reid@kleckner.net>2014-12-17 20:23:11 +0000
commitdccbabfacf4b993e2cbe394c814c47b4dca17df8 (patch)
tree7021d1441c7a83424623504b9fc9e5a39e4d91b1 /clang/lib/Basic/Diagnostic.cpp
parent390fe4e450ca1c22263ab3fd3957379dbcb1ded2 (diff)
downloadbcm5719-llvm-dccbabfacf4b993e2cbe394c814c47b4dca17df8.tar.gz
bcm5719-llvm-dccbabfacf4b993e2cbe394c814c47b4dca17df8.zip
Destroy the diagnostic client first in ~DiagnosticEngine
Add a comment and a test to ~DiagnosticEngine about the ordering requirements on the teardown of DiagnosticConsumer. This could also be accomplished by rearranging the fields of ~DiagnosticEngine, but I felt that this was a better, more explicit solution. This fixes PR21911, an issue that occurred after the unique_ptr migration in r222193. llvm-svn: 224454
Diffstat (limited to 'clang/lib/Basic/Diagnostic.cpp')
-rw-r--r--clang/lib/Basic/Diagnostic.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index 5c066efa108..a8929466084 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -61,6 +61,12 @@ DiagnosticsEngine::DiagnosticsEngine(
Reset();
}
+DiagnosticsEngine::~DiagnosticsEngine() {
+ // If we own the diagnostic client, destroy it first so that it can access the
+ // engine from its destructor.
+ setClient(nullptr);
+}
+
void DiagnosticsEngine::setClient(DiagnosticConsumer *client,
bool ShouldOwnClient) {
Owner.reset(ShouldOwnClient ? client : nullptr);
OpenPOWER on IntegriCloud