mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-21 08:17:40 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user