Implement remove/eraseFromParent methods
authorChris Lattner <sabre@nondot.org>
Mon, 11 Oct 2004 22:21:39 +0000 (22:21 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 11 Oct 2004 22:21:39 +0000 (22:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16922 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/BasicBlock.cpp
lib/VMCore/Function.cpp
lib/VMCore/Globals.cpp
lib/VMCore/Instruction.cpp

index 32c86c4ce69079bd4be94e2067ddccb2cbba0ec5..2e8560cb65779dba97d99462cc28064809bec782 100644 (file)
@@ -105,6 +105,15 @@ void BasicBlock::setName(const std::string &name, SymbolTable *ST) {
   if (P && hasName()) P->getSymbolTable().insert(this);
 }
 
+void BasicBlock::removeFromParent() {
+  getParent()->getBasicBlockList().remove(this);
+}
+
+void BasicBlock::eraseFromParent() {
+  getParent()->getBasicBlockList().erase(this);
+}
+
+
 TerminatorInst *BasicBlock::getTerminator() {
   if (InstList.empty()) return 0;
   return dyn_cast<TerminatorInst>(&InstList.back());
index e918fd5878a02b4cb9634dc6be867ee30e1cc6db..ede2ca209747b2b936364aa74fbcd6be6d4104b9 100644 (file)
@@ -147,6 +147,14 @@ const Type *Function::getReturnType() const {
   return getFunctionType()->getReturnType();
 }
 
+void Function::removeFromParent() {
+  getParent()->getFunctionList().remove(this);
+}
+
+void Function::eraseFromParent() {
+  getParent()->getFunctionList().erase(this);
+}
+
 // dropAllReferences() - This function causes all the subinstructions to "let
 // go" of all references that they are maintaining.  This allows one to
 // 'delete' a whole class at a time, even though there may be circular
index b84dbf7fd4a60131838bb50b766c53ffae0a4c48..731f495c299d50d4036e02e5f41843396b0b65c0 100644 (file)
@@ -106,9 +106,16 @@ void GlobalVariable::setName(const std::string &name, SymbolTable *ST) {
   if (P && hasName()) P->getSymbolTable().insert(this);
 }
 
+void GlobalVariable::removeFromParent() {
+  getParent()->getGlobalList().remove(this);
+}
+
+void GlobalVariable::eraseFromParent() {
+  getParent()->getGlobalList().erase(this);
+}
+
 void GlobalVariable::replaceUsesOfWithOnConstant(Value *From, Value *To,
-                                                 bool DisableChecking )
-{
+                                                 bool DisableChecking) {
   // If you call this, then you better know this GVar has a constant
   // initializer worth replacing. Enforce that here.
   assert(getNumOperands() == 1 && 
index f54acf5f03edb23e2b9e2ec1af4b2fd99e81882c..4ea5775330a1b1d1930c4ce0ce75875c7df2bcc5 100644 (file)
@@ -72,6 +72,13 @@ void Instruction::setName(const std::string &name, SymbolTable *ST) {
   if (PP && hasName()) PP->getSymbolTable().insert(this);
 }
 
+void Instruction::removeFromParent() {
+  getParent()->getInstList().remove(this);
+}
+
+void Instruction::eraseFromParent() {
+  getParent()->getInstList().erase(this);
+}
 
 const char *Instruction::getOpcodeName(unsigned OpCode) {
   switch (OpCode) {