aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/VMCore/Value.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp
index af753236c1..30ca5c35b5 100644
--- a/lib/VMCore/Value.cpp
+++ b/lib/VMCore/Value.cpp
@@ -141,6 +141,12 @@ void Value::setName(const std::string &name) {
/// takeName - transfer the name from V to this value, setting V's name to
/// empty. It is an error to call V->takeName(V).
void Value::takeName(Value *V) {
+ if (!V->hasName()) {
+ if (hasName())
+ setName("");
+ return;
+ }
+
std::string Name = V->getName();
V->setName("");
setName(Name);