Enable "garbage detection" of LLVM objects. Now users should be obnoxious
warnings. If they accidentally leak LLVM Value's.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3620 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp
index 2c7f6ea..4368b7e 100644
--- a/lib/VMCore/Instruction.cpp
+++ b/lib/VMCore/Instruction.cpp
@@ -7,15 +7,25 @@
#include "llvm/Function.h"
#include "llvm/SymbolTable.h"
#include "llvm/Type.h"
+#include "Support/LeakDetector.h"
Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name)
: User(ty, Value::InstructionVal, Name) {
Parent = 0;
iType = it;
+
+ // Make sure that we get added to a basicblock
+ LeakDetector::addGarbageObject(this);
}
void Instruction::setParent(BasicBlock *P) {
+ if (getParent())
+ LeakDetector::addGarbageObject(this);
+
Parent = P;
+
+ if (getParent())
+ LeakDetector::removeGarbageObject(this);
}
// Specialize setName to take care of symbol table majik