diff options
author | Chris Lattner <sabre@nondot.org> | 2007-02-11 00:39:38 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-02-11 00:39:38 +0000 |
commit | 2a8d2e0e52ce7f2c2689301979b3d02601b2bde4 (patch) | |
tree | 1088c5d4c66fe23cbd95ec5438a38479fcb6f0e1 /llvm/lib/Linker/LinkModules.cpp | |
parent | b625082a4261aacb4a91d770f6ebce9a8a7b4735 (diff) | |
download | bcm5719-llvm-2a8d2e0e52ce7f2c2689301979b3d02601b2bde4.tar.gz bcm5719-llvm-2a8d2e0e52ce7f2c2689301979b3d02601b2bde4.zip |
simplify this code by using value::takename
llvm-svn: 34172
Diffstat (limited to 'llvm/lib/Linker/LinkModules.cpp')
-rw-r--r-- | llvm/lib/Linker/LinkModules.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index 83765345bb1..f7accb7719c 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/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 |