diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index 37c214cdff7..5d0aafc4683 100644 --- a/include/llvm/ADT/StringRef.h +++ b/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 /// @{