add a method for comparing to see if a value has a specified name.
authorChris Lattner <sabre@nondot.org>
Wed, 30 Apr 2008 03:55:40 +0000 (03:55 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 30 Apr 2008 03:55:40 +0000 (03:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50465 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Value.h
lib/VMCore/Value.cpp

index 4604dae6ed9e3fc4a762674598aab8e9dc8b223a..c1c728270e4c53de1d12590ee95ee1298ba8eff1 100644 (file)
@@ -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;
index a61a1a02472765c08af97da068790177a5542176..cf696fe44feee92df2854f61cdb4c826d1a390db 100644 (file)
@@ -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 "";