simplify code by using Value::takeName

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34177 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2007-02-11 01:37:51 +00:00
parent 6934a04a8c
commit 86cc423555
4 changed files with 26 additions and 32 deletions

View File

@ -29,14 +29,12 @@ void llvm::ReplaceInstWithValue(BasicBlock::InstListType &BIL,
// Replaces all of the uses of the instruction with uses of the value
I.replaceAllUsesWith(V);
std::string OldName = I.getName();
// Make sure to propagate a name if there is one already.
if (I.hasName() && !V->hasName())
V->takeName(&I);
// Delete the unnecessary instruction now...
BI = BIL.erase(BI);
// Make sure to propagate a name if there is one already.
if (!OldName.empty() && !V->hasName())
V->setName(OldName);
}