From: Chris Lattner Date: Sun, 11 Feb 2007 00:39:38 +0000 (+0000) Subject: simplify this code by using value::takename X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=33f294930e0affa51c3818405741abd80cc90316;p=oota-llvm.git simplify this code by using value::takename git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34172 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 83765345bb1..f7accb7719c 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(ST.lookup(Name)); - if (ConflictGV) { + if (GlobalValue *ConflictGV = cast_or_null(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