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

Devang Patel dpatel at apple.com
Tue Sep 29 11:39:56 PDT 2009


Author: dpatel
Date: Tue Sep 29 13:39:56 2009
New Revision: 83082

URL: http://llvm.org/viewvc/llvm-project?rev=83082&view=rev
Log:
Create empty StringRef is incoming cstring is NULL.

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=83082&r1=83081&r2=83082&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/StringRef.h (original)
+++ llvm/trunk/include/llvm/ADT/StringRef.h Tue Sep 29 13:39:56 2009
@@ -46,7 +46,7 @@
 
     /// Construct a string ref from a cstring.
     /*implicit*/ StringRef(const char *Str) 
-      : Data(Str), Length(::strlen(Str)) {}
+      : Data(Str) { if (Str) Length = ::strlen(Str); else Length = 0; }
  
     /// Construct a string ref from a pointer and length.
     /*implicit*/ StringRef(const char *_Data, unsigned _Length)





More information about the llvm-commits mailing list