aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT
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
commit1e9a727f1058c9e8f90eae9ac656214265244f7f (patch)
tree0cee552e94f7c8c637888ee995d6f5314dee91ae /include/llvm/ADT
parent9a0b6e6ded68db772631c2938c7a07905e28144f (diff)
downloadexternal_llvm-1e9a727f1058c9e8f90eae9ac656214265244f7f.zip
external_llvm-1e9a727f1058c9e8f90eae9ac656214265244f7f.tar.gz
external_llvm-1e9a727f1058c9e8f90eae9ac656214265244f7f.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
Diffstat (limited to 'include/llvm/ADT')
-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)