]> granicus.if.org Git - clang/commitdiff
Don't leak _all_ directives in -verify mode. Found by LSan, PR19520.
authorNico Weber <nicolasweber@gmx.de>
Thu, 24 Apr 2014 05:39:55 +0000 (05:39 +0000)
committerNico Weber <nicolasweber@gmx.de>
Thu, 24 Apr 2014 05:39:55 +0000 (05:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207079 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/VerifyDiagnosticConsumer.h
lib/Frontend/VerifyDiagnosticConsumer.cpp

index 39678ef44bc968c0522bcdac557dfd8add606eae..fb026bbc2b0470044906a44c12eacc76b39889ac 100644 (file)
@@ -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 {
index 407c1d32972a8094dfd9c0faa4a7ca7b331c39ca..d6d01156557ebf3977f75252e6c45f47502f3e60 100644 (file)
@@ -847,9 +847,7 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() {
 
   // 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,