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

Chris Lattner clattner at apple.com
Thu Oct 1 13:28:23 PDT 2009


On Oct 1, 2009, at 10:59 AM, Devang Patel wrote:
>>> I'm using it to pass optional strings. For example, linkage name  
>>> in debug info.
>>> Note, one can create empty StringRef by say
>>> 	SringRef foo;
>>> If this is not desirable then I'll update DebugInfo interface.
>>
>> Hi Devang,
>>
>> Can you use the StringRef(const char *data, unsigned length)  
>> constructor for
>> this purpose, passing in a length of 0?  That way the  
>> StringRef(const char *data)
>> constructor doesn't need to check for null.
>
> That'd require clients to do strlen(). Right now StringRef  
> constructor calls strlen(). It'd be better to use const char *  
> directly in the DebugInfo interface.

But Dan's solution doesn't punish all users of StringRef.

-Chris



More information about the llvm-commits mailing list