<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 17, 2014 at 12:23 PM, Reid Kleckner <span dir="ltr"><<a href="mailto:reid@kleckner.net" target="_blank">reid@kleckner.net</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rnk<br>
Date: Wed Dec 17 14:23:11 2014<br>
New Revision: 224454<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=224454&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=224454&view=rev</a><br>
Log:<br>
Destroy the diagnostic client first in ~DiagnosticEngine<br>
<br>
Add a comment and a test to ~DiagnosticEngine about the ordering<br>
requirements on the teardown of DiagnosticConsumer. This could also be<br>
accomplished by rearranging the fields of ~DiagnosticEngine, but I felt<br>
that this was a better, more explicit solution.<br></blockquote><div><br>Your call - though I'd personally vote for the member reordering (& just put the comment there, explaining what constraint on the order was required).<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This fixes PR21911, an issue that occurred after the unique_ptr<br>
migration in r222193.<br></blockquote><div><br>Thanks for the fix, in any case!<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Added:<br>
cfe/trunk/test/Frontend/verify-unknown-arg.c<br>
Modified:<br>
cfe/trunk/include/clang/Basic/Diagnostic.h<br>
cfe/trunk/lib/Basic/Diagnostic.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/Diagnostic.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=224454&r1=224453&r2=224454&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=224454&r1=224453&r2=224454&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)<br>
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Wed Dec 17 14:23:11 2014<br>
@@ -347,6 +347,7 @@ public:<br>
DiagnosticOptions *DiagOpts,<br>
DiagnosticConsumer *client = nullptr,<br>
bool ShouldOwnClient = true);<br>
+ ~DiagnosticsEngine();<br>
<br>
const IntrusiveRefCntPtr<DiagnosticIDs> &getDiagnosticIDs() const {<br>
return Diags;<br>
<br>
Modified: cfe/trunk/lib/Basic/Diagnostic.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=224454&r1=224453&r2=224454&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=224454&r1=224453&r2=224454&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)<br>
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Wed Dec 17 14:23:11 2014<br>
@@ -61,6 +61,12 @@ DiagnosticsEngine::DiagnosticsEngine(<br>
Reset();<br>
}<br>
<br>
+DiagnosticsEngine::~DiagnosticsEngine() {<br>
+ // If we own the diagnostic client, destroy it first so that it can access the<br>
+ // engine from its destructor.<br>
+ setClient(nullptr);<br>
+}<br>
+<br>
void DiagnosticsEngine::setClient(DiagnosticConsumer *client,<br>
bool ShouldOwnClient) {<br>
Owner.reset(ShouldOwnClient ? client : nullptr);<br>
<br>
Added: cfe/trunk/test/Frontend/verify-unknown-arg.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/verify-unknown-arg.c?rev=224454&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/verify-unknown-arg.c?rev=224454&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Frontend/verify-unknown-arg.c (added)<br>
+++ cfe/trunk/test/Frontend/verify-unknown-arg.c Wed Dec 17 14:23:11 2014<br>
@@ -0,0 +1,6 @@<br>
+// RUN: not %clang_cc1 -asdf -verify %s 2>&1 | FileCheck %s<br>
+<br>
+// expected-no-diagnostics<br>
+<br>
+// CHECK: error: 'error' diagnostics seen but not expected:<br>
+// CHECK-NEXT: (frontend): unknown argument: '-asdf'<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div></div>