[llvm-commits] [llvm] r87031 - /llvm/trunk/include/llvm/ADT/StringRef.h

Daniel Dunbar daniel at zuster.org
Thu Nov 12 13:26:12 PST 2009


Author: ddunbar
Date: Thu Nov 12 15:26:11 2009
New Revision: 87031

URL: http://llvm.org/viewvc/llvm-project?rev=87031&view=rev
Log:
StringRef(const char*) should not be used to turn null pointers into empty
strings.

Modified:
    llvm/trunk/include/llvm/ADT/StringRef.h

Modified: llvm/trunk/include/llvm/ADT/StringRef.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=87031&r1=87030&r2=87031&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/StringRef.h (original)
+++ llvm/trunk/include/llvm/ADT/StringRef.h Thu Nov 12 15:26:11 2009
@@ -46,7 +46,7 @@
 
     /// Construct a string ref from a cstring.
     /*implicit*/ StringRef(const char *Str)
-      : Data(Str) { if (Str) Length = ::strlen(Str); else Length = 0; }
+      : Data(Str), Length(::strlen(Str)) {}
 
     /// Construct a string ref from a pointer and length.
     /*implicit*/ StringRef(const char *data, size_t length)





More information about the llvm-commits mailing list