aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-03-05 19:51:50 +0000
committerChris Lattner <sabre@nondot.org>2005-03-05 19:51:50 +0000
commit0d1e40728d668085257b78657b381e1f13d77d52 (patch)
tree00e51cc189ccb0faa187276ed1c6ca5f2d953b9e /lib/VMCore
parent7acff25f7f48ccbc8ca55032a59bfd4102ebed72 (diff)
downloadexternal_llvm-0d1e40728d668085257b78657b381e1f13d77d52.zip
external_llvm-0d1e40728d668085257b78657b381e1f13d77d52.tar.gz
external_llvm-0d1e40728d668085257b78657b381e1f13d77d52.tar.bz2
remove all of the various setName implementations, consolidating them into
Value::setName, which is no longer virtual. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20464 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/BasicBlock.cpp9
-rw-r--r--lib/VMCore/Constants.cpp4
-rw-r--r--lib/VMCore/Function.cpp17
-rw-r--r--lib/VMCore/Globals.cpp8
-rw-r--r--lib/VMCore/Instruction.cpp9
-rw-r--r--lib/VMCore/Value.cpp31
6 files changed, 28 insertions, 50 deletions
diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp
index 232a4e3..49bd8cf 100644
--- a/lib/VMCore/BasicBlock.cpp
+++ b/lib/VMCore/BasicBlock.cpp
@@ -16,7 +16,6 @@
#include "llvm/Instructions.h"
#include "llvm/Type.h"
#include "llvm/Support/CFG.h"
-#include "llvm/SymbolTable.h"
#include "llvm/Support/LeakDetector.h"
#include "SymbolTableListTraitsImpl.h"
#include <algorithm>
@@ -95,14 +94,6 @@ void BasicBlock::setParent(Function *parent) {
LeakDetector::removeGarbageObject(this);
}
-// Specialize setName to take care of symbol table majik
-void BasicBlock::setName(const std::string &name) {
- Function *P;
- if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this);
- Value::setName(name);
- if (P && hasName()) P->getSymbolTable().insert(this);
-}
-
void BasicBlock::removeFromParent() {
getParent()->getBasicBlockList().remove(this);
}
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 99a15ea..dfba350 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -31,10 +31,6 @@ ConstantBool *ConstantBool::False = new ConstantBool(false);
// Constant Class
//===----------------------------------------------------------------------===//
-void Constant::setName(const std::string &Name) {
- // Constants can't take names.
-}
-
void Constant::destroyConstantImpl() {
// When a Constant is destroyed, there may be lingering
// references to the constant by other constants in the constant pool. These
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index 7cced30..df8d1f9 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -62,15 +62,6 @@ Argument::Argument(const Type *Ty, const std::string &Name, Function *Par)
Par->getArgumentList().push_back(this);
}
-
-// Specialize setName to take care of symbol table majik
-void Argument::setName(const std::string &name) {
- Function *P;
- if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this);
- Value::setName(name);
- if (P && hasName()) P->getSymbolTable().insert(this);
-}
-
void Argument::setParent(Function *parent) {
if (getParent())
LeakDetector::addGarbageObject(this);
@@ -118,14 +109,6 @@ Function::~Function() {
delete SymTab;
}
-// Specialize setName to take care of symbol table majik
-void Function::setName(const std::string &name) {
- Module *P;
- if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this);
- Value::setName(name);
- if (P && hasName()) P->getSymbolTable().insert(this);
-}
-
void Function::setParent(Module *parent) {
if (getParent())
LeakDetector::addGarbageObject(this);
diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp
index efa588b..c0264ae 100644
--- a/lib/VMCore/Globals.cpp
+++ b/lib/VMCore/Globals.cpp
@@ -99,14 +99,6 @@ void GlobalVariable::setParent(Module *parent) {
LeakDetector::removeGarbageObject(this);
}
-// Specialize setName to take care of symbol table majik
-void GlobalVariable::setName(const std::string &name) {
- Module *P;
- if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this);
- Value::setName(name);
- if (P && hasName()) P->getSymbolTable().insert(this);
-}
-
void GlobalVariable::removeFromParent() {
getParent()->getGlobalList().remove(this);
}
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp
index eeba47b..4ccbd74 100644
--- a/lib/VMCore/Instruction.cpp
+++ b/lib/VMCore/Instruction.cpp
@@ -57,15 +57,6 @@ void Instruction::setParent(BasicBlock *P) {
Parent = P;
}
-// Specialize setName to take care of symbol table majik
-void Instruction::setName(const std::string &name) {
- BasicBlock *P = 0; Function *PP = 0;
- if ((P = getParent()) && (PP = P->getParent()) && hasName())
- PP->getSymbolTable().remove(this);
- Value::setName(name);
- if (PP && hasName()) PP->getSymbolTable().insert(this);
-}
-
void Instruction::removeFromParent() {
getParent()->getInstList().remove(this);
}
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp
index b3b133f..cdde96b 100644
--- a/lib/VMCore/Value.cpp
+++ b/lib/VMCore/Value.cpp
@@ -11,11 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Constant.h"
+#include "llvm/DerivedTypes.h"
#include "llvm/InstrTypes.h"
+#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Constant.h"
-#include "llvm/GlobalValue.h"
#include "llvm/Support/LeakDetector.h"
#include <algorithm>
#include <iostream>
@@ -93,6 +93,31 @@ unsigned Value::getNumUses() const {
}
+void Value::setName(const std::string &name) {
+ if (Name == name) return; // Name is already set.
+
+ SymbolTable *ST = 0;
+
+ if (Instruction *I = dyn_cast<Instruction>(this)) {
+ if (BasicBlock *P = I->getParent())
+ if (Function *PP = P->getParent())
+ ST = &PP->getSymbolTable();
+ } else if (BasicBlock *BB = dyn_cast<BasicBlock>(this)) {
+ if (Function *P = BB->getParent()) ST = &P->getSymbolTable();
+ } else if (GlobalValue *GV = dyn_cast<GlobalValue>(this)) {
+ if (Module *P = GV->getParent()) ST = &P->getSymbolTable();
+ } else if (Argument *A = dyn_cast<Argument>(this)) {
+ if (Function *P = A->getParent()) ST = &P->getSymbolTable();
+ } else {
+ assert(isa<Constant>(this) && "Unknown value type!");
+ return; // no name is setable for this.
+ }
+
+ if (ST && hasName()) ST->remove(this);
+ Name = name;
+ if (ST && hasName()) ST->insert(this);
+}
+
// uncheckedReplaceAllUsesWith - This is exactly the same as replaceAllUsesWith,
// except that it doesn't have all of the asserts. The asserts fail because we
// are half-way done resolving types, which causes some types to exist as two