diff options
author | Chris Lattner <sabre@nondot.org> | 2002-09-08 18:59:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-09-08 18:59:35 +0000 |
commit | 184b298edcf86613b6d5ba8efc4c6055351a7fcc (patch) | |
tree | ee5a136b781090cdc326ace1473ea839ef1c2796 /llvm/lib/VMCore/BasicBlock.cpp | |
parent | bdb147c37312365ed70d16c954a3ff066eb0bf78 (diff) | |
download | bcm5719-llvm-184b298edcf86613b6d5ba8efc4c6055351a7fcc.tar.gz bcm5719-llvm-184b298edcf86613b6d5ba8efc4c6055351a7fcc.zip |
Enable "garbage detection" of LLVM objects. Now users should be obnoxious
warnings. If they accidentally leak LLVM Value's.
llvm-svn: 3620
Diffstat (limited to 'llvm/lib/VMCore/BasicBlock.cpp')
-rw-r--r-- | llvm/lib/VMCore/BasicBlock.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/BasicBlock.cpp b/llvm/lib/VMCore/BasicBlock.cpp index 4271f32e7ac..bf7191c6593 100644 --- a/llvm/lib/VMCore/BasicBlock.cpp +++ b/llvm/lib/VMCore/BasicBlock.cpp @@ -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 |