]> granicus.if.org Git - clang/commitdiff
[leaks] The PDFileEntry nodes in the FilesMade FoldingSet contain
authorChandler Carruth <chandlerc@gmail.com>
Sat, 3 May 2014 10:39:05 +0000 (10:39 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sat, 3 May 2014 10:39:05 +0000 (10:39 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207902 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
lib/StaticAnalyzer/Core/PathDiagnostic.cpp

index cc31593833306d9ec4ee9c0635a6571647adb05f..69ec3e3b3fc0279ddaced0e86dcd14fad6a6d097 100644 (file)
@@ -72,7 +72,9 @@ public:
   
   struct FilesMade : public llvm::FoldingSet<PDFileEntry> {
     llvm::BumpPtrAllocator Alloc;
-    
+
+    ~FilesMade();
+
     void addDiagnostic(const PathDiagnostic &PD,
                        StringRef ConsumerName,
                        StringRef fileName);
index 89e4309175301d41f59e111875886bf7e6496b4a..5b2aa353651121b740b4f68acb488b3aeed68d5d 100644 (file)
@@ -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) {