From 3f53fa9a51c4ce7ba81170ca7ab2e49bd37281b0 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sun, 26 Jul 2009 00:34:27 +0000 Subject: [PATCH] Remove Value::setName(const char*, unsigned). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77100 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Value.h | 5 ++++- lib/Bitcode/Reader/BitcodeReader.cpp | 4 ++-- lib/VMCore/Value.cpp | 14 +++++++------- tools/bugpoint/ExtractFunction.cpp | 4 ++-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/llvm/Value.h b/include/llvm/Value.h index 0ff0f7ebc96..b460e9a9a88 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -128,8 +128,11 @@ public: StringRef getName() const { return StringRef(getNameStart(), getNameLen()); } std::string getNameStr() const; + /// setName() - Change the name of the value, choosing a new unique name if + /// the provided name is taken. + /// + /// \arg Name - The new name; or "" if the value's name should be removed. void setName(const Twine &Name); - void setName(const char *Name, unsigned NameLen); /// takeName - transfer the name from V to this value, setting V's name to diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 7a224025532..0c6162ccffb 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -680,7 +680,7 @@ bool BitcodeReader::ParseValueSymbolTable() { return Error("Invalid Value ID in VST_ENTRY record"); Value *V = ValueList[ValueID]; - V->setName(&ValueName[0], ValueName.size()); + V->setName(StringRef(ValueName.data(), ValueName.size())); ValueName.clear(); break; } @@ -691,7 +691,7 @@ bool BitcodeReader::ParseValueSymbolTable() { if (BB == 0) return Error("Invalid BB ID in VST_BBENTRY record"); - BB->setName(&ValueName[0], ValueName.size()); + BB->setName(StringRef(ValueName.data(), ValueName.size())); ValueName.clear(); break; } diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index 1b9fe51332f..6157dd5a753 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -170,13 +170,13 @@ std::string Value::getNameStr() const { return getName().str(); } -void Value::setName(const Twine &Name) { +void Value::setName(const Twine &NewName) { SmallString<32> NameData; - Name.toVector(NameData); - setName(NameData.begin(), NameData.size()); -} + NewName.toVector(NameData); + + const char *NameStr = NameData.data(); + unsigned NameLen = NameData.size(); -void Value::setName(const char *NameStr, unsigned NameLen) { if (NameLen == 0 && !hasName()) return; assert(getType() != Type::VoidTy && "Cannot assign a name to void values!"); @@ -242,7 +242,7 @@ void Value::takeName(Value *V) { if (getSymTab(this, ST)) { // We can't set a name on this value, but we need to clear V's name if // it has one. - if (V->hasName()) V->setName(0, 0); + if (V->hasName()) V->setName(""); return; // Cannot set a name on this value (e.g. constant). } @@ -262,7 +262,7 @@ void Value::takeName(Value *V) { if (!ST) { if (getSymTab(this, ST)) { // Clear V's name. - V->setName(0, 0); + V->setName(""); return; // Cannot set a name on this value (e.g. constant). } } diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp index f0e9af7a63f..41704f9dcab 100644 --- a/tools/bugpoint/ExtractFunction.cpp +++ b/tools/bugpoint/ExtractFunction.cpp @@ -269,8 +269,8 @@ llvm::SplitFunctionsOutOfModule(Module *M, I->setLinkage(GlobalValue::ExternalLinkage); for (Module::global_iterator I = M->global_begin(), E = M->global_end(); I != E; ++I) { - if (I->hasName() && *I->getNameStart() == '\01') - I->setName(I->getNameStart()+1, I->getNameLen()-1); + if (I->hasName() && I->getName()[0] == '\01') + I->setName(I->getName().substr(1)); I->setLinkage(GlobalValue::ExternalLinkage); }