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
This commit is contained in:
Chris Lattner
2002-09-08 18:59:35 +00:00
parent bd78696719
commit d1e693f2a3
5 changed files with 70 additions and 7 deletions
+15 -2
View File
@@ -1,4 +1,4 @@
//===-- BasicBlock.cpp - Implement BasicBlock related functions --*- C++ -*--=//
//===-- BasicBlock.cpp - Implement BasicBlock related methods -------------===//
//
// This file implements the BasicBlock class for the VMCore library.
//
@@ -11,6 +11,7 @@
#include "llvm/Constant.h"
#include "llvm/iPHINode.h"
#include "llvm/SymbolTable.h"
#include "Support/LeakDetector.h"
#include "SymbolTableListTraitsImpl.h"
#include <algorithm>
@@ -18,7 +19,10 @@
// instruction list. This is not a real instruction.
//
struct DummyInst : public Instruction {
DummyInst() : Instruction(Type::VoidTy, NumOtherOps) {}
DummyInst() : Instruction(Type::VoidTy, NumOtherOps) {
// This should not be garbage monitored.
LeakDetector::removeGarbageObject(this);
}
virtual Instruction *clone() const {
assert(0 && "Cannot clone EOL");abort();
@@ -56,6 +60,9 @@ BasicBlock::BasicBlock(const std::string &name, Function *Parent)
// Initialize the instlist...
InstList.setItemParent(this);
// Make sure that we get added to a function
LeakDetector::addGarbageObject(this);
if (Parent)
Parent->getBasicBlockList().push_back(this);
}
@@ -66,7 +73,13 @@ BasicBlock::~BasicBlock() {
}
void BasicBlock::setParent(Function *parent) {
if (getParent())
LeakDetector::addGarbageObject(this);
InstList.setParent(parent);
if (getParent())
LeakDetector::removeGarbageObject(this);
}
// Specialize setName to take care of symbol table majik