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