-//===-- BasicBlock.cpp - Implement BasicBlock related functions --*- C++ -*--=//
+//===-- BasicBlock.cpp - Implement BasicBlock related methods -------------===//
//
// This file implements the BasicBlock class for the VMCore library.
//
#include "llvm/Constant.h"
#include "llvm/iPHINode.h"
#include "llvm/SymbolTable.h"
+#include "Support/LeakDetector.h"
#include "SymbolTableListTraitsImpl.h"
#include <algorithm>
// 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();
template SymbolTableListTraits<Instruction, BasicBlock, Function>;
+// BasicBlock ctor - If the function parameter is specified, the basic block is
+// automatically inserted at the end of the function.
+//
BasicBlock::BasicBlock(const std::string &name, Function *Parent)
: Value(Type::LabelTy, Value::BasicBlockVal, name) {
// 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);
}
InstList.clear();
}
+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
void BasicBlock::setName(const std::string &name, SymbolTable *ST) {
Function *P;