From: Daniel Dunbar Date: Thu, 12 Nov 2009 21:26:11 +0000 (+0000) Subject: StringRef(const char*) should not be used to turn null pointers into empty X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=89fccca4b01f148a7244f47e5a484cd793a1c30b;p=oota-llvm.git StringRef(const char*) should not be used to turn null pointers into empty strings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@87031 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index 269d16af618..b07dcc12ced 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -46,7 +46,7 @@ namespace llvm { /// 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)