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