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

Chris Lattner clattner at apple.com
Tue Sep 29 11:53:12 PDT 2009


On Sep 29, 2009, at 11:39 AM, Devang Patel wrote:

> 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.

I don't think this is correct, StringRef shouldn't allow null cstrings  
to be passed in.

-Chris

>
> 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)
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list