Add llvm::Value::getNameRef, for help in API migration.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76893 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-07-23 18:50:53 +00:00
parent 8f51a62b41
commit e6c42dd6d3
2 changed files with 8 additions and 2 deletions

View File

@ -16,6 +16,7 @@
#include "llvm/AbstractTypeUser.h"
#include "llvm/Use.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include <iosfwd>
#include <string>
@ -129,7 +130,7 @@ public:
/// construct a string, they are very expensive and should be avoided.
std::string getName() const { return getNameStr(); }
std::string getNameStr() const;
StringRef getNameRef() const;
void setName(const std::string &name);
void setName(const char *Name, unsigned NameLen);

View File

@ -178,6 +178,11 @@ std::string Value::getNameStr() const {
Name->getKeyData()+Name->getKeyLength());
}
StringRef Value::getNameRef() const {
if (Name == 0) return StringRef();
return StringRef(Name->getKeyData(), Name->getKeyLength());
}
void Value::setName(const std::string &name) {
setName(&name[0], name.size());
}
@ -238,7 +243,7 @@ void Value::setName(const char *NameStr, unsigned NameLen) {
}
// Name is changing to something new.
Name = ST->createValueName(NameStr, NameLen, this);
Name = ST->createValueName(StringRef(NameStr, NameLen), this);
}