LLVM  16.0.0git
StringRef.h
Go to the documentation of this file.
1 //===- StringRef.h - Constant String Reference Wrapper ----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_ADT_STRINGREF_H
10 #define LLVM_ADT_STRINGREF_H
11 
12 #include "llvm/ADT/DenseMapInfo.h"
15 #include "llvm/Support/Compiler.h"
16 #include <algorithm>
17 #include <cassert>
18 #include <cstddef>
19 #include <cstring>
20 #include <limits>
21 #include <string>
22 #include <string_view>
23 #include <type_traits>
24 #include <utility>
25 
26 namespace llvm {
27 
28  class APInt;
29  class hash_code;
30  template <typename T> class SmallVectorImpl;
31  class StringRef;
32 
33  /// Helper functions for StringRef::getAsInteger.
34  bool getAsUnsignedInteger(StringRef Str, unsigned Radix,
35  unsigned long long &Result);
36 
37  bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result);
38 
39  bool consumeUnsignedInteger(StringRef &Str, unsigned Radix,
40  unsigned long long &Result);
41  bool consumeSignedInteger(StringRef &Str, unsigned Radix, long long &Result);
42 
43  /// StringRef - Represent a constant reference to a string, i.e. a character
44  /// array and a length, which need not be null terminated.
45  ///
46  /// This class does not own the string data, it is expected to be used in
47  /// situations where the character data resides in some other buffer, whose
48  /// lifetime extends past that of the StringRef. For this reason, it is not in
49  /// general safe to store a StringRef.
51  public:
52  static constexpr size_t npos = ~size_t(0);
53 
54  using iterator = const char *;
55  using const_iterator = const char *;
56  using size_type = size_t;
57 
58  private:
59  /// The start of the string, in an external buffer.
60  const char *Data = nullptr;
61 
62  /// The length of the string.
63  size_t Length = 0;
64 
65  // Workaround memcmp issue with null pointers (undefined behavior)
66  // by providing a specialized version
67  static int compareMemory(const char *Lhs, const char *Rhs, size_t Length) {
68  if (Length == 0) { return 0; }
69  return ::memcmp(Lhs,Rhs,Length);
70  }
71 
72  public:
73  /// @name Constructors
74  /// @{
75 
76  /// Construct an empty string ref.
77  /*implicit*/ StringRef() = default;
78 
79  /// Disable conversion from nullptr. This prevents things like
80  /// if (S == nullptr)
81  StringRef(std::nullptr_t) = delete;
82 
83  /// Construct a string ref from a cstring.
84  /*implicit*/ constexpr StringRef(const char *Str)
85  : Data(Str), Length(Str ?
86  // GCC 7 doesn't have constexpr char_traits. Fall back to __builtin_strlen.
87 #if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE < 8
88  __builtin_strlen(Str)
89 #else
90  std::char_traits<char>::length(Str)
91 #endif
92  : 0) {
93  }
94 
95  /// Construct a string ref from a pointer and length.
96  /*implicit*/ constexpr StringRef(const char *data, size_t length)
97  : Data(data), Length(length) {}
98 
99  /// Construct a string ref from an std::string.
100  /*implicit*/ StringRef(const std::string &Str)
101  : Data(Str.data()), Length(Str.length()) {}
102 
103  /// Construct a string ref from an std::string_view.
104  /*implicit*/ constexpr StringRef(std::string_view Str)
105  : Data(Str.data()), Length(Str.size()) {}
106 
107  /// @}
108  /// @name Iterators
109  /// @{
110 
111  iterator begin() const { return Data; }
112 
113  iterator end() const { return Data + Length; }
114 
115  const unsigned char *bytes_begin() const {
116  return reinterpret_cast<const unsigned char *>(begin());
117  }
118  const unsigned char *bytes_end() const {
119  return reinterpret_cast<const unsigned char *>(end());
120  }
122  return make_range(bytes_begin(), bytes_end());
123  }
124 
125  /// @}
126  /// @name String Operations
127  /// @{
128 
129  /// data - Get a pointer to the start of the string (which may not be null
130  /// terminated).
131  [[nodiscard]] const char *data() const { return Data; }
132 
133  /// empty - Check if the string is empty.
134  [[nodiscard]] constexpr bool empty() const { return Length == 0; }
135 
136  /// size - Get the string size.
137  [[nodiscard]] constexpr size_t size() const { return Length; }
138 
139  /// front - Get the first character in the string.
140  [[nodiscard]] char front() const {
141  assert(!empty());
142  return Data[0];
143  }
144 
145  /// back - Get the last character in the string.
146  [[nodiscard]] char back() const {
147  assert(!empty());
148  return Data[Length-1];
149  }
150 
151  // copy - Allocate copy in Allocator and return StringRef to it.
152  template <typename Allocator>
153  [[nodiscard]] StringRef copy(Allocator &A) const {
154  // Don't request a length 0 copy from the allocator.
155  if (empty())
156  return StringRef();
157  char *S = A.template Allocate<char>(Length);
158  std::copy(begin(), end(), S);
159  return StringRef(S, Length);
160  }
161 
162  /// equals - Check for string equality, this is more efficient than
163  /// compare() when the relative ordering of inequal strings isn't needed.
164  [[nodiscard]] bool equals(StringRef RHS) const {
165  return (Length == RHS.Length &&
166  compareMemory(Data, RHS.Data, RHS.Length) == 0);
167  }
168 
169  /// Check for string equality, ignoring case.
170  [[nodiscard]] bool equals_insensitive(StringRef RHS) const {
171  return Length == RHS.Length && compare_insensitive(RHS) == 0;
172  }
173 
174  /// compare - Compare two strings; the result is -1, 0, or 1 if this string
175  /// is lexicographically less than, equal to, or greater than the \p RHS.
176  [[nodiscard]] int compare(StringRef RHS) const {
177  // Check the prefix for a mismatch.
178  if (int Res = compareMemory(Data, RHS.Data, std::min(Length, RHS.Length)))
179  return Res < 0 ? -1 : 1;
180 
181  // Otherwise the prefixes match, so we only need to check the lengths.
182  if (Length == RHS.Length)
183  return 0;
184  return Length < RHS.Length ? -1 : 1;
185  }
186 
187  /// Compare two strings, ignoring case.
188  [[nodiscard]] int compare_insensitive(StringRef RHS) const;
189 
190  /// compare_numeric - Compare two strings, treating sequences of digits as
191  /// numbers.
192  [[nodiscard]] int compare_numeric(StringRef RHS) const;
193 
194  /// Determine the edit distance between this string and another
195  /// string.
196  ///
197  /// \param Other the string to compare this string against.
198  ///
199  /// \param AllowReplacements whether to allow character
200  /// replacements (change one character into another) as a single
201  /// operation, rather than as two operations (an insertion and a
202  /// removal).
203  ///
204  /// \param MaxEditDistance If non-zero, the maximum edit distance that
205  /// this routine is allowed to compute. If the edit distance will exceed
206  /// that maximum, returns \c MaxEditDistance+1.
207  ///
208  /// \returns the minimum number of character insertions, removals,
209  /// or (if \p AllowReplacements is \c true) replacements needed to
210  /// transform one of the given strings into the other. If zero,
211  /// the strings are identical.
212  [[nodiscard]] unsigned edit_distance(StringRef Other,
213  bool AllowReplacements = true,
214  unsigned MaxEditDistance = 0) const;
215 
216  [[nodiscard]] unsigned
217  edit_distance_insensitive(StringRef Other, bool AllowReplacements = true,
218  unsigned MaxEditDistance = 0) const;
219 
220  /// str - Get the contents as an std::string.
221  [[nodiscard]] std::string str() const {
222  if (!Data) return std::string();
223  return std::string(Data, Length);
224  }
225 
226  /// @}
227  /// @name Operator Overloads
228  /// @{
229 
230  [[nodiscard]] char operator[](size_t Index) const {
231  assert(Index < Length && "Invalid index!");
232  return Data[Index];
233  }
234 
235  /// Disallow accidental assignment from a temporary std::string.
236  ///
237  /// The declaration here is extra complicated so that `stringRef = {}`
238  /// and `stringRef = "abc"` continue to select the move assignment operator.
239  template <typename T>
240  std::enable_if_t<std::is_same<T, std::string>::value, StringRef> &
241  operator=(T &&Str) = delete;
242 
243  /// @}
244  /// @name Type Conversions
245  /// @{
246 
247  operator std::string_view() const {
248  return std::string_view(data(), size());
249  }
250 
251  /// @}
252  /// @name String Predicates
253  /// @{
254 
255  /// Check if this string starts with the given \p Prefix.
256  [[nodiscard]] bool starts_with(StringRef Prefix) const {
257  return Length >= Prefix.Length &&
258  compareMemory(Data, Prefix.Data, Prefix.Length) == 0;
259  }
260  [[nodiscard]] bool startswith(StringRef Prefix) const {
261  return starts_with(Prefix);
262  }
263 
264  /// Check if this string starts with the given \p Prefix, ignoring case.
265  [[nodiscard]] bool starts_with_insensitive(StringRef Prefix) const;
266  [[nodiscard]] bool startswith_insensitive(StringRef Prefix) const {
267  return starts_with_insensitive(Prefix);
268  }
269 
270  /// Check if this string ends with the given \p Suffix.
271  [[nodiscard]] bool ends_with(StringRef Suffix) const {
272  return Length >= Suffix.Length &&
273  compareMemory(end() - Suffix.Length, Suffix.Data, Suffix.Length) ==
274  0;
275  }
276  [[nodiscard]] bool endswith(StringRef Suffix) const {
277  return ends_with(Suffix);
278  }
279 
280  /// Check if this string ends with the given \p Suffix, ignoring case.
281  [[nodiscard]] bool ends_with_insensitive(StringRef Suffix) const;
282  [[nodiscard]] bool endswith_insensitive(StringRef Suffix) const {
283  return ends_with_insensitive(Suffix);
284  }
285 
286  /// @}
287  /// @name String Searching
288  /// @{
289 
290  /// Search for the first character \p C in the string.
291  ///
292  /// \returns The index of the first occurrence of \p C, or npos if not
293  /// found.
294  [[nodiscard]] size_t find(char C, size_t From = 0) const {
295  size_t FindBegin = std::min(From, Length);
296  if (FindBegin < Length) { // Avoid calling memchr with nullptr.
297  // Just forward to memchr, which is faster than a hand-rolled loop.
298  if (const void *P = ::memchr(Data + FindBegin, C, Length - FindBegin))
299  return static_cast<const char *>(P) - Data;
300  }
301  return npos;
302  }
303 
304  /// Search for the first character \p C in the string, ignoring case.
305  ///
306  /// \returns The index of the first occurrence of \p C, or npos if not
307  /// found.
308  [[nodiscard]] size_t find_insensitive(char C, size_t From = 0) const;
309 
310  /// Search for the first character satisfying the predicate \p F
311  ///
312  /// \returns The index of the first character satisfying \p F starting from
313  /// \p From, or npos if not found.
314  [[nodiscard]] size_t find_if(function_ref<bool(char)> F,
315  size_t From = 0) const {
316  StringRef S = drop_front(From);
317  while (!S.empty()) {
318  if (F(S.front()))
319  return size() - S.size();
320  S = S.drop_front();
321  }
322  return npos;
323  }
324 
325  /// Search for the first character not satisfying the predicate \p F
326  ///
327  /// \returns The index of the first character not satisfying \p F starting
328  /// from \p From, or npos if not found.
329  [[nodiscard]] size_t find_if_not(function_ref<bool(char)> F,
330  size_t From = 0) const {
331  return find_if([F](char c) { return !F(c); }, From);
332  }
333 
334  /// Search for the first string \p Str in the string.
335  ///
336  /// \returns The index of the first occurrence of \p Str, or npos if not
337  /// found.
338  [[nodiscard]] size_t find(StringRef Str, size_t From = 0) const;
339 
340  /// Search for the first string \p Str in the string, ignoring case.
341  ///
342  /// \returns The index of the first occurrence of \p Str, or npos if not
343  /// found.
344  [[nodiscard]] size_t find_insensitive(StringRef Str, size_t From = 0) const;
345 
346  /// Search for the last character \p C in the string.
347  ///
348  /// \returns The index of the last occurrence of \p C, or npos if not
349  /// found.
350  [[nodiscard]] size_t rfind(char C, size_t From = npos) const {
351  From = std::min(From, Length);
352  size_t i = From;
353  while (i != 0) {
354  --i;
355  if (Data[i] == C)
356  return i;
357  }
358  return npos;
359  }
360 
361  /// Search for the last character \p C in the string, ignoring case.
362  ///
363  /// \returns The index of the last occurrence of \p C, or npos if not
364  /// found.
365  [[nodiscard]] size_t rfind_insensitive(char C, size_t From = npos) const;
366 
367  /// Search for the last string \p Str in the string.
368  ///
369  /// \returns The index of the last occurrence of \p Str, or npos if not
370  /// found.
371  [[nodiscard]] size_t rfind(StringRef Str) const;
372 
373  /// Search for the last string \p Str in the string, ignoring case.
374  ///
375  /// \returns The index of the last occurrence of \p Str, or npos if not
376  /// found.
377  [[nodiscard]] size_t rfind_insensitive(StringRef Str) const;
378 
379  /// Find the first character in the string that is \p C, or npos if not
380  /// found. Same as find.
381  [[nodiscard]] size_t find_first_of(char C, size_t From = 0) const {
382  return find(C, From);
383  }
384 
385  /// Find the first character in the string that is in \p Chars, or npos if
386  /// not found.
387  ///
388  /// Complexity: O(size() + Chars.size())
389  [[nodiscard]] size_t find_first_of(StringRef Chars, size_t From = 0) const;
390 
391  /// Find the first character in the string that is not \p C or npos if not
392  /// found.
393  [[nodiscard]] size_t find_first_not_of(char C, size_t From = 0) const;
394 
395  /// Find the first character in the string that is not in the string
396  /// \p Chars, or npos if not found.
397  ///
398  /// Complexity: O(size() + Chars.size())
399  [[nodiscard]] size_t find_first_not_of(StringRef Chars,
400  size_t From = 0) const;
401 
402  /// Find the last character in the string that is \p C, or npos if not
403  /// found.
404  [[nodiscard]] size_t find_last_of(char C, size_t From = npos) const {
405  return rfind(C, From);
406  }
407 
408  /// Find the last character in the string that is in \p C, or npos if not
409  /// found.
410  ///
411  /// Complexity: O(size() + Chars.size())
412  [[nodiscard]] size_t find_last_of(StringRef Chars,
413  size_t From = npos) const;
414 
415  /// Find the last character in the string that is not \p C, or npos if not
416  /// found.
417  [[nodiscard]] size_t find_last_not_of(char C, size_t From = npos) const;
418 
419  /// Find the last character in the string that is not in \p Chars, or
420  /// npos if not found.
421  ///
422  /// Complexity: O(size() + Chars.size())
423  [[nodiscard]] size_t find_last_not_of(StringRef Chars,
424  size_t From = npos) const;
425 
426  /// Return true if the given string is a substring of *this, and false
427  /// otherwise.
428  [[nodiscard]] bool contains(StringRef Other) const {
429  return find(Other) != npos;
430  }
431 
432  /// Return true if the given character is contained in *this, and false
433  /// otherwise.
434  [[nodiscard]] bool contains(char C) const {
435  return find_first_of(C) != npos;
436  }
437 
438  /// Return true if the given string is a substring of *this, and false
439  /// otherwise.
440  [[nodiscard]] bool contains_insensitive(StringRef Other) const {
441  return find_insensitive(Other) != npos;
442  }
443 
444  /// Return true if the given character is contained in *this, and false
445  /// otherwise.
446  [[nodiscard]] bool contains_insensitive(char C) const {
447  return find_insensitive(C) != npos;
448  }
449 
450  /// @}
451  /// @name Helpful Algorithms
452  /// @{
453 
454  /// Return the number of occurrences of \p C in the string.
455  [[nodiscard]] size_t count(char C) const {
456  size_t Count = 0;
457  for (size_t i = 0, e = Length; i != e; ++i)
458  if (Data[i] == C)
459  ++Count;
460  return Count;
461  }
462 
463  /// Return the number of non-overlapped occurrences of \p Str in
464  /// the string.
465  size_t count(StringRef Str) const;
466 
467  /// Parse the current string as an integer of the specified radix. If
468  /// \p Radix is specified as zero, this does radix autosensing using
469  /// extended C rules: 0 is octal, 0x is hex, 0b is binary.
470  ///
471  /// If the string is invalid or if only a subset of the string is valid,
472  /// this returns true to signify the error. The string is considered
473  /// erroneous if empty or if it overflows T.
474  template <typename T> bool getAsInteger(unsigned Radix, T &Result) const {
475  if constexpr (std::numeric_limits<T>::is_signed) {
476  long long LLVal;
477  if (getAsSignedInteger(*this, Radix, LLVal) ||
478  static_cast<T>(LLVal) != LLVal)
479  return true;
480  Result = LLVal;
481  } else {
482  unsigned long long ULLVal;
483  // The additional cast to unsigned long long is required to avoid the
484  // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type
485  // 'unsigned __int64' when instantiating getAsInteger with T = bool.
486  if (getAsUnsignedInteger(*this, Radix, ULLVal) ||
487  static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal)
488  return true;
489  Result = ULLVal;
490  }
491  return false;
492  }
493 
494  /// Parse the current string as an integer of the specified radix. If
495  /// \p Radix is specified as zero, this does radix autosensing using
496  /// extended C rules: 0 is octal, 0x is hex, 0b is binary.
497  ///
498  /// If the string does not begin with a number of the specified radix,
499  /// this returns true to signify the error. The string is considered
500  /// erroneous if empty or if it overflows T.
501  /// The portion of the string representing the discovered numeric value
502  /// is removed from the beginning of the string.
503  template <typename T> bool consumeInteger(unsigned Radix, T &Result) {
504  if constexpr (std::numeric_limits<T>::is_signed) {
505  long long LLVal;
506  if (consumeSignedInteger(*this, Radix, LLVal) ||
507  static_cast<long long>(static_cast<T>(LLVal)) != LLVal)
508  return true;
509  Result = LLVal;
510  } else {
511  unsigned long long ULLVal;
512  if (consumeUnsignedInteger(*this, Radix, ULLVal) ||
513  static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal)
514  return true;
515  Result = ULLVal;
516  }
517  return false;
518  }
519 
520  /// Parse the current string as an integer of the specified \p Radix, or of
521  /// an autosensed radix if the \p Radix given is 0. The current value in
522  /// \p Result is discarded, and the storage is changed to be wide enough to
523  /// store the parsed integer.
524  ///
525  /// \returns true if the string does not solely consist of a valid
526  /// non-empty number in the appropriate base.
527  ///
528  /// APInt::fromString is superficially similar but assumes the
529  /// string is well-formed in the given radix.
530  bool getAsInteger(unsigned Radix, APInt &Result) const;
531 
532  /// Parse the current string as an IEEE double-precision floating
533  /// point value. The string must be a well-formed double.
534  ///
535  /// If \p AllowInexact is false, the function will fail if the string
536  /// cannot be represented exactly. Otherwise, the function only fails
537  /// in case of an overflow or underflow, or an invalid floating point
538  /// representation.
539  bool getAsDouble(double &Result, bool AllowInexact = true) const;
540 
541  /// @}
542  /// @name String Operations
543  /// @{
544 
545  // Convert the given ASCII string to lowercase.
546  [[nodiscard]] std::string lower() const;
547 
548  /// Convert the given ASCII string to uppercase.
549  [[nodiscard]] std::string upper() const;
550 
551  /// @}
552  /// @name Substring Operations
553  /// @{
554 
555  /// Return a reference to the substring from [Start, Start + N).
556  ///
557  /// \param Start The index of the starting character in the substring; if
558  /// the index is npos or greater than the length of the string then the
559  /// empty substring will be returned.
560  ///
561  /// \param N The number of characters to included in the substring. If N
562  /// exceeds the number of characters remaining in the string, the string
563  /// suffix (starting with \p Start) will be returned.
564  [[nodiscard]] constexpr StringRef substr(size_t Start,
565  size_t N = npos) const {
566  Start = std::min(Start, Length);
567  return StringRef(Data + Start, std::min(N, Length - Start));
568  }
569 
570  /// Return a StringRef equal to 'this' but with only the first \p N
571  /// elements remaining. If \p N is greater than the length of the
572  /// string, the entire string is returned.
573  [[nodiscard]] StringRef take_front(size_t N = 1) const {
574  if (N >= size())
575  return *this;
576  return drop_back(size() - N);
577  }
578 
579  /// Return a StringRef equal to 'this' but with only the last \p N
580  /// elements remaining. If \p N is greater than the length of the
581  /// string, the entire string is returned.
582  [[nodiscard]] StringRef take_back(size_t N = 1) const {
583  if (N >= size())
584  return *this;
585  return drop_front(size() - N);
586  }
587 
588  /// Return the longest prefix of 'this' such that every character
589  /// in the prefix satisfies the given predicate.
590  [[nodiscard]] StringRef take_while(function_ref<bool(char)> F) const {
591  return substr(0, find_if_not(F));
592  }
593 
594  /// Return the longest prefix of 'this' such that no character in
595  /// the prefix satisfies the given predicate.
596  [[nodiscard]] StringRef take_until(function_ref<bool(char)> F) const {
597  return substr(0, find_if(F));
598  }
599 
600  /// Return a StringRef equal to 'this' but with the first \p N elements
601  /// dropped.
602  [[nodiscard]] StringRef drop_front(size_t N = 1) const {
603  assert(size() >= N && "Dropping more elements than exist");
604  return substr(N);
605  }
606 
607  /// Return a StringRef equal to 'this' but with the last \p N elements
608  /// dropped.
609  [[nodiscard]] StringRef drop_back(size_t N = 1) const {
610  assert(size() >= N && "Dropping more elements than exist");
611  return substr(0, size()-N);
612  }
613 
614  /// Return a StringRef equal to 'this', but with all characters satisfying
615  /// the given predicate dropped from the beginning of the string.
616  [[nodiscard]] StringRef drop_while(function_ref<bool(char)> F) const {
617  return substr(find_if_not(F));
618  }
619 
620  /// Return a StringRef equal to 'this', but with all characters not
621  /// satisfying the given predicate dropped from the beginning of the string.
622  [[nodiscard]] StringRef drop_until(function_ref<bool(char)> F) const {
623  return substr(find_if(F));
624  }
625 
626  /// Returns true if this StringRef has the given prefix and removes that
627  /// prefix.
629  if (!starts_with(Prefix))
630  return false;
631 
632  *this = drop_front(Prefix.size());
633  return true;
634  }
635 
636  /// Returns true if this StringRef has the given prefix, ignoring case,
637  /// and removes that prefix.
639  if (!startswith_insensitive(Prefix))
640  return false;
641 
642  *this = drop_front(Prefix.size());
643  return true;
644  }
645 
646  /// Returns true if this StringRef has the given suffix and removes that
647  /// suffix.
648  bool consume_back(StringRef Suffix) {
649  if (!ends_with(Suffix))
650  return false;
651 
652  *this = drop_back(Suffix.size());
653  return true;
654  }
655 
656  /// Returns true if this StringRef has the given suffix, ignoring case,
657  /// and removes that suffix.
659  if (!endswith_insensitive(Suffix))
660  return false;
661 
662  *this = drop_back(Suffix.size());
663  return true;
664  }
665 
666  /// Return a reference to the substring from [Start, End).
667  ///
668  /// \param Start The index of the starting character in the substring; if
669  /// the index is npos or greater than the length of the string then the
670  /// empty substring will be returned.
671  ///
672  /// \param End The index following the last character to include in the
673  /// substring. If this is npos or exceeds the number of characters
674  /// remaining in the string, the string suffix (starting with \p Start)
675  /// will be returned. If this is less than \p Start, an empty string will
676  /// be returned.
677  [[nodiscard]] StringRef slice(size_t Start, size_t End) const {
678  Start = std::min(Start, Length);
679  End = std::min(std::max(Start, End), Length);
680  return StringRef(Data + Start, End - Start);
681  }
682 
683  /// Split into two substrings around the first occurrence of a separator
684  /// character.
685  ///
686  /// If \p Separator is in the string, then the result is a pair (LHS, RHS)
687  /// such that (*this == LHS + Separator + RHS) is true and RHS is
688  /// maximal. If \p Separator is not in the string, then the result is a
689  /// pair (LHS, RHS) where (*this == LHS) and (RHS == "").
690  ///
691  /// \param Separator The character to split on.
692  /// \returns The split substrings.
693  [[nodiscard]] std::pair<StringRef, StringRef> split(char Separator) const {
694  return split(StringRef(&Separator, 1));
695  }
696 
697  /// Split into two substrings around the first occurrence of a separator
698  /// string.
699  ///
700  /// If \p Separator is in the string, then the result is a pair (LHS, RHS)
701  /// such that (*this == LHS + Separator + RHS) is true and RHS is
702  /// maximal. If \p Separator is not in the string, then the result is a
703  /// pair (LHS, RHS) where (*this == LHS) and (RHS == "").
704  ///
705  /// \param Separator - The string to split on.
706  /// \return - The split substrings.
707  [[nodiscard]] std::pair<StringRef, StringRef>
708  split(StringRef Separator) const {
709  size_t Idx = find(Separator);
710  if (Idx == npos)
711  return std::make_pair(*this, StringRef());
712  return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos));
713  }
714 
715  /// Split into two substrings around the last occurrence of a separator
716  /// string.
717  ///
718  /// If \p Separator is in the string, then the result is a pair (LHS, RHS)
719  /// such that (*this == LHS + Separator + RHS) is true and RHS is
720  /// minimal. If \p Separator is not in the string, then the result is a
721  /// pair (LHS, RHS) where (*this == LHS) and (RHS == "").
722  ///
723  /// \param Separator - The string to split on.
724  /// \return - The split substrings.
725  [[nodiscard]] std::pair<StringRef, StringRef>
726  rsplit(StringRef Separator) const {
727  size_t Idx = rfind(Separator);
728  if (Idx == npos)
729  return std::make_pair(*this, StringRef());
730  return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos));
731  }
732 
733  /// Split into substrings around the occurrences of a separator string.
734  ///
735  /// Each substring is stored in \p A. If \p MaxSplit is >= 0, at most
736  /// \p MaxSplit splits are done and consequently <= \p MaxSplit + 1
737  /// elements are added to A.
738  /// If \p KeepEmpty is false, empty strings are not added to \p A. They
739  /// still count when considering \p MaxSplit
740  /// An useful invariant is that
741  /// Separator.join(A) == *this if MaxSplit == -1 and KeepEmpty == true
742  ///
743  /// \param A - Where to put the substrings.
744  /// \param Separator - The string to split on.
745  /// \param MaxSplit - The maximum number of times the string is split.
746  /// \param KeepEmpty - True if empty substring should be added.
748  StringRef Separator, int MaxSplit = -1,
749  bool KeepEmpty = true) const;
750 
751  /// Split into substrings around the occurrences of a separator character.
752  ///
753  /// Each substring is stored in \p A. If \p MaxSplit is >= 0, at most
754  /// \p MaxSplit splits are done and consequently <= \p MaxSplit + 1
755  /// elements are added to A.
756  /// If \p KeepEmpty is false, empty strings are not added to \p A. They
757  /// still count when considering \p MaxSplit
758  /// An useful invariant is that
759  /// Separator.join(A) == *this if MaxSplit == -1 and KeepEmpty == true
760  ///
761  /// \param A - Where to put the substrings.
762  /// \param Separator - The string to split on.
763  /// \param MaxSplit - The maximum number of times the string is split.
764  /// \param KeepEmpty - True if empty substring should be added.
765  void split(SmallVectorImpl<StringRef> &A, char Separator, int MaxSplit = -1,
766  bool KeepEmpty = true) const;
767 
768  /// Split into two substrings around the last occurrence of a separator
769  /// character.
770  ///
771  /// If \p Separator is in the string, then the result is a pair (LHS, RHS)
772  /// such that (*this == LHS + Separator + RHS) is true and RHS is
773  /// minimal. If \p Separator is not in the string, then the result is a
774  /// pair (LHS, RHS) where (*this == LHS) and (RHS == "").
775  ///
776  /// \param Separator - The character to split on.
777  /// \return - The split substrings.
778  [[nodiscard]] std::pair<StringRef, StringRef> rsplit(char Separator) const {
779  return rsplit(StringRef(&Separator, 1));
780  }
781 
782  /// Return string with consecutive \p Char characters starting from the
783  /// the left removed.
784  [[nodiscard]] StringRef ltrim(char Char) const {
785  return drop_front(std::min(Length, find_first_not_of(Char)));
786  }
787 
788  /// Return string with consecutive characters in \p Chars starting from
789  /// the left removed.
790  [[nodiscard]] StringRef ltrim(StringRef Chars = " \t\n\v\f\r") const {
791  return drop_front(std::min(Length, find_first_not_of(Chars)));
792  }
793 
794  /// Return string with consecutive \p Char characters starting from the
795  /// right removed.
796  [[nodiscard]] StringRef rtrim(char Char) const {
797  return drop_back(Length - std::min(Length, find_last_not_of(Char) + 1));
798  }
799 
800  /// Return string with consecutive characters in \p Chars starting from
801  /// the right removed.
802  [[nodiscard]] StringRef rtrim(StringRef Chars = " \t\n\v\f\r") const {
803  return drop_back(Length - std::min(Length, find_last_not_of(Chars) + 1));
804  }
805 
806  /// Return string with consecutive \p Char characters starting from the
807  /// left and right removed.
808  [[nodiscard]] StringRef trim(char Char) const {
809  return ltrim(Char).rtrim(Char);
810  }
811 
812  /// Return string with consecutive characters in \p Chars starting from
813  /// the left and right removed.
814  [[nodiscard]] StringRef trim(StringRef Chars = " \t\n\v\f\r") const {
815  return ltrim(Chars).rtrim(Chars);
816  }
817 
818  /// Detect the line ending style of the string.
819  ///
820  /// If the string contains a line ending, return the line ending character
821  /// sequence that is detected. Otherwise return '\n' for unix line endings.
822  ///
823  /// \return - The line ending character sequence.
824  [[nodiscard]] StringRef detectEOL() const {
825  size_t Pos = find('\r');
826  if (Pos == npos) {
827  // If there is no carriage return, assume unix
828  return "\n";
829  }
830  if (Pos + 1 < Length && Data[Pos + 1] == '\n')
831  return "\r\n"; // Windows
832  if (Pos > 0 && Data[Pos - 1] == '\n')
833  return "\n\r"; // You monster!
834  return "\r"; // Classic Mac
835  }
836  /// @}
837  };
838 
839  /// A wrapper around a string literal that serves as a proxy for constructing
840  /// global tables of StringRefs with the length computed at compile time.
841  /// In order to avoid the invocation of a global constructor, StringLiteral
842  /// should *only* be used in a constexpr context, as such:
843  ///
844  /// constexpr StringLiteral S("test");
845  ///
846  class StringLiteral : public StringRef {
847  private:
848  constexpr StringLiteral(const char *Str, size_t N) : StringRef(Str, N) {
849  }
850 
851  public:
852  template <size_t N>
853  constexpr StringLiteral(const char (&Str)[N])
854 #if defined(__clang__) && __has_attribute(enable_if)
855 #pragma clang diagnostic push
856 #pragma clang diagnostic ignored "-Wgcc-compat"
857  __attribute((enable_if(__builtin_strlen(Str) == N - 1,
858  "invalid string literal")))
859 #pragma clang diagnostic pop
860 #endif
861  : StringRef(Str, N - 1) {
862  }
863 
864  // Explicit construction for strings like "foo\0bar".
865  template <size_t N>
866  static constexpr StringLiteral withInnerNUL(const char (&Str)[N]) {
867  return StringLiteral(Str, N - 1);
868  }
869  };
870 
871  /// @name StringRef Comparison Operators
872  /// @{
873 
875  return LHS.equals(RHS);
876  }
877 
878  inline bool operator!=(StringRef LHS, StringRef RHS) { return !(LHS == RHS); }
879 
881  return LHS.compare(RHS) == -1;
882  }
883 
885  return LHS.compare(RHS) != 1;
886  }
887 
889  return LHS.compare(RHS) == 1;
890  }
891 
893  return LHS.compare(RHS) != -1;
894  }
895 
896  inline std::string &operator+=(std::string &buffer, StringRef string) {
897  return buffer.append(string.data(), string.size());
898  }
899 
900  /// @}
901 
902  /// Compute a hash_code for a StringRef.
903  [[nodiscard]] hash_code hash_value(StringRef S);
904 
905  // Provide DenseMapInfo for StringRefs.
906  template <> struct DenseMapInfo<StringRef, void> {
907  static inline StringRef getEmptyKey() {
908  return StringRef(
909  reinterpret_cast<const char *>(~static_cast<uintptr_t>(0)), 0);
910  }
911 
912  static inline StringRef getTombstoneKey() {
913  return StringRef(
914  reinterpret_cast<const char *>(~static_cast<uintptr_t>(1)), 0);
915  }
916 
917  static unsigned getHashValue(StringRef Val);
918 
920  if (RHS.data() == getEmptyKey().data())
921  return LHS.data() == getEmptyKey().data();
922  if (RHS.data() == getTombstoneKey().data())
923  return LHS.data() == getTombstoneKey().data();
924  return LHS == RHS;
925  }
926  };
927 
928 } // end namespace llvm
929 
930 #endif // LLVM_ADT_STRINGREF_H
i
i
Definition: README.txt:29
llvm::sys::path::starts_with
static bool starts_with(StringRef Path, StringRef Prefix, Style style=Style::native)
Definition: Path.cpp:499
llvm::StringRef::take_front
StringRef take_front(size_t N=1) const
Return a StringRef equal to 'this' but with only the first N elements remaining.
Definition: StringRef.h:573
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::make_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Definition: iterator_range.h:53
llvm::StringRef::rfind
size_t rfind(char C, size_t From=npos) const
Search for the last character C in the string.
Definition: StringRef.h:350
llvm::cl::Prefix
@ Prefix
Definition: CommandLine.h:161
llvm::StringRef::consumeInteger
bool consumeInteger(unsigned Radix, T &Result)
Parse the current string as an integer of the specified radix.
Definition: StringRef.h:503
llvm::StringRef::trim
StringRef trim(char Char) const
Return string with consecutive Char characters starting from the left and right removed.
Definition: StringRef.h:808
llvm::StringRef::compare
int compare(StringRef RHS) const
compare - Compare two strings; the result is -1, 0, or 1 if this string is lexicographically less tha...
Definition: StringRef.h:176
llvm::StringRef::front
char front() const
front - Get the first character in the string.
Definition: StringRef.h:140
llvm::operator<=
bool operator<=(int64_t V1, const APSInt &V2)
Definition: APSInt.h:345
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::StringRef::StringRef
constexpr StringRef(std::string_view Str)
Construct a string ref from an std::string_view.
Definition: StringRef.h:104
llvm::StringRef::startswith_insensitive
bool startswith_insensitive(StringRef Prefix) const
Definition: StringRef.h:266
memcmp
Merge contiguous icmps into a memcmp
Definition: MergeICmps.cpp:907
llvm::StringRef::consume_front
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Definition: StringRef.h:628
split
static Error split(StringRef Str, char Separator, std::pair< StringRef, StringRef > &Split)
Checked version of split, to ensure mandatory subparts.
Definition: DataLayout.cpp:219
llvm::StringRef::find_first_of
size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
Definition: StringRef.h:381
llvm::StringRef::StringRef
constexpr StringRef(const char *data, size_t length)
Construct a string ref from a pointer and length.
Definition: StringRef.h:96
llvm::DenseMapInfo< StringRef, void >::getTombstoneKey
static StringRef getTombstoneKey()
Definition: StringRef.h:912
llvm::sys::path::end
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:235
llvm::sys::path::begin
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:226
llvm::operator!=
bool operator!=(uint64_t V1, const APInt &V2)
Definition: APInt.h:2012
llvm::StringRef::ends_with
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
Definition: StringRef.h:271
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::StringRef::ltrim
StringRef ltrim(StringRef Chars=" \t\n\v\f\r") const
Return string with consecutive characters in Chars starting from the left removed.
Definition: StringRef.h:790
llvm::max
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:337
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
endif
__FakeVCSRevision h endif() endif() set(generated_files "$
Definition: CMakeLists.txt:16
size_t
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::consumeSignedInteger
bool consumeSignedInteger(StringRef &Str, unsigned Radix, long long &Result)
Definition: StringRef.cpp:474
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
llvm::DenseMapInfo
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: APInt.h:34
llvm::StringLiteral
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Definition: StringRef.h:846
llvm::StringRef::startswith
bool startswith(StringRef Prefix) const
Definition: StringRef.h:260
llvm::StringRef::contains
bool contains(char C) const
Return true if the given character is contained in *this, and false otherwise.
Definition: StringRef.h:434
llvm::StringLiteral::withInnerNUL
static constexpr StringLiteral withInnerNUL(const char(&Str)[N])
Definition: StringRef.h:866
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::StringRef::rsplit
std::pair< StringRef, StringRef > rsplit(char Separator) const
Split into two substrings around the last occurrence of a separator character.
Definition: StringRef.h:778
llvm::getAsUnsignedInteger
bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result)
Helper functions for StringRef::getAsInteger.
Definition: StringRef.cpp:504
llvm::operator+=
std::string & operator+=(std::string &buffer, StringRef string)
Definition: StringRef.h:896
llvm::StringRef::contains_insensitive
bool contains_insensitive(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition: StringRef.h:440
llvm::StringRef::getAsInteger
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
Definition: StringRef.h:474
llvm::StringRef::iterator
const char * iterator
Definition: StringRef.h:54
llvm::StringRef::substr
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:564
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
llvm::StringRef::take_until
StringRef take_until(function_ref< bool(char)> F) const
Return the longest prefix of 'this' such that no character in the prefix satisfies the given predicat...
Definition: StringRef.h:596
llvm::StringRef::drop_until
StringRef drop_until(function_ref< bool(char)> F) const
Return a StringRef equal to 'this', but with all characters not satisfying the given predicate droppe...
Definition: StringRef.h:622
llvm::StringRef::data
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:131
STLFunctionalExtras.h
llvm::StringRef::starts_with
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:256
else
else
Definition: README.txt:179
c
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only and the condition codes are not remembered when the same two values are compared twice More LSR enhancements i8 and i32 load store addressing modes are identical int int c
Definition: README.txt:418
llvm::StringRef::slice
StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
Definition: StringRef.h:677
llvm::StringRef::equals
bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
Definition: StringRef.h:164
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLFunctionalExtras.h:36
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
llvm::StringRef::contains_insensitive
bool contains_insensitive(char C) const
Return true if the given character is contained in *this, and false otherwise.
Definition: StringRef.h:446
llvm::StringRef::StringRef
StringRef(const std::string &Str)
Construct a string ref from an std::string.
Definition: StringRef.h:100
llvm::operator>=
bool operator>=(int64_t V1, const APSInt &V2)
Definition: APSInt.h:346
llvm::count
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
Definition: STLExtras.h:1895
Index
uint32_t Index
Definition: ELFObjHandler.cpp:83
llvm::StringRef::end
iterator end() const
Definition: StringRef.h:113
llvm::StringRef::detectEOL
StringRef detectEOL() const
Detect the line ending style of the string.
Definition: StringRef.h:824
llvm::find
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1754
llvm::consumeUnsignedInteger
bool consumeUnsignedInteger(StringRef &Str, unsigned Radix, unsigned long long &Result)
Definition: StringRef.cpp:426
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:53
llvm::StringRef::rtrim
StringRef rtrim(char Char) const
Return string with consecutive Char characters starting from the right removed.
Definition: StringRef.h:796
llvm::operator<
bool operator<(int64_t V1, const APSInt &V2)
Definition: APSInt.h:347
llvm::DenseMapInfo< StringRef, void >::isEqual
static bool isEqual(StringRef LHS, StringRef RHS)
Definition: StringRef.h:919
llvm::StringRef::trim
StringRef trim(StringRef Chars=" \t\n\v\f\r") const
Return string with consecutive characters in Chars starting from the left and right removed.
Definition: StringRef.h:814
llvm::StringRef::ltrim
StringRef ltrim(char Char) const
Return string with consecutive Char characters starting from the the left removed.
Definition: StringRef.h:784
llvm::StringRef::StringRef
constexpr StringRef(const char *Str)
Construct a string ref from a cstring.
Definition: StringRef.h:84
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::operator==
bool operator==(uint64_t V1, const APInt &V2)
Definition: APInt.h:2010
iterator_range.h
llvm::StringRef::bytes_begin
const unsigned char * bytes_begin() const
Definition: StringRef.h:115
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:75
llvm::size
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition: STLExtras.h:1715
llvm::StringRef::take_back
StringRef take_back(size_t N=1) const
Return a StringRef equal to 'this' but with only the last N elements remaining.
Definition: StringRef.h:582
llvm::StringRef::rtrim
StringRef rtrim(StringRef Chars=" \t\n\v\f\r") const
Return string with consecutive characters in Chars starting from the right removed.
Definition: StringRef.h:802
llvm::min
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:357
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::StringRef::rsplit
std::pair< StringRef, StringRef > rsplit(StringRef Separator) const
Split into two substrings around the last occurrence of a separator string.
Definition: StringRef.h:726
if
if(llvm_vc STREQUAL "") set(fake_version_inc "$
Definition: CMakeLists.txt:14
Compiler.h
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::DenseMapInfo< StringRef, void >::getEmptyKey
static StringRef getEmptyKey()
Definition: StringRef.h:907
llvm::StringRef::split
std::pair< StringRef, StringRef > split(StringRef Separator) const
Split into two substrings around the first occurrence of a separator string.
Definition: StringRef.h:708
llvm::StringRef::find_last_of
size_t find_last_of(char C, size_t From=npos) const
Find the last character in the string that is C, or npos if not found.
Definition: StringRef.h:404
llvm::StringRef::count
size_t count(char C) const
Return the number of occurrences of C in the string.
Definition: StringRef.h:455
llvm::StringRef::StringRef
StringRef()=default
Construct an empty string ref.
llvm::find_if
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1761
llvm::StringRef::size
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:137
std
Definition: BitVector.h:851
llvm::StringRef::endswith
bool endswith(StringRef Suffix) const
Definition: StringRef.h:276
llvm::StringLiteral::StringLiteral
constexpr StringLiteral(const char(&Str)[N])
Definition: StringRef.h:853
llvm::StringRef::bytes
iterator_range< const unsigned char * > bytes() const
Definition: StringRef.h:121
llvm::StringRef::find_if_not
size_t find_if_not(function_ref< bool(char)> F, size_t From=0) const
Search for the first character not satisfying the predicate F.
Definition: StringRef.h:329
LLVM_GSL_POINTER
#define LLVM_GSL_POINTER
LLVM_GSL_POINTER - Apply this to non-owning classes like StringRef to enable lifetime warnings.
Definition: Compiler.h:295
llvm::StringRef::take_while
StringRef take_while(function_ref< bool(char)> F) const
Return the longest prefix of 'this' such that every character in the prefix satisfies the given predi...
Definition: StringRef.h:590
llvm::StringRef::find_if
size_t find_if(function_ref< bool(char)> F, size_t From=0) const
Search for the first character satisfying the predicate F.
Definition: StringRef.h:314
llvm::StringRef::contains
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition: StringRef.h:428
llvm::hash_value
hash_code hash_value(const FixedPointSemantics &Val)
Definition: APFixedPoint.h:127
llvm::getAsSignedInteger
bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result)
Definition: StringRef.cpp:514
llvm::StringRef::equals_insensitive
bool equals_insensitive(StringRef RHS) const
Check for string equality, ignoring case.
Definition: StringRef.h:170
Allocator
Basic Register Allocator
Definition: RegAllocBasic.cpp:143
llvm::StringRef::consume_back
bool consume_back(StringRef Suffix)
Returns true if this StringRef has the given suffix and removes that suffix.
Definition: StringRef.h:648
N
#define N
llvm::StringRef::const_iterator
const char * const_iterator
Definition: StringRef.h:55
llvm::operator>
bool operator>(int64_t V1, const APSInt &V2)
Definition: APSInt.h:348
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::StringRef::back
char back() const
back - Get the last character in the string.
Definition: StringRef.h:146
llvm::SmallVectorImpl< StringRef >
DenseMapInfo.h
llvm::StringRef::str
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:221
llvm::StringRef::find
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Definition: StringRef.h:294
substr
static StringRef substr(StringRef Str, uint64_t Len)
Definition: SimplifyLibCalls.cpp:299
From
BlockVerifier::State From
Definition: BlockVerifier.cpp:55
llvm::StringRef::consume_back_insensitive
bool consume_back_insensitive(StringRef Suffix)
Returns true if this StringRef has the given suffix, ignoring case, and removes that suffix.
Definition: StringRef.h:658
llvm::StringRef::operator[]
char operator[](size_t Index) const
Definition: StringRef.h:230
llvm::StringRef::begin
iterator begin() const
Definition: StringRef.h:111
copy
we should consider alternate ways to model stack dependencies Lots of things could be done in WebAssemblyTargetTransformInfo cpp there are numerous optimization related hooks that can be overridden in WebAssemblyTargetLowering Instead of the OptimizeReturned which should consider preserving the returned attribute through to MachineInstrs and extending the MemIntrinsicResults pass to do this optimization on calls too That would also let the WebAssemblyPeephole pass clean up dead defs for such as it does for stores Consider implementing and or getMachineCombinerPatterns Find a clean way to fix the problem which leads to the Shrink Wrapping pass being run after the WebAssembly PEI pass When setting multiple variables to the same we currently get code like const It could be done with a smaller encoding like local tee $pop5 local copy
Definition: README.txt:101
llvm::StringRef::copy
StringRef copy(Allocator &A) const
Definition: StringRef.h:153
llvm::StringRef::split
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition: StringRef.h:693
llvm::find_if_not
auto find_if_not(R &&Range, UnaryPredicate P)
Definition: STLExtras.h:1766
llvm::StringRef::drop_while
StringRef drop_while(function_ref< bool(char)> F) const
Return a StringRef equal to 'this', but with all characters satisfying the given predicate dropped fr...
Definition: StringRef.h:616
llvm::StringRef::drop_front
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
Definition: StringRef.h:602
llvm::StringRef::drop_back
StringRef drop_back(size_t N=1) const
Return a StringRef equal to 'this' but with the last N elements dropped.
Definition: StringRef.h:609
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1251
llvm::StringRef::bytes_end
const unsigned char * bytes_end() const
Definition: StringRef.h:118
llvm::StringRef::endswith_insensitive
bool endswith_insensitive(StringRef Suffix) const
Definition: StringRef.h:282
llvm::StringRef::consume_front_insensitive
bool consume_front_insensitive(StringRef Prefix)
Returns true if this StringRef has the given prefix, ignoring case, and removes that prefix.
Definition: StringRef.h:638