aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-09-29 18:39:56 +0000
committerDevang Patel <dpatel@apple.com>2009-09-29 18:39:56 +0000
commite4002bc8194a36ff425f37829d6fb04a56ef1358 (patch)
tree0cee552e94f7c8c637888ee995d6f5314dee91ae
parent428fa81b068032e70a4df96a9bf95aea8647bae7 (diff)
downloadexternal_llvm-e4002bc8194a36ff425f37829d6fb04a56ef1358.zip
external_llvm-e4002bc8194a36ff425f37829d6fb04a56ef1358.tar.gz
external_llvm-e4002bc8194a36ff425f37829d6fb04a56ef1358.tar.bz2
Create empty StringRef is incoming cstring is NULL.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83082 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/ADT/StringRef.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h
index e4fd258..30379a3 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), 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)