diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index 33756f605f0..9962bb2b188 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -149,7 +149,10 @@ namespace llvm { unsigned edit_distance(StringRef Other, bool AllowReplacements = true); /// str - Get the contents as an std::string. - std::string str() const { return std::string(Data, Length); } + std::string str() const { + if (Data == 0) return ""; + return std::string(Data, Length); + } /// @} /// @name Operator Overloads