summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/ADT/StringRef.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index 37c214cdff7..5d0aafc4683 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -88,6 +88,10 @@ namespace llvm {
/*implicit*/ StringRef(const std::string &Str)
: Data(Str.data()), Length(Str.length()) {}
+ static StringRef withNullAsEmpty(const char *data) {
+ return StringRef(data ? data : "");
+ }
+
/// @}
/// @name Iterators
/// @{
OpenPOWER on IntegriCloud