From: Daniel Dunbar Date: Tue, 13 Mar 2012 18:30:38 +0000 (+0000) Subject: [Basic] Fix ~Diagnostic() to not call Emit() when there is no diag obj (most X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=53c83b32550b3f29db2419160fa2e3684e420556;p=clang [Basic] Fix ~Diagnostic() to not call Emit() when there is no diag obj (most commonly when the diag has been copied). - This eliminates a completely spurious call to Emit() which was in Sema::Diag(). Sob. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152640 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index 85d405062c..9d3e02b657 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -797,7 +797,10 @@ public: /// Destructor - The dtor emits the diagnostic if it hasn't already /// been emitted. - ~DiagnosticBuilder() { Emit(); } + ~DiagnosticBuilder() { + if (DiagObj) + Emit(); + } /// isActive - Determine whether this diagnostic is still active. bool isActive() const { return DiagObj != 0; }