r207079 - Don't leak _all_ directives in -verify mode. Found by LSan, PR19520.

Nico Weber nicolasweber at gmx.de
Wed Apr 23 22:39:55 PDT 2014


Author: nico
Date: Thu Apr 24 00:39:55 2014
New Revision: 207079

URL: http://llvm.org/viewvc/llvm-project?rev=207079&view=rev
Log:
Don't leak _all_ directives in -verify mode. Found by LSan, PR19520.

Modified:
    cfe/trunk/include/clang/Frontend/VerifyDiagnosticConsumer.h
    cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp

Modified: cfe/trunk/include/clang/Frontend/VerifyDiagnosticConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/VerifyDiagnosticConsumer.h?rev=207079&r1=207078&r2=207079&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/VerifyDiagnosticConsumer.h (original)
+++ cfe/trunk/include/clang/Frontend/VerifyDiagnosticConsumer.h Thu Apr 24 00:39:55 2014
@@ -186,11 +186,13 @@ public:
     DirectiveList Warnings;
     DirectiveList Notes;
 
-    ~ExpectedData() {
+    void Reset() {
       llvm::DeleteContainerPointers(Errors);
       llvm::DeleteContainerPointers(Warnings);
       llvm::DeleteContainerPointers(Notes);
     }
+
+    ~ExpectedData() { Reset(); }
   };
 
   enum DirectiveStatus {

Modified: cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp?rev=207079&r1=207078&r2=207079&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp (original)
+++ cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp Thu Apr 24 00:39:55 2014
@@ -847,9 +847,7 @@ void VerifyDiagnosticConsumer::CheckDiag
 
   // Reset the buffer, we have processed all the diagnostics in it.
   Buffer.reset(new TextDiagnosticBuffer());
-  ED.Errors.clear();
-  ED.Warnings.clear();
-  ED.Notes.clear();
+  ED.Reset();
 }
 
 Directive *Directive::create(bool RegexKind, SourceLocation DirectiveLoc,





More information about the cfe-commits mailing list