[llvm-commits] [llvm] r50465 - in /llvm/trunk: include/llvm/Value.h lib/VMCore/Value.cpp

Chris Lattner sabre at nondot.org
Tue Apr 29 20:55:41 PDT 2008


Author: lattner
Date: Tue Apr 29 22:55:40 2008
New Revision: 50465

URL: http://llvm.org/viewvc/llvm-project?rev=50465&view=rev
Log:
add a method for comparing to see if a value has a specified name.

Modified:
    llvm/trunk/include/llvm/Value.h
    llvm/trunk/lib/VMCore/Value.cpp

Modified: llvm/trunk/include/llvm/Value.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Value.h?rev=50465&r1=50464&r2=50465&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Value.h (original)
+++ llvm/trunk/include/llvm/Value.h Tue Apr 29 22:55:40 2008
@@ -95,6 +95,10 @@
   /// 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;

Modified: llvm/trunk/lib/VMCore/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=50465&r1=50464&r2=50465&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Value.cpp (original)
+++ llvm/trunk/lib/VMCore/Value.cpp Tue Apr 29 22:55:40 2008
@@ -136,6 +136,13 @@
   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 "";





More information about the llvm-commits mailing list