aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Linker
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-11 00:39:38 +0000
committerChris Lattner <sabre@nondot.org>2007-02-11 00:39:38 +0000
commit33f294930e0affa51c3818405741abd80cc90316 (patch)
tree07e824a32357eee42752479334188beedb7256f8 /lib/Linker
parent7216811ea22d68cbf8df092cda8e64e13e394ac8 (diff)
downloadexternal_llvm-33f294930e0affa51c3818405741abd80cc90316.zip
external_llvm-33f294930e0affa51c3818405741abd80cc90316.tar.gz
external_llvm-33f294930e0affa51c3818405741abd80cc90316.tar.bz2
simplify this code by using value::takename
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34172 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker')
-rw-r--r--lib/Linker/LinkModules.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index 8376534..f7accb7 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -337,18 +337,15 @@ static void ForceRenaming(GlobalValue *GV, const std::string &Name) {
ValueSymbolTable &ST = GV->getParent()->getValueSymbolTable();
// If there is a conflict, rename the conflict.
- GlobalValue *ConflictGV = cast_or_null<GlobalValue>(ST.lookup(Name));
- if (ConflictGV) {
+ if (GlobalValue *ConflictGV = cast_or_null<GlobalValue>(ST.lookup(Name))) {
assert(ConflictGV->hasInternalLinkage() &&
"Not conflicting with a static global, should link instead!");
- ConflictGV->setName(""); // Eliminate the conflict
- }
- GV->setName(Name); // Force the name back
- if (ConflictGV) {
- ConflictGV->setName(Name); // This will cause ConflictGV to get renamed
+ GV->takeName(ConflictGV);
+ ConflictGV->setName(Name); // This will cause ConflictGV to get renamed
assert(ConflictGV->getName() != Name && "ForceRenaming didn't work");
+ } else {
+ GV->setName(Name); // Force the name back
}
- assert(GV->getName() == Name && "ForceRenaming didn't work");
}
/// CopyGVAttributes - copy additional attributes (those not needed to construct