[llvm-commits] [llvm] r111332 - /llvm/trunk/include/llvm/ADT/StringRef.h
Chris Lattner
sabre at nondot.org
Tue Aug 17 17:11:25 PDT 2010
Author: lattner
Date: Tue Aug 17 19:11:25 2010
New Revision: 111332
URL: http://llvm.org/viewvc/llvm-project?rev=111332&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/ADT/StringRef.h
Modified: llvm/trunk/include/llvm/ADT/StringRef.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=111332&r1=111331&r2=111332&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringRef.h (original)
+++ llvm/trunk/include/llvm/ADT/StringRef.h Tue Aug 17 19:11:25 2010
@@ -149,7 +149,10 @@
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
More information about the llvm-commits
mailing list