diff options
Diffstat (limited to 'include/llvm/ADT/StringRef.h')
-rw-r--r-- | include/llvm/ADT/StringRef.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index 33756f605f..9962bb2b18 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 |