From 7ff07727b540dfb17b5a41c95306c91e1e04ce2c Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 3 May 2014 10:39:05 +0000 Subject: [PATCH] [leaks] The PDFileEntry nodes in the FilesMade FoldingSet contain a std::vector that allocates on the heap. As a consequence, we have to run all of their destructors when tearing down the set, not just deallocate the memory blobs. llvm-svn: 207902 --- .../clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h | 4 +++- clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h index cc3159383330..69ec3e3b3fc0 100644 --- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h +++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h @@ -72,7 +72,9 @@ public: struct FilesMade : public llvm::FoldingSet { llvm::BumpPtrAllocator Alloc; - + + ~FilesMade(); + void addDiagnostic(const PathDiagnostic &PD, StringRef ConsumerName, StringRef fileName); diff --git a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp index 89e430917530..5b2aa3536511 100644 --- a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -451,6 +451,11 @@ void PathDiagnosticConsumer::FlushDiagnostics( Diags.clear(); } +PathDiagnosticConsumer::FilesMade::~FilesMade() { + for (PDFileEntry &Entry : *this) + Entry.~PDFileEntry(); +} + void PathDiagnosticConsumer::FilesMade::addDiagnostic(const PathDiagnostic &PD, StringRef ConsumerName, StringRef FileName) {