1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

simplify this code by using value::takename

llvm-svn: 34172
This commit is contained in:
Chris Lattner 2007-02-11 00:39:38 +00:00
parent e8dd3c90f1
commit 8aafcbb579

View File

@ -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