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

Chris Lattner sabre at nondot.org
Fri Aug 10 08:34:36 PDT 2007


Author: lattner
Date: Fri Aug 10 10:34:35 2007
New Revision: 40989

URL: http://llvm.org/viewvc/llvm-project?rev=40989&view=rev
Log:
add Value::getNameStart/getNameLen() accessors.

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=40989&r1=40988&r2=40989&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Value.h (original)
+++ llvm/trunk/include/llvm/Value.h Fri Aug 10 10:34:35 2007
@@ -88,9 +88,23 @@
 
   // All values can potentially be named...
   inline bool hasName() const { return Name != 0; }
+  ValueName *getValueName() const { return Name; }
+
+  /// getNameStart - Return a pointer to a null terminated string for this name.
+  /// Note that names can have null characters within the string as well as at
+  /// their end.  This always returns a non-null pointer.
+  const char *getNameStart() const;
+  
+  /// getNameLen - Return the length of the string, correctly handling nul
+  /// characters embedded into them.
+  unsigned getNameLen() const;
+
+  /// getName()/getNameStr() - Return the name of the specified value, 
+  /// *constructing a string* to hold it.  Because these are guaranteed to
+  /// construct a string, they are very expensive and should be avoided.
   std::string getName() const { return getNameStr(); }
   std::string getNameStr() const;
-  ValueName *getValueName() const { return Name; }
+
 
   void setName(const std::string &name);
   void setName(const char *Name, unsigned NameLen);

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

==============================================================================
--- llvm/trunk/lib/VMCore/Value.cpp (original)
+++ llvm/trunk/lib/VMCore/Value.cpp Fri Aug 10 10:34:35 2007
@@ -117,6 +117,21 @@
   return false;
 }
 
+/// getNameStart - Return a pointer to a null terminated string for this name.
+/// Note that names can have null characters within the string as well as at
+/// their end.  This always returns a non-null pointer.
+const char *Value::getNameStart() const {
+  if (Name == 0) return "";
+  return Name->getKeyData();
+}
+
+/// getNameLen - Return the length of the string, correctly handling nul
+/// characters embedded into them.
+unsigned Value::getNameLen() const {
+  return Name->getKeyLength();
+}
+
+
 std::string Value::getNameStr() const {
   if (Name == 0) return "";
   return std::string(Name->getKeyData(),





More information about the llvm-commits mailing list