From d8a232b716412d536f3340e7e7e6be82bd0669df Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 4 Feb 2004 01:06:38 +0000 Subject: [PATCH] If changing a parent, don't add then remove the object from the leak detector llvm-svn: 11106 --- llvm/lib/VMCore/Instruction.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/llvm/lib/VMCore/Instruction.cpp b/llvm/lib/VMCore/Instruction.cpp index 6f2480bdde7b..b009c01eecb7 100644 --- a/llvm/lib/VMCore/Instruction.cpp +++ b/llvm/lib/VMCore/Instruction.cpp @@ -35,13 +35,13 @@ Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name, } void Instruction::setParent(BasicBlock *P) { - if (getParent()) - LeakDetector::addGarbageObject(this); + if (getParent()) { + if (!P) LeakDetector::addGarbageObject(this); + } else { + if (P) LeakDetector::removeGarbageObject(this); + } Parent = P; - - if (getParent()) - LeakDetector::removeGarbageObject(this); } // Specialize setName to take care of symbol table majik