LLVM  14.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/STLExtras.h"
14 #include "llvm/Support/Compiler.h"
15 #include <algorithm>
16 #include <cassert>
17 #include <cstddef>
18 #include <cstring>
19 #include <limits>
20 #include <string>
21 #if __cplusplus > 201402L
22 #include <string_view>
23 #endif
24 #include <type_traits>
25 #include <utility>
26 
27 // Declare the __builtin_strlen intrinsic for MSVC so it can be used in
28 // constexpr context.
29 #if defined(_MSC_VER)
30 extern "C" size_t __builtin_strlen(const char *);
31 #endif
32 
33 namespace llvm {
34 
35  class APInt;
36  class hash_code;
37  template <typename T> class SmallVectorImpl;
38  class StringRef;
39 
40  /// Helper functions for StringRef::getAsInteger.
41  bool getAsUnsignedInteger(StringRef Str, unsigned Radix,
42  unsigned long long &Result);
43 
44  bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result);
45 
46  bool consumeUnsignedInteger(StringRef &Str, unsigned Radix,
47  unsigned long long &Result);
48  bool consumeSignedInteger(StringRef &Str, unsigned Radix, long long &Result);
49 
50  /// StringRef - Represent a constant reference to a string, i.e. a character
51  /// array and a length, which need not be null terminated.
52  ///
53  /// This class does not own the string data, it is expected to be used in
54  /// situations where the character data resides in some other buffer, whose
55  /// lifetime extends past that of the StringRef. For this reason, it is not in
56  /// general safe to store a StringRef.
58  public:
59  static constexpr size_t npos = ~size_t(0);
60 
61  using iterator = const char *;
62  using const_iterator = const char *;
63  using size_type = size_t;
64 
65  private:
66  /// The start of the string, in an external buffer.
67  const char *Data = nullptr;
68 
69  /// The length of the string.
70  size_t Length = 0;
71 
72  // Workaround memcmp issue with null pointers (undefined behavior)
73  // by providing a specialized version
74  static int compareMemory(const char *Lhs, const char *Rhs, size_t Length) {
75  if (Length == 0) { return 0; }
76  return ::memcmp(Lhs,Rhs,Length);
77  }
78 
79  // Constexpr version of std::strlen.
80  static constexpr size_t strLen(const char *Str) {
81 #if __cplusplus > 201402L
82  return std::char_traits<char>::length(Str);
83 #elif __has_builtin(__builtin_strlen) || defined(__GNUC__) || \
84  (defined(_MSC_VER) && _MSC_VER >= 1916)
85  return __builtin_strlen(Str);
86 #else
87  const char *Begin = Str;
88  while (*Str != '\0')
89  ++Str;
90  return Str - Begin;
91 #endif
92  }
93 
94  public:
95  /// @name Constructors
96  /// @{
97 
98  /// Construct an empty string ref.
99  /*implicit*/ StringRef() = default;
100 
101  /// Disable conversion from nullptr. This prevents things like
102  /// if (S == nullptr)
103  StringRef(std::nullptr_t) = delete;
104 
105  /// Construct a string ref from a cstring.
106  /*implicit*/ constexpr StringRef(const char *Str)
107  : Data(Str), Length(Str ? strLen(Str) : 0) {}
108 
109  /// Construct a string ref from a pointer and length.
110  /*implicit*/ constexpr StringRef(const char *data, size_t length)
111  : Data(data), Length(length) {}
112 
113  /// Construct a string ref from an std::string.
114  /*implicit*/ StringRef(const std::string &Str)
115  : Data(Str.data()), Length(Str.length()) {}
116 
117 #if __cplusplus > 201402L
118  /// Construct a string ref from an std::string_view.
119  /*implicit*/ constexpr StringRef(std::string_view Str)
120  : Data(Str.data()), Length(Str.size()) {}
121 #endif
122 
123  /// @}
124  /// @name Iterators
125  /// @{
126 
127  iterator begin() const { return Data; }
128 
129  iterator end() const { return Data + Length; }
130 
131  const unsigned char *bytes_begin() const {
132  return reinterpret_cast<const unsigned char *>(begin());
133  }
134  const unsigned char *bytes_end() const {
135  return reinterpret_cast<const unsigned char *>(end());
136  }
138  return make_range(bytes_begin(), bytes_end());
139  }
140 
141  /// @}
142  /// @name String Operations
143  /// @{
144 
145  /// data - Get a pointer to the start of the string (which may not be null
146  /// terminated).
148  const char *data() const { return Data; }
149 
150  /// empty - Check if the string is empty.
152  constexpr bool empty() const { return Length == 0; }
153 
154  /// size - Get the string size.
156  constexpr size_t size() const { return Length; }
157 
158  /// front - Get the first character in the string.
160  char front() const {
161  assert(!empty());
162  return Data[0];
163  }
164 
165  /// back - Get the last character in the string.
167  char back() const {
168  assert(!empty());
169  return Data[Length-1];
170  }
171 
172  // copy - Allocate copy in Allocator and return StringRef to it.
173  template <typename Allocator>
175  // Don't request a length 0 copy from the allocator.
176  if (empty())
177  return StringRef();
178  char *S = A.template Allocate<char>(Length);
179  std::copy(begin(), end(), S);
180  return StringRef(S, Length);
181  }
182 
183  /// equals - Check for string equality, this is more efficient than
184  /// compare() when the relative ordering of inequal strings isn't needed.
186  bool equals(StringRef RHS) const {
187  return (Length == RHS.Length &&
188  compareMemory(Data, RHS.Data, RHS.Length) == 0);
189  }
190 
191  /// Check for string equality, ignoring case.
194  return Length == RHS.Length && compare_insensitive(RHS) == 0;
195  }
196 
197  /// compare - Compare two strings; the result is -1, 0, or 1 if this string
198  /// is lexicographically less than, equal to, or greater than the \p RHS.
200  int compare(StringRef RHS) const {
201  // Check the prefix for a mismatch.
202  if (int Res = compareMemory(Data, RHS.Data, std::min(Length, RHS.Length)))
203  return Res < 0 ? -1 : 1;
204 
205  // Otherwise the prefixes match, so we only need to check the lengths.
206  if (Length == RHS.Length)
207  return 0;
208  return Length < RHS.Length ? -1 : 1;
209  }
210 
211  /// Compare two strings, ignoring case.
213  int compare_insensitive(StringRef RHS) const;
214 
215  /// compare_numeric - Compare two strings, treating sequences of digits as
216  /// numbers.
218  int compare_numeric(StringRef RHS) const;
219 
220  /// Determine the edit distance between this string and another
221  /// string.
222  ///
223  /// \param Other the string to compare this string against.
224  ///
225  /// \param AllowReplacements whether to allow character
226  /// replacements (change one character into another) as a single
227  /// operation, rather than as two operations (an insertion and a
228  /// removal).
229  ///
230  /// \param MaxEditDistance If non-zero, the maximum edit distance that
231  /// this routine is allowed to compute. If the edit distance will exceed
232  /// that maximum, returns \c MaxEditDistance+1.
233  ///
234  /// \returns the minimum number of character insertions, removals,
235  /// or (if \p AllowReplacements is \c true) replacements needed to
236  /// transform one of the given strings into the other. If zero,
237  /// the strings are identical.
239  unsigned edit_distance(StringRef Other, bool AllowReplacements = true,
240  unsigned MaxEditDistance = 0) const;
241 
242  /// str - Get the contents as an std::string.
244  std::string str() const {
245  if (!Data) return std::string();
246  return std::string(Data, Length);
247  }
248 
249  /// @}
250  /// @name Operator Overloads
251  /// @{
252 
254  char operator[](size_t Index) const {
255  assert(Index < Length && "Invalid index!");
256  return Data[Index];
257  }
258 
259  /// Disallow accidental assignment from a temporary std::string.
260  ///
261  /// The declaration here is extra complicated so that `stringRef = {}`
262  /// and `stringRef = "abc"` continue to select the move assignment operator.
263  template <typename T>
264  std::enable_if_t<std::is_same<T, std::string>::value, StringRef> &
265  operator=(T &&Str) = delete;
266 
267  /// @}
268  /// @name Type Conversions
269  /// @{
270 
271  explicit operator std::string() const { return str(); }
272 
273 #if __cplusplus > 201402L
274  operator std::string_view() const {
275  return std::string_view(data(), size());
276  }
277 #endif
278 
279  /// @}
280  /// @name String Predicates
281  /// @{
282 
283  /// Check if this string starts with the given \p Prefix.
286  return Length >= Prefix.Length &&
287  compareMemory(Data, Prefix.Data, Prefix.Length) == 0;
288  }
289 
290  /// Check if this string starts with the given \p Prefix, ignoring case.
292  bool startswith_insensitive(StringRef Prefix) const;
293 
294  /// Check if this string ends with the given \p Suffix.
296  bool endswith(StringRef Suffix) const {
297  return Length >= Suffix.Length &&
298  compareMemory(end() - Suffix.Length, Suffix.Data, Suffix.Length) == 0;
299  }
300 
301  /// Check if this string ends with the given \p Suffix, ignoring case.
303  bool endswith_insensitive(StringRef Suffix) const;
304 
305  /// @}
306  /// @name String Searching
307  /// @{
308 
309  /// Search for the first character \p C in the string.
310  ///
311  /// \returns The index of the first occurrence of \p C, or npos if not
312  /// found.
314  size_t find(char C, size_t From = 0) const {
315  size_t FindBegin = std::min(From, Length);
316  if (FindBegin < Length) { // Avoid calling memchr with nullptr.
317  // Just forward to memchr, which is faster than a hand-rolled loop.
318  if (const void *P = ::memchr(Data + FindBegin, C, Length - FindBegin))
319  return static_cast<const char *>(P) - Data;
320  }
321  return npos;
322  }
323 
324  /// Search for the first character \p C in the string, ignoring case.
325  ///
326  /// \returns The index of the first occurrence of \p C, or npos if not
327  /// found.
329  size_t find_insensitive(char C, size_t From = 0) const;
330 
331  /// Search for the first character satisfying the predicate \p F
332  ///
333  /// \returns The index of the first character satisfying \p F starting from
334  /// \p From, or npos if not found.
336  size_t find_if(function_ref<bool(char)> F, size_t From = 0) const {
337  StringRef S = drop_front(From);
338  while (!S.empty()) {
339  if (F(S.front()))
340  return size() - S.size();
341  S = S.drop_front();
342  }
343  return npos;
344  }
345 
346  /// Search for the first character not satisfying the predicate \p F
347  ///
348  /// \returns The index of the first character not satisfying \p F starting
349  /// from \p From, or npos if not found.
351  size_t find_if_not(function_ref<bool(char)> F, size_t From = 0) const {
352  return find_if([F](char c) { return !F(c); }, From);
353  }
354 
355  /// Search for the first string \p Str in the string.
356  ///
357  /// \returns The index of the first occurrence of \p Str, or npos if not
358  /// found.
360  size_t find(StringRef Str, size_t From = 0) const;
361 
362  /// Search for the first string \p Str in the string, ignoring case.
363  ///
364  /// \returns The index of the first occurrence of \p Str, or npos if not
365  /// found.
367  size_t find_insensitive(StringRef Str, size_t From = 0) const;
368 
369  /// Search for the last character \p C in the string.
370  ///
371  /// \returns The index of the last occurrence of \p C, or npos if not
372  /// found.
374  size_t rfind(char C, size_t From = npos) const {
375  From = std::min(From, Length);
376  size_t i = From;
377  while (i != 0) {
378  --i;
379  if (Data[i] == C)
380  return i;
381  }
382  return npos;
383  }
384 
385  /// Search for the last character \p C in the string, ignoring case.
386  ///
387  /// \returns The index of the last occurrence of \p C, or npos if not
388  /// found.
390  size_t rfind_insensitive(char C, size_t From = npos) const;
391 
392  /// Search for the last string \p Str in the string.
393  ///
394  /// \returns The index of the last occurrence of \p Str, or npos if not
395  /// found.
397  size_t rfind(StringRef Str) const;
398 
399  /// Search for the last string \p Str in the string, ignoring case.
400  ///
401  /// \returns The index of the last occurrence of \p Str, or npos if not
402  /// found.
404  size_t rfind_insensitive(StringRef Str) const;
405 
406  /// Find the first character in the string that is \p C, or npos if not
407  /// found. Same as find.
409  size_t find_first_of(char C, size_t From = 0) const {
410  return find(C, From);
411  }
412 
413  /// Find the first character in the string that is in \p Chars, or npos if
414  /// not found.
415  ///
416  /// Complexity: O(size() + Chars.size())
418  size_t find_first_of(StringRef Chars, size_t From = 0) const;
419 
420  /// Find the first character in the string that is not \p C or npos if not
421  /// found.
423  size_t find_first_not_of(char C, size_t From = 0) const;
424 
425  /// Find the first character in the string that is not in the string
426  /// \p Chars, or npos if not found.
427  ///
428  /// Complexity: O(size() + Chars.size())
430  size_t find_first_not_of(StringRef Chars, size_t From = 0) const;
431 
432  /// Find the last character in the string that is \p C, or npos if not
433  /// found.
435  size_t find_last_of(char C, size_t From = npos) const {
436  return rfind(C, From);
437  }
438 
439  /// Find the last character in the string that is in \p C, or npos if not
440  /// found.
441  ///
442  /// Complexity: O(size() + Chars.size())
444  size_t find_last_of(StringRef Chars, size_t From = npos) const;
445 
446  /// Find the last character in the string that is not \p C, or npos if not
447  /// found.
449  size_t find_last_not_of(char C, size_t From = npos) const;
450 
451  /// Find the last character in the string that is not in \p Chars, or
452  /// npos if not found.
453  ///
454  /// Complexity: O(size() + Chars.size())
456  size_t find_last_not_of(StringRef Chars, size_t From = npos) const;
457 
458  /// Return true if the given string is a substring of *this, and false
459  /// otherwise.
461  bool contains(StringRef Other) const { return find(Other) != npos; }
462 
463  /// Return true if the given character is contained in *this, and false
464  /// otherwise.
466  bool contains(char C) const { return find_first_of(C) != npos; }
467 
468  /// Return true if the given string is a substring of *this, and false
469  /// otherwise.
471  bool contains_insensitive(StringRef Other) const {
472  return find_insensitive(Other) != npos;
473  }
474 
475  /// Return true if the given character is contained in *this, and false
476  /// otherwise.
478  bool contains_insensitive(char C) const {
479  return find_insensitive(C) != npos;
480  }
481 
482  /// @}
483  /// @name Helpful Algorithms
484  /// @{
485 
486  /// Return the number of occurrences of \p C in the string.
488  size_t count(char C) const {
489  size_t Count = 0;
490  for (size_t i = 0, e = Length; i != e; ++i)
491  if (Data[i] == C)
492  ++Count;
493  return Count;
494  }
495 
496  /// Return the number of non-overlapped occurrences of \p Str in
497  /// the string.
498  size_t count(StringRef Str) const;
499 
500  /// Parse the current string as an integer of the specified radix. If
501  /// \p Radix is specified as zero, this does radix autosensing using
502  /// extended C rules: 0 is octal, 0x is hex, 0b is binary.
503  ///
504  /// If the string is invalid or if only a subset of the string is valid,
505  /// this returns true to signify the error. The string is considered
506  /// erroneous if empty or if it overflows T.
507  template <typename T>
508  std::enable_if_t<std::numeric_limits<T>::is_signed, bool>
509  getAsInteger(unsigned Radix, T &Result) const {
510  long long LLVal;
511  if (getAsSignedInteger(*this, Radix, LLVal) ||
512  static_cast<T>(LLVal) != LLVal)
513  return true;
514  Result = LLVal;
515  return false;
516  }
517 
518  template <typename T>
519  std::enable_if_t<!std::numeric_limits<T>::is_signed, bool>
520  getAsInteger(unsigned Radix, T &Result) const {
521  unsigned long long ULLVal;
522  // The additional cast to unsigned long long is required to avoid the
523  // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type
524  // 'unsigned __int64' when instantiating getAsInteger with T = bool.
525  if (getAsUnsignedInteger(*this, Radix, ULLVal) ||
526  static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal)
527  return true;
528  Result = ULLVal;
529  return false;
530  }
531 
532  /// Parse the current string as an integer of the specified radix. If
533  /// \p Radix is specified as zero, this does radix autosensing using
534  /// extended C rules: 0 is octal, 0x is hex, 0b is binary.
535  ///
536  /// If the string does not begin with a number of the specified radix,
537  /// this returns true to signify the error. The string is considered
538  /// erroneous if empty or if it overflows T.
539  /// The portion of the string representing the discovered numeric value
540  /// is removed from the beginning of the string.
541  template <typename T>
542  std::enable_if_t<std::numeric_limits<T>::is_signed, bool>
543  consumeInteger(unsigned Radix, T &Result) {
544  long long LLVal;
545  if (consumeSignedInteger(*this, Radix, LLVal) ||
546  static_cast<long long>(static_cast<T>(LLVal)) != LLVal)
547  return true;
548  Result = LLVal;
549  return false;
550  }
551 
552  template <typename T>
553  std::enable_if_t<!std::numeric_limits<T>::is_signed, bool>
554  consumeInteger(unsigned Radix, T &Result) {
555  unsigned long long ULLVal;
556  if (consumeUnsignedInteger(*this, Radix, ULLVal) ||
557  static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal)
558  return true;
559  Result = ULLVal;
560  return false;
561  }
562 
563  /// Parse the current string as an integer of the specified \p Radix, or of
564  /// an autosensed radix if the \p Radix given is 0. The current value in
565  /// \p Result is discarded, and the storage is changed to be wide enough to
566  /// store the parsed integer.
567  ///
568  /// \returns true if the string does not solely consist of a valid
569  /// non-empty number in the appropriate base.
570  ///
571  /// APInt::fromString is superficially similar but assumes the
572  /// string is well-formed in the given radix.
573  bool getAsInteger(unsigned Radix, APInt &Result) const;
574 
575  /// Parse the current string as an IEEE double-precision floating
576  /// point value. The string must be a well-formed double.
577  ///
578  /// If \p AllowInexact is false, the function will fail if the string
579  /// cannot be represented exactly. Otherwise, the function only fails
580  /// in case of an overflow or underflow, or an invalid floating point
581  /// representation.
582  bool getAsDouble(double &Result, bool AllowInexact = true) const;
583 
584  /// @}
585  /// @name String Operations
586  /// @{
587 
588  // Convert the given ASCII string to lowercase.
590  std::string lower() const;
591 
592  /// Convert the given ASCII string to uppercase.
594  std::string upper() const;
595 
596  /// @}
597  /// @name Substring Operations
598  /// @{
599 
600  /// Return a reference to the substring from [Start, Start + N).
601  ///
602  /// \param Start The index of the starting character in the substring; if
603  /// the index is npos or greater than the length of the string then the
604  /// empty substring will be returned.
605  ///
606  /// \param N The number of characters to included in the substring. If N
607  /// exceeds the number of characters remaining in the string, the string
608  /// suffix (starting with \p Start) will be returned.
610  StringRef substr(size_t Start, size_t N = npos) const {
611  Start = std::min(Start, Length);
612  return StringRef(Data + Start, std::min(N, Length - Start));
613  }
614 
615  /// Return a StringRef equal to 'this' but with only the first \p N
616  /// elements remaining. If \p N is greater than the length of the
617  /// string, the entire string is returned.
619  StringRef take_front(size_t N = 1) const {
620  if (N >= size())
621  return *this;
622  return drop_back(size() - N);
623  }
624 
625  /// Return a StringRef equal to 'this' but with only the last \p N
626  /// elements remaining. If \p N is greater than the length of the
627  /// string, the entire string is returned.
629  StringRef take_back(size_t N = 1) const {
630  if (N >= size())
631  return *this;
632  return drop_front(size() - N);
633  }
634 
635  /// Return the longest prefix of 'this' such that every character
636  /// in the prefix satisfies the given predicate.
638  StringRef take_while(function_ref<bool(char)> F) const {
639  return substr(0, find_if_not(F));
640  }
641 
642  /// Return the longest prefix of 'this' such that no character in
643  /// the prefix satisfies the given predicate.
645  StringRef take_until(function_ref<bool(char)> F) const {
646  return substr(0, find_if(F));
647  }
648 
649  /// Return a StringRef equal to 'this' but with the first \p N elements
650  /// dropped.
652  StringRef drop_front(size_t N = 1) const {
653  assert(size() >= N && "Dropping more elements than exist");
654  return substr(N);
655  }
656 
657  /// Return a StringRef equal to 'this' but with the last \p N elements
658  /// dropped.
660  StringRef drop_back(size_t N = 1) const {
661  assert(size() >= N && "Dropping more elements than exist");
662  return substr(0, size()-N);
663  }
664 
665  /// Return a StringRef equal to 'this', but with all characters satisfying
666  /// the given predicate dropped from the beginning of the string.
668  StringRef drop_while(function_ref<bool(char)> F) const {
669  return substr(find_if_not(F));
670  }
671 
672  /// Return a StringRef equal to 'this', but with all characters not
673  /// satisfying the given predicate dropped from the beginning of the string.
675  StringRef drop_until(function_ref<bool(char)> F) const {
676  return substr(find_if(F));
677  }
678 
679  /// Returns true if this StringRef has the given prefix and removes that
680  /// prefix.
682  if (!startswith(Prefix))
683  return false;
684 
685  *this = drop_front(Prefix.size());
686  return true;
687  }
688 
689  /// Returns true if this StringRef has the given prefix, ignoring case,
690  /// and removes that prefix.
692  if (!startswith_insensitive(Prefix))
693  return false;
694 
695  *this = drop_front(Prefix.size());
696  return true;
697  }
698 
699  /// Returns true if this StringRef has the given suffix and removes that
700  /// suffix.
701  bool consume_back(StringRef Suffix) {
702  if (!endswith(Suffix))
703  return false;
704 
705  *this = drop_back(Suffix.size());
706  return true;
707  }
708 
709  /// Returns true if this StringRef has the given suffix, ignoring case,
710  /// and removes that suffix.
712  if (!endswith_insensitive(Suffix))
713  return false;
714 
715  *this = drop_back(Suffix.size());
716  return true;
717  }
718 
719  /// Return a reference to the substring from [Start, End).
720  ///
721  /// \param Start The index of the starting character in the substring; if
722  /// the index is npos or greater than the length of the string then the
723  /// empty substring will be returned.
724  ///
725  /// \param End The index following the last character to include in the
726  /// substring. If this is npos or exceeds the number of characters
727  /// remaining in the string, the string suffix (starting with \p Start)
728  /// will be returned. If this is less than \p Start, an empty string will
729  /// be returned.
731  StringRef slice(size_t Start, size_t End) const {
732  Start = std::min(Start, Length);
733  End = std::min(std::max(Start, End), Length);
734  return StringRef(Data + Start, End - Start);
735  }
736 
737  /// Split into two substrings around the first occurrence of a separator
738  /// character.
739  ///
740  /// If \p Separator is in the string, then the result is a pair (LHS, RHS)
741  /// such that (*this == LHS + Separator + RHS) is true and RHS is
742  /// maximal. If \p Separator is not in the string, then the result is a
743  /// pair (LHS, RHS) where (*this == LHS) and (RHS == "").
744  ///
745  /// \param Separator The character to split on.
746  /// \returns The split substrings.
748  std::pair<StringRef, StringRef> split(char Separator) const {
749  return split(StringRef(&Separator, 1));
750  }
751 
752  /// Split into two substrings around the first occurrence of a separator
753  /// string.
754  ///
755  /// If \p Separator is in the string, then the result is a pair (LHS, RHS)
756  /// such that (*this == LHS + Separator + RHS) is true and RHS is
757  /// maximal. If \p Separator is not in the string, then the result is a
758  /// pair (LHS, RHS) where (*this == LHS) and (RHS == "").
759  ///
760  /// \param Separator - The string to split on.
761  /// \return - The split substrings.
763  std::pair<StringRef, StringRef> split(StringRef Separator) const {
764  size_t Idx = find(Separator);
765  if (Idx == npos)
766  return std::make_pair(*this, StringRef());
767  return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos));
768  }
769 
770  /// Split into two substrings around the last occurrence of a separator
771  /// string.
772  ///
773  /// If \p Separator is in the string, then the result is a pair (LHS, RHS)
774  /// such that (*this == LHS + Separator + RHS) is true and RHS is
775  /// minimal. If \p Separator is not in the string, then the result is a
776  /// pair (LHS, RHS) where (*this == LHS) and (RHS == "").
777  ///
778  /// \param Separator - The string to split on.
779  /// \return - The split substrings.
781  std::pair<StringRef, StringRef> rsplit(StringRef Separator) const {
782  size_t Idx = rfind(Separator);
783  if (Idx == npos)
784  return std::make_pair(*this, StringRef());
785  return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos));
786  }
787 
788  /// Split into substrings around the occurrences of a separator string.
789  ///
790  /// Each substring is stored in \p A. If \p MaxSplit is >= 0, at most
791  /// \p MaxSplit splits are done and consequently <= \p MaxSplit + 1
792  /// elements are added to A.
793  /// If \p KeepEmpty is false, empty strings are not added to \p A. They
794  /// still count when considering \p MaxSplit
795  /// An useful invariant is that
796  /// Separator.join(A) == *this if MaxSplit == -1 and KeepEmpty == true
797  ///
798  /// \param A - Where to put the substrings.
799  /// \param Separator - The string to split on.
800  /// \param MaxSplit - The maximum number of times the string is split.
801  /// \param KeepEmpty - True if empty substring should be added.
803  StringRef Separator, int MaxSplit = -1,
804  bool KeepEmpty = true) const;
805 
806  /// Split into substrings around the occurrences of a separator character.
807  ///
808  /// Each substring is stored in \p A. If \p MaxSplit is >= 0, at most
809  /// \p MaxSplit splits are done and consequently <= \p MaxSplit + 1
810  /// elements are added to A.
811  /// If \p KeepEmpty is false, empty strings are not added to \p A. They
812  /// still count when considering \p MaxSplit
813  /// An useful invariant is that
814  /// Separator.join(A) == *this if MaxSplit == -1 and KeepEmpty == true
815  ///
816  /// \param A - Where to put the substrings.
817  /// \param Separator - The string to split on.
818  /// \param MaxSplit - The maximum number of times the string is split.
819  /// \param KeepEmpty - True if empty substring should be added.
820  void split(SmallVectorImpl<StringRef> &A, char Separator, int MaxSplit = -1,
821  bool KeepEmpty = true) const;
822 
823  /// Split into two substrings around the last occurrence of a separator
824  /// character.
825  ///
826  /// If \p Separator is in the string, then the result is a pair (LHS, RHS)
827  /// such that (*this == LHS + Separator + RHS) is true and RHS is
828  /// minimal. If \p Separator is not in the string, then the result is a
829  /// pair (LHS, RHS) where (*this == LHS) and (RHS == "").
830  ///
831  /// \param Separator - The character to split on.
832  /// \return - The split substrings.
834  std::pair<StringRef, StringRef> rsplit(char Separator) const {
835  return rsplit(StringRef(&Separator, 1));
836  }
837 
838  /// Return string with consecutive \p Char characters starting from the
839  /// the left removed.
841  StringRef ltrim(char Char) const {
842  return drop_front(std::min(Length, find_first_not_of(Char)));
843  }
844 
845  /// Return string with consecutive characters in \p Chars starting from
846  /// the left removed.
848  StringRef ltrim(StringRef Chars = " \t\n\v\f\r") const {
849  return drop_front(std::min(Length, find_first_not_of(Chars)));
850  }
851 
852  /// Return string with consecutive \p Char characters starting from the
853  /// right removed.
855  StringRef rtrim(char Char) const {
856  return drop_back(Length - std::min(Length, find_last_not_of(Char) + 1));
857  }
858 
859  /// Return string with consecutive characters in \p Chars starting from
860  /// the right removed.
862  StringRef rtrim(StringRef Chars = " \t\n\v\f\r") const {
863  return drop_back(Length - std::min(Length, find_last_not_of(Chars) + 1));
864  }
865 
866  /// Return string with consecutive \p Char characters starting from the
867  /// left and right removed.
869  StringRef trim(char Char) const {
870  return ltrim(Char).rtrim(Char);
871  }
872 
873  /// Return string with consecutive characters in \p Chars starting from
874  /// the left and right removed.
876  StringRef trim(StringRef Chars = " \t\n\v\f\r") const {
877  return ltrim(Chars).rtrim(Chars);
878  }
879 
880  /// @}
881  };
882 
883  /// A wrapper around a string literal that serves as a proxy for constructing
884  /// global tables of StringRefs with the length computed at compile time.
885  /// In order to avoid the invocation of a global constructor, StringLiteral
886  /// should *only* be used in a constexpr context, as such:
887  ///
888  /// constexpr StringLiteral S("test");
889  ///
890  class StringLiteral : public StringRef {
891  private:
892  constexpr StringLiteral(const char *Str, size_t N) : StringRef(Str, N) {
893  }
894 
895  public:
896  template <size_t N>
897  constexpr StringLiteral(const char (&Str)[N])
898 #if defined(__clang__) && __has_attribute(enable_if)
899 #pragma clang diagnostic push
900 #pragma clang diagnostic ignored "-Wgcc-compat"
901  __attribute((enable_if(__builtin_strlen(Str) == N - 1,
902  "invalid string literal")))
903 #pragma clang diagnostic pop
904 #endif
905  : StringRef(Str, N - 1) {
906  }
907 
908  // Explicit construction for strings like "foo\0bar".
909  template <size_t N>
910  static constexpr StringLiteral withInnerNUL(const char (&Str)[N]) {
911  return StringLiteral(Str, N - 1);
912  }
913  };
914 
915  /// @name StringRef Comparison Operators
916  /// @{
917 
919  return LHS.equals(RHS);
920  }
921 
922  inline bool operator!=(StringRef LHS, StringRef RHS) { return !(LHS == RHS); }
923 
925  return LHS.compare(RHS) == -1;
926  }
927 
929  return LHS.compare(RHS) != 1;
930  }
931 
933  return LHS.compare(RHS) == 1;
934  }
935 
937  return LHS.compare(RHS) != -1;
938  }
939 
940  inline std::string &operator+=(std::string &buffer, StringRef string) {
941  return buffer.append(string.data(), string.size());
942  }
943 
944  /// @}
945 
946  /// Compute a hash_code for a StringRef.
948  hash_code hash_value(StringRef S);
949 
950  // Provide DenseMapInfo for StringRefs.
951  template <> struct DenseMapInfo<StringRef, void> {
952  static inline StringRef getEmptyKey() {
953  return StringRef(
954  reinterpret_cast<const char *>(~static_cast<uintptr_t>(0)), 0);
955  }
956 
957  static inline StringRef getTombstoneKey() {
958  return StringRef(
959  reinterpret_cast<const char *>(~static_cast<uintptr_t>(1)), 0);
960  }
961 
962  static unsigned getHashValue(StringRef Val) {
963  assert(Val.data() != getEmptyKey().data() &&
964  "Cannot hash the empty key!");
965  assert(Val.data() != getTombstoneKey().data() &&
966  "Cannot hash the tombstone key!");
967  return (unsigned)(hash_value(Val));
968  }
969 
971  if (RHS.data() == getEmptyKey().data())
972  return LHS.data() == getEmptyKey().data();
973  if (RHS.data() == getTombstoneKey().data())
974  return LHS.data() == getTombstoneKey().data();
975  return LHS == RHS;
976  }
977  };
978 
979 } // end namespace llvm
980 
981 #endif // LLVM_ADT_STRINGREF_H
llvm::StringRef::copy
LLVM_NODISCARD StringRef copy(Allocator &A) const
Definition: StringRef.h:174
i
i
Definition: README.txt:29
llvm::StringRef::back
LLVM_NODISCARD char back() const
back - Get the last character in the string.
Definition: StringRef.h:167
llvm::StringRef::startswith
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:285
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::StringRef::operator[]
LLVM_NODISCARD char operator[](size_t Index) const
Definition: StringRef.h:254
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::count
LLVM_NODISCARD size_t count(char C) const
Return the number of occurrences of C in the string.
Definition: StringRef.h:488
llvm::StringRef::rtrim
LLVM_NODISCARD StringRef rtrim(char Char) const
Return string with consecutive Char characters starting from the right removed.
Definition: StringRef.h:855
llvm::cl::Prefix
@ Prefix
Definition: CommandLine.h:164
llvm::StringRef::endswith
LLVM_NODISCARD bool endswith(StringRef Suffix) const
Check if this string ends with the given Suffix.
Definition: StringRef.h:296
llvm::StringRef::rfind
LLVM_NODISCARD size_t rfind(char C, size_t From=npos) const
Search for the last character C in the string.
Definition: StringRef.h:374
llvm::operator<=
bool operator<=(int64_t V1, const APSInt &V2)
Definition: APSInt.h:336
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::take_until
LLVM_NODISCARD 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:645
llvm::StringRef::find
LLVM_NODISCARD size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Definition: StringRef.h:314
llvm::StringRef::take_while
LLVM_NODISCARD 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:638
llvm::StringRef::rtrim
LLVM_NODISCARD 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:862
llvm::StringRef::ltrim
LLVM_NODISCARD StringRef ltrim(char Char) const
Return string with consecutive Char characters starting from the the left removed.
Definition: StringRef.h:841
memcmp
Merge contiguous icmps into a memcmp
Definition: MergeICmps.cpp:888
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:681
llvm::StringRef::rsplit
LLVM_NODISCARD std::pair< StringRef, StringRef > rsplit(char Separator) const
Split into two substrings around the last occurrence of a separator character.
Definition: StringRef.h:834
startswith
static bool startswith(StringRef Magic, const char(&S)[N])
Definition: Magic.cpp:30
llvm::StringRef::StringRef
constexpr StringRef(const char *data, size_t length)
Construct a string ref from a pointer and length.
Definition: StringRef.h:110
llvm::DenseMapInfo< StringRef, void >::getTombstoneKey
static StringRef getTombstoneKey()
Definition: StringRef.h:957
llvm::StringRef::rsplit
LLVM_NODISCARD std::pair< StringRef, StringRef > rsplit(StringRef Separator) const
Split into two substrings around the last occurrence of a separator string.
Definition: StringRef.h:781
llvm::sys::path::end
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:236
llvm::sys::path::begin
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:227
llvm::operator!=
bool operator!=(uint64_t V1, const APInt &V2)
Definition: APInt.h:1988
T
#define T
Definition: Mips16ISelLowering.cpp:341
STLExtras.h
RHS
Value * RHS
Definition: X86PartialReduction.cpp:74
llvm::StringRef::slice
LLVM_NODISCARD StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
Definition: StringRef.h:731
llvm::hash_value
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
Definition: APFloat.cpp:4821
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
size_t
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::StringRef::substr
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:610
llvm::StringRef::consumeInteger
std::enable_if_t<!std::numeric_limits< T >::is_signed, bool > consumeInteger(unsigned Radix, T &Result)
Definition: StringRef.h:554
llvm::consumeSignedInteger
bool consumeSignedInteger(StringRef &Str, unsigned Radix, long long &Result)
Definition: StringRef.cpp:455
LHS
Value * LHS
Definition: X86PartialReduction.cpp:73
llvm::DenseMapInfo
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: APInt.h:34
llvm::StringRef::trim
LLVM_NODISCARD 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:876
llvm::StringLiteral
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Definition: StringRef.h:890
llvm::StringRef::find_last_of
LLVM_NODISCARD 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:435
llvm::StringRef::take_front
LLVM_NODISCARD 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:619
llvm::StringLiteral::withInnerNUL
static constexpr StringLiteral withInnerNUL(const char(&Str)[N])
Definition: StringRef.h:910
llvm::StringRef::split
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition: StringRef.h:748
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::getAsUnsignedInteger
bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result)
Helper functions for StringRef::getAsInteger.
Definition: StringRef.cpp:485
llvm::operator+=
std::string & operator+=(std::string &buffer, StringRef string)
Definition: StringRef.h:940
llvm::StringRef::iterator
const char * iterator
Definition: StringRef.h:61
llvm::StringRef::contains
LLVM_NODISCARD bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition: StringRef.h:461
llvm::StringRef::drop_until
LLVM_NODISCARD 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:675
llvm::StringRef::find_if_not
LLVM_NODISCARD 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:351
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::str
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:244
llvm::StringRef::getAsInteger
std::enable_if_t< std::numeric_limits< T >::is_signed, bool > getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
Definition: StringRef.h:509
llvm::StringRef::equals
LLVM_NODISCARD bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
Definition: StringRef.h:186
llvm::StringRef::drop_while
LLVM_NODISCARD 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:668
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:223
llvm::StringRef::trim
LLVM_NODISCARD StringRef trim(char Char) const
Return string with consecutive Char characters starting from the left and right removed.
Definition: StringRef.h:869
llvm::StringRef::StringRef
StringRef(const std::string &Str)
Construct a string ref from an std::string.
Definition: StringRef.h:114
llvm::operator>=
bool operator>=(int64_t V1, const APSInt &V2)
Definition: APSInt.h:337
llvm::StringRef::equals_insensitive
LLVM_NODISCARD bool equals_insensitive(StringRef RHS) const
Check for string equality, ignoring case.
Definition: StringRef.h:193
llvm::StringRef::empty
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:152
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:1732
Index
uint32_t Index
Definition: ELFObjHandler.cpp:83
llvm::StringRef::contains
LLVM_NODISCARD bool contains(char C) const
Return true if the given character is contained in *this, and false otherwise.
Definition: StringRef.h:466
llvm::StringRef::end
iterator end() const
Definition: StringRef.h:129
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:1669
llvm::consumeUnsignedInteger
bool consumeUnsignedInteger(StringRef &Str, unsigned Radix, unsigned long long &Result)
Definition: StringRef.cpp:407
llvm::StringRef::getAsInteger
std::enable_if_t<!std::numeric_limits< T >::is_signed, bool > getAsInteger(unsigned Radix, T &Result) const
Definition: StringRef.h:520
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:57
llvm::operator<
bool operator<(int64_t V1, const APSInt &V2)
Definition: APSInt.h:338
llvm::StringRef::front
LLVM_NODISCARD char front() const
front - Get the first character in the string.
Definition: StringRef.h:160
llvm::DenseMapInfo< StringRef, void >::isEqual
static bool isEqual(StringRef LHS, StringRef RHS)
Definition: StringRef.h:970
llvm::StringRef::StringRef
constexpr StringRef(const char *Str)
Construct a string ref from a cstring.
Definition: StringRef.h:106
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::operator==
bool operator==(uint64_t V1, const APInt &V2)
Definition: APInt.h:1986
iterator_range.h
llvm::StringRef::bytes_begin
const unsigned char * bytes_begin() const
Definition: StringRef.h:131
llvm::StringRef::contains_insensitive
LLVM_NODISCARD bool contains_insensitive(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition: StringRef.h:471
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:75
llvm::StringRef::drop_back
LLVM_NODISCARD StringRef drop_back(size_t N=1) const
Return a StringRef equal to 'this' but with the last N elements dropped.
Definition: StringRef.h:660
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:1630
llvm::min
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:357
llvm::StringRef::ltrim
LLVM_NODISCARD 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:848
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
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:952
llvm::DenseMapInfo< StringRef, void >::getHashValue
static unsigned getHashValue(StringRef Val)
Definition: StringRef.h:962
llvm::StringRef::consumeInteger
std::enable_if_t< std::numeric_limits< T >::is_signed, bool > consumeInteger(unsigned Radix, T &Result)
Parse the current string as an integer of the specified radix.
Definition: StringRef.h:543
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:1676
llvm::StringRef::size
constexpr LLVM_NODISCARD size_t size() const
size - Get the string size.
Definition: StringRef.h:156
llvm::empty
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
Definition: STLExtras.h:309
split
coro split
Definition: CoroSplit.cpp:2344
llvm::StringRef::drop_front
LLVM_NODISCARD StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
Definition: StringRef.h:652
llvm::StringRef::split
LLVM_NODISCARD std::pair< StringRef, StringRef > split(StringRef Separator) const
Split into two substrings around the first occurrence of a separator string.
Definition: StringRef.h:763
llvm::StringLiteral::StringLiteral
constexpr StringLiteral(const char(&Str)[N])
Definition: StringRef.h:897
llvm::StringRef::bytes
iterator_range< const unsigned char * > bytes() const
Definition: StringRef.h:137
LLVM_NODISCARD
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
Definition: Compiler.h:165
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:315
llvm::getAsSignedInteger
bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result)
Definition: StringRef.cpp:495
Allocator
Basic Register Allocator
Definition: RegAllocBasic.cpp:146
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:701
N
#define N
llvm::max
Align max(MaybeAlign Lhs, Align Rhs)
Definition: Alignment.h:340
llvm::StringRef::const_iterator
const char * const_iterator
Definition: StringRef.h:62
llvm::operator>
bool operator>(int64_t V1, const APSInt &V2)
Definition: APSInt.h:339
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::StringRef::data
const LLVM_NODISCARD char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:148
llvm::SmallVectorImpl< StringRef >
llvm::StringRef::find_first_of
LLVM_NODISCARD 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:409
llvm::StringRef::find_if
LLVM_NODISCARD 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:336
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:711
llvm::StringRef::begin
iterator begin() const
Definition: StringRef.h:127
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::compare
LLVM_NODISCARD 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:200
llvm::find_if_not
auto find_if_not(R &&Range, UnaryPredicate P)
Definition: STLExtras.h:1681
llvm::StringRef::contains_insensitive
LLVM_NODISCARD bool contains_insensitive(char C) const
Return true if the given character is contained in *this, and false otherwise.
Definition: StringRef.h:478
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1198
llvm::StringRef::bytes_end
const unsigned char * bytes_end() const
Definition: StringRef.h:134
llvm::StringRef::take_back
LLVM_NODISCARD 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:629
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:691