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
-//===-- BasicBlock.cpp - Implement BasicBlock related functions --*- C++ -*--=//
+//===-- BasicBlock.cpp - Implement BasicBlock related methods -------------===//
//
// This file implements the BasicBlock class for the VMCore library.
//
//
// This file implements the BasicBlock class for the VMCore library.
//
#include "llvm/Constant.h"
#include "llvm/iPHINode.h"
#include "llvm/SymbolTable.h"
#include "llvm/Constant.h"
#include "llvm/iPHINode.h"
#include "llvm/SymbolTable.h"
+#include "Support/LeakDetector.h"
#include "SymbolTableListTraitsImpl.h"
#include <algorithm>
#include "SymbolTableListTraitsImpl.h"
#include <algorithm>
// instruction list. This is not a real instruction.
//
struct DummyInst : public Instruction {
// 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();
virtual Instruction *clone() const {
assert(0 && "Cannot clone EOL");abort();
// Initialize the instlist...
InstList.setItemParent(this);
// 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);
}
if (Parent)
Parent->getBasicBlockList().push_back(this);
}
}
void BasicBlock::setParent(Function *parent) {
}
void BasicBlock::setParent(Function *parent) {
+ if (getParent())
+ LeakDetector::addGarbageObject(this);
+
InstList.setParent(parent);
InstList.setParent(parent);
+
+ if (getParent())
+ LeakDetector::removeGarbageObject(this);
}
// Specialize setName to take care of symbol table majik
}
// Specialize setName to take care of symbol table majik
#include "llvm/Module.h"
#include "llvm/DerivedTypes.h"
#include "llvm/iOther.h"
#include "llvm/Module.h"
#include "llvm/DerivedTypes.h"
#include "llvm/iOther.h"
+#include "Support/LeakDetector.h"
#include "SymbolTableListTraitsImpl.h"
BasicBlock *ilist_traits<BasicBlock>::createNode() {
#include "SymbolTableListTraitsImpl.h"
BasicBlock *ilist_traits<BasicBlock>::createNode() {
- return new BasicBlock();
+ BasicBlock *Ret = new BasicBlock();
+ // This should not be garbage monitored.
+ LeakDetector::removeGarbageObject(Ret);
+ return Ret;
}
iplist<BasicBlock> &ilist_traits<BasicBlock>::getList(Function *F) {
}
iplist<BasicBlock> &ilist_traits<BasicBlock>::getList(Function *F) {
}
Argument *ilist_traits<Argument>::createNode() {
}
Argument *ilist_traits<Argument>::createNode() {
- return new Argument(Type::IntTy);
+ Argument *Ret = new Argument(Type::IntTy);
+ // This should not be garbage monitored.
+ LeakDetector::removeGarbageObject(Ret);
+ return Ret;
}
iplist<Argument> &ilist_traits<Argument>::getList(Function *F) {
}
iplist<Argument> &ilist_traits<Argument>::getList(Function *F) {
Argument::Argument(const Type *Ty, const std::string &Name = "", Function *Par)
: Value(Ty, Value::ArgumentVal, Name) {
Parent = 0;
Argument::Argument(const Type *Ty, const std::string &Name = "", Function *Par)
: Value(Ty, Value::ArgumentVal, Name) {
Parent = 0;
+
+ // Make sure that we get added to a function
+ LeakDetector::addGarbageObject(this);
+
if (Par)
Par->getArgumentList().push_back(this);
}
if (Par)
Par->getArgumentList().push_back(this);
}
}
void Argument::setParent(Function *parent) {
}
void Argument::setParent(Function *parent) {
+ if (getParent())
+ LeakDetector::addGarbageObject(this);
+ if (getParent())
+ LeakDetector::removeGarbageObject(this);
ArgumentList.setParent(this);
ParentSymTab = SymTab = 0;
ArgumentList.setParent(this);
ParentSymTab = SymTab = 0;
+ // Make sure that we get added to a function
+ LeakDetector::addGarbageObject(this);
+
if (ParentModule)
ParentModule->getFunctionList().push_back(this);
}
if (ParentModule)
ParentModule->getFunctionList().push_back(this);
}
}
void Function::setParent(Module *parent) {
}
void Function::setParent(Module *parent) {
+ if (getParent())
+ LeakDetector::addGarbageObject(this);
+ if (getParent())
+ LeakDetector::removeGarbageObject(this);
// Relink symbol tables together...
ParentSymTab = Parent ? Parent->getSymbolTableSure() : 0;
// Relink symbol tables together...
ParentSymTab = Parent ? Parent->getSymbolTableSure() : 0;
isConstantGlobal(constant) {
if (Initializer) Operands.push_back(Use((Value*)Initializer, this));
isConstantGlobal(constant) {
if (Initializer) Operands.push_back(Use((Value*)Initializer, this));
+ LeakDetector::addGarbageObject(this);
+
if (ParentModule)
ParentModule->getGlobalList().push_back(this);
}
void GlobalVariable::setParent(Module *parent) {
if (ParentModule)
ParentModule->getGlobalList().push_back(this);
}
void GlobalVariable::setParent(Module *parent) {
+ if (getParent())
+ LeakDetector::addGarbageObject(this);
+ if (getParent())
+ LeakDetector::removeGarbageObject(this);
}
// Specialize setName to take care of symbol table majik
}
// Specialize setName to take care of symbol table majik
#include "llvm/Function.h"
#include "llvm/SymbolTable.h"
#include "llvm/Type.h"
#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;
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) {
}
void Instruction::setParent(BasicBlock *P) {
+ if (getParent())
+ LeakDetector::addGarbageObject(this);
+
+
+ if (getParent())
+ LeakDetector::removeGarbageObject(this);
}
// Specialize setName to take care of symbol table majik
}
// Specialize setName to take care of symbol table majik
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "Support/STLExtras.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "Support/STLExtras.h"
+#include "Support/LeakDetector.h"
#include "SymbolTableListTraitsImpl.h"
#include <algorithm>
#include <map>
Function *ilist_traits<Function>::createNode() {
#include "SymbolTableListTraitsImpl.h"
#include <algorithm>
#include <map>
Function *ilist_traits<Function>::createNode() {
- return new Function(FunctionType::get(Type::VoidTy,std::vector<const Type*>(),
- false), false);
+ FunctionType *FTy =
+ FunctionType::get(Type::VoidTy, std::vector<const Type*>(), false);
+ Function *Ret = new Function(FTy, false);
+ // This should not be garbage monitored.
+ LeakDetector::removeGarbageObject(Ret);
+ return Ret;
}
GlobalVariable *ilist_traits<GlobalVariable>::createNode() {
}
GlobalVariable *ilist_traits<GlobalVariable>::createNode() {
- return new GlobalVariable(Type::IntTy, false, false);
+ GlobalVariable *Ret = new GlobalVariable(Type::IntTy, false, false);
+ // This should not be garbage monitored.
+ LeakDetector::removeGarbageObject(Ret);
+ return Ret;
}
iplist<Function> &ilist_traits<Function>::getList(Module *M) {
}
iplist<Function> &ilist_traits<Function>::getList(Module *M) {
#include "llvm/InstrTypes.h"
#include "llvm/SymbolTable.h"
#include "llvm/DerivedTypes.h"
#include "llvm/InstrTypes.h"
#include "llvm/SymbolTable.h"
#include "llvm/DerivedTypes.h"
+#include "Support/LeakDetector.h"
#include <algorithm>
//===----------------------------------------------------------------------===//
#include <algorithm>
//===----------------------------------------------------------------------===//
}
#endif
assert(Uses.begin() == Uses.end());
}
#endif
assert(Uses.begin() == Uses.end());
+
+ // There should be no uses of this object anymore, remove it.
+ LeakDetector::removeGarbageObject(this);
}
void Value::replaceAllUsesWith(Value *D) {
}
void Value::replaceAllUsesWith(Value *D) {