From: Nico Weber Date: Thu, 24 Apr 2014 05:39:55 +0000 (+0000) Subject: Don't leak _all_ directives in -verify mode. Found by LSan, PR19520. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=33d678865e28dccaaa4f76988f0ba150bc8da3b0;p=clang Don't leak _all_ directives in -verify mode. Found by LSan, PR19520. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207079 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Frontend/VerifyDiagnosticConsumer.h b/include/clang/Frontend/VerifyDiagnosticConsumer.h index 39678ef44b..fb026bbc2b 100644 --- a/include/clang/Frontend/VerifyDiagnosticConsumer.h +++ b/include/clang/Frontend/VerifyDiagnosticConsumer.h @@ -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 { diff --git a/lib/Frontend/VerifyDiagnosticConsumer.cpp b/lib/Frontend/VerifyDiagnosticConsumer.cpp index 407c1d3297..d6d0115655 100644 --- a/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -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,