diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-30 03:55:40 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-30 03:55:40 +0000 |
commit | 12e6d200597bb5d61ed56ccf9d70a52614956a70 (patch) | |
tree | 5d6ca20313ef2e50aa43dd5a894e762f49186eb0 | |
parent | ea8650cddfb4ec7a532409ea918173e050cb40e8 (diff) | |
download | external_llvm-12e6d200597bb5d61ed56ccf9d70a52614956a70.zip external_llvm-12e6d200597bb5d61ed56ccf9d70a52614956a70.tar.gz external_llvm-12e6d200597bb5d61ed56ccf9d70a52614956a70.tar.bz2 |
add a method for comparing to see if a value has a specified name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50465 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Value.h | 4 | ||||
-rw-r--r-- | lib/VMCore/Value.cpp | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/include/llvm/Value.h b/include/llvm/Value.h index 4604dae..c1c7282 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -95,6 +95,10 @@ public: /// their end. This always returns a non-null pointer. const char *getNameStart() const; + /// isName - Return true if this value has the name specified by the provided + /// nul terminated string. + bool isName(const char *N) const; + /// getNameLen - Return the length of the string, correctly handling nul /// characters embedded into them. unsigned getNameLen() const; diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index a61a1a0..cf696fe 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -136,6 +136,13 @@ unsigned Value::getNameLen() const { return Name ? Name->getKeyLength() : 0; } +/// isName - Return true if this value has the name specified by the provided +/// nul terminated string. +bool Value::isName(const char *N) const { + unsigned InLen = strlen(N); + return InLen = getNameLen() && memcmp(getNameStart(), N, InLen) == 0; +} + std::string Value::getNameStr() const { if (Name == 0) return ""; |