@@ -60,7 +60,11 @@ namespace llvm {
6060 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
6161
6262 private:
63- std::string_view View;
63+ // / The start of the string, in an external buffer.
64+ const char *Data = nullptr ;
65+
66+ // / The length of the string.
67+ size_t Length = 0 ;
6468
6569 // Workaround memcmp issue with null pointers (undefined behavior)
6670 // by providing a specialized version
@@ -82,26 +86,28 @@ namespace llvm {
8286
8387 // / Construct a string ref from a cstring.
8488 /* implicit*/ constexpr StringRef (const char *Str LLVM_LIFETIME_BOUND)
85- : View (Str, Str ?
89+ : Data (Str), Length( Str ?
8690 // GCC 7 doesn't have constexpr char_traits. Fall back to __builtin_strlen.
8791#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE < 8
88- __builtin_strlen (Str)
92+ __builtin_strlen (Str)
8993#else
90- std::char_traits<char >::length(Str)
94+ std::char_traits<char >::length(Str)
9195#endif
92- : 0 ) {
96+ : 0 ) {
9397 }
9498
9599 // / Construct a string ref from a pointer and length.
96100 /* implicit*/ constexpr StringRef (const char *data LLVM_LIFETIME_BOUND,
97101 size_t length)
98- : View (data, length) {}
102+ : Data (data), Length( length) {}
99103
100104 // / Construct a string ref from an std::string.
101- /* implicit*/ StringRef(const std::string &Str) : View(Str) {}
105+ /* implicit*/ StringRef(const std::string &Str)
106+ : Data(Str.data()), Length(Str.length()) {}
102107
103108 // / Construct a string ref from an std::string_view.
104- /* implicit*/ constexpr StringRef (std::string_view Str) : View(Str) {}
109+ /* implicit*/ constexpr StringRef (std::string_view Str)
110+ : Data(Str.data()), Length(Str.size()) {}
105111
106112 // / @}
107113 // / @name Iterators
@@ -135,13 +141,13 @@ namespace llvm {
135141
136142 // / data - Get a pointer to the start of the string (which may not be null
137143 // / terminated).
138- [[nodiscard]] constexpr const char *data () const { return View. data () ; }
144+ [[nodiscard]] constexpr const char *data () const { return Data ; }
139145
140146 // / empty - Check if the string is empty.
141147 [[nodiscard]] constexpr bool empty () const { return size () == 0 ; }
142148
143149 // / size - Get the string size.
144- [[nodiscard]] constexpr size_t size () const { return View. size () ; }
150+ [[nodiscard]] constexpr size_t size () const { return Length ; }
145151
146152 // / front - Get the first character in the string.
147153 [[nodiscard]] char front () const {
0 commit comments