diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-26 00:51:56 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-26 00:51:56 +0000 |
commit | 499027fb4826e25919f2ea154ca4db73842560af (patch) | |
tree | ffb6fc38b2dfefebc67413b95d50760e9a2cb4d0 /include/llvm/Value.h | |
parent | e3577da6d969c7411736b5fcfe27ba355dd2d806 (diff) | |
download | llvm-499027fb4826e25919f2ea154ca4db73842560af.tar.gz llvm-499027fb4826e25919f2ea154ca4db73842560af.tar.bz2 llvm-499027fb4826e25919f2ea154ca4db73842560af.tar.xz |
Rewrite getName{Start,End,Len} in terms of getName(), instead of vice-versa.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77105 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Value.h')
-rw-r--r-- | include/llvm/Value.h | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/include/llvm/Value.h b/include/llvm/Value.h index b460e9a9a8..bee70b2147 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -114,18 +114,22 @@ public: /// getNameStart - Return a pointer to a null terminated string for this name. /// Note that names can have null characters within the string as well as at /// their end. This always returns a non-null pointer. - const char *getNameStart() const; + const char *getNameStart() const { return getName().begin(); } /// getNameEnd - Return a pointer to the end of the name. - const char *getNameEnd() const { return getNameStart() + getNameLen(); } + const char *getNameEnd() const { return getName().end(); } /// getNameLen - Return the length of the string, correctly handling nul /// characters embedded into them. - unsigned getNameLen() const; + unsigned getNameLen() const { return getName().size(); } - /// getName()/getNameStr() - Return the name of the specified value, - /// *constructing a string* to hold it. Because these are guaranteed to - /// construct a string, they are very expensive and should be avoided. - StringRef getName() const { return StringRef(getNameStart(), getNameLen()); } + /// getName() - Return a constant reference to the value's name. This is cheap + /// and guaranteed to return the same reference as long as the value is not + /// modified. + StringRef getName() const; + + /// getNameStr() - Return the name of the specified value, *constructing a + /// string* to hold it. This is guaranteed to construct a string and is very + /// expensive, clients should use getName() unless necessary. std::string getNameStr() const; /// setName() - Change the name of the value, choosing a new unique name if |