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 | a1d850ee1cdc2576f34cc38ac3018eb850ab33fe (patch) | |
tree | 4cf7a141ef19d08d718f5fd135e9330dde9fc999 /llvm | |
parent | 438e35c4d15121ae64e1e9cd45f0c6bcc18e7828 (diff) | |
download | bcm5719-llvm-a1d850ee1cdc2576f34cc38ac3018eb850ab33fe.tar.gz bcm5719-llvm-a1d850ee1cdc2576f34cc38ac3018eb850ab33fe.zip |
add a method for comparing to see if a value has a specified name.
llvm-svn: 50465
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/Value.h | 4 | ||||
-rw-r--r-- | llvm/lib/VMCore/Value.cpp | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/llvm/include/llvm/Value.h b/llvm/include/llvm/Value.h index 4604dae6ed9..c1c728270e4 100644 --- a/llvm/include/llvm/Value.h +++ b/llvm/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/llvm/lib/VMCore/Value.cpp b/llvm/lib/VMCore/Value.cpp index a61a1a02472..cf696fe44fe 100644 --- a/llvm/lib/VMCore/Value.cpp +++ b/llvm/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 ""; |