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 | d1e693f2a3883dacf213aa2b477540c57b53b714 (patch) | |
tree | 46b79948a66f3765a515c8cccaf2f7995a29c8ce /lib/VMCore/BasicBlock.cpp | |
parent | bd78696719a77c0ab4876901f2fa4dcbed234e46 (diff) |
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
Diffstat (limited to 'lib/VMCore/BasicBlock.cpp')
-rw-r--r-- | lib/VMCore/BasicBlock.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp index 4271f32e7a..bf7191c659 100644 --- a/lib/VMCore/BasicBlock.cpp +++ b/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 |