summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-08-18 00:11:25 +0000
committerChris Lattner <sabre@nondot.org>2010-08-18 00:11:25 +0000
commit7f7274ce7f3243bd71588c7a75a142c39e5c7e34 (patch)
tree4f28d17599ed45c56d1637ff8b1efa4cb735934e /include
parentdc65f22390ab100381e281399003d18ce98fdd53 (diff)
downloadllvm-7f7274ce7f3243bd71588c7a75a142c39e5c7e34.tar.gz
llvm-7f7274ce7f3243bd71588c7a75a142c39e5c7e34.tar.bz2
llvm-7f7274ce7f3243bd71588c7a75a142c39e5c7e34.tar.xz
Don't pass in a null pointer to std::string's ctor, an empty string
ref should produce an empty std::string. This fixes PR7879. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111332 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/ADT/StringRef.h5
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