[llvm] r226536 - IR: Delete GenericDwarfNode during teardown
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Jan 19 17:18:32 PST 2015
Author: dexonsmith
Date: Mon Jan 19 19:18:32 2015
New Revision: 226536
URL: http://llvm.org/viewvc/llvm-project?rev=226536&view=rev
Log:
IR: Delete GenericDwarfNode during teardown
Fix a leak in `LLVMContextImpl` teardown that the leak sanitizer tracked
down [1]. I've just switched to automatic dispatch here (since I'll
inevitably forget again with the next class).
[1]: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/811/steps/check-llvm%20asan/logs/stdio
Modified:
llvm/trunk/lib/IR/LLVMContextImpl.cpp
Modified: llvm/trunk/lib/IR/LLVMContextImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContextImpl.cpp?rev=226536&r1=226535&r2=226536&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LLVMContextImpl.cpp (original)
+++ llvm/trunk/lib/IR/LLVMContextImpl.cpp Mon Jan 19 19:18:32 2015
@@ -78,10 +78,10 @@ LLVMContextImpl::~LLVMContextImpl() {
// unnecessary RAUW when nodes are still unresolved.
for (auto *I : DistinctMDNodes)
I->dropAllReferences();
- for (auto *I : MDTuples)
- I->dropAllReferences();
- for (auto *I : MDLocations)
+#define HANDLE_MDNODE_LEAF(CLASS) \
+ for (auto *I : CLASS##s) \
I->dropAllReferences();
+#include "llvm/IR/Metadata.def"
// Also drop references that come from the Value bridges.
for (auto &Pair : ValuesAsMetadata)
@@ -92,10 +92,10 @@ LLVMContextImpl::~LLVMContextImpl() {
// Destroy MDNodes.
for (MDNode *I : DistinctMDNodes)
I->deleteAsSubclass();
- for (MDTuple *I : MDTuples)
- delete I;
- for (MDLocation *I : MDLocations)
+#define HANDLE_MDNODE_LEAF(CLASS) \
+ for (CLASS *I : CLASS##s) \
delete I;
+#include "llvm/IR/Metadata.def"
// Free the constants. This is important to do here to ensure that they are
// freed before the LeakDetector is torn down.
More information about the llvm-commits
mailing list