forked from OSchip/llvm-project
add a method for comparing to see if a value has a specified name.
llvm-svn: 50465
This commit is contained in:
parent
438e35c4d1
commit
a1d850ee1c
|
@ -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;
|
||||
|
|
|
@ -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 "";
|
||||
|
|
Loading…
Reference in New Issue