LLVM  13.0.0git
StringRef.cpp
Go to the documentation of this file.
1 //===-- StringRef.cpp - Lightweight String References ---------------------===//
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 #include "llvm/ADT/StringRef.h"
10 #include "llvm/ADT/APFloat.h"
11 #include "llvm/ADT/APInt.h"
12 #include "llvm/ADT/Hashing.h"
13 #include "llvm/ADT/StringExtras.h"
14 #include "llvm/ADT/edit_distance.h"
15 #include "llvm/Support/Error.h"
16 #include <bitset>
17 
18 using namespace llvm;
19 
20 // MSVC emits references to this into the translation units which reference it.
21 #ifndef _MSC_VER
22 constexpr size_t StringRef::npos;
23 #endif
24 
25 // strncasecmp() is not available on non-POSIX systems, so define an
26 // alternative function here.
27 static int ascii_strncasecmp(const char *LHS, const char *RHS, size_t Length) {
28  for (size_t I = 0; I < Length; ++I) {
29  unsigned char LHC = toLower(LHS[I]);
30  unsigned char RHC = toLower(RHS[I]);
31  if (LHC != RHC)
32  return LHC < RHC ? -1 : 1;
33  }
34  return 0;
35 }
36 
37 /// compare_lower - Compare strings, ignoring case.
39  if (int Res = ascii_strncasecmp(Data, RHS.Data, std::min(Length, RHS.Length)))
40  return Res;
41  if (Length == RHS.Length)
42  return 0;
43  return Length < RHS.Length ? -1 : 1;
44 }
45 
46 /// Check if this string starts with the given \p Prefix, ignoring case.
48  return Length >= Prefix.Length &&
49  ascii_strncasecmp(Data, Prefix.Data, Prefix.Length) == 0;
50 }
51 
52 /// Check if this string ends with the given \p Suffix, ignoring case.
54  return Length >= Suffix.Length &&
55  ascii_strncasecmp(end() - Suffix.Length, Suffix.Data, Suffix.Length) == 0;
56 }
57 
58 size_t StringRef::find_lower(char C, size_t From) const {
59  char L = toLower(C);
60  return find_if([L](char D) { return toLower(D) == L; }, From);
61 }
62 
63 /// compare_numeric - Compare strings, handle embedded numbers.
65  for (size_t I = 0, E = std::min(Length, RHS.Length); I != E; ++I) {
66  // Check for sequences of digits.
67  if (isDigit(Data[I]) && isDigit(RHS.Data[I])) {
68  // The longer sequence of numbers is considered larger.
69  // This doesn't really handle prefixed zeros well.
70  size_t J;
71  for (J = I + 1; J != E + 1; ++J) {
72  bool ld = J < Length && isDigit(Data[J]);
73  bool rd = J < RHS.Length && isDigit(RHS.Data[J]);
74  if (ld != rd)
75  return rd ? -1 : 1;
76  if (!rd)
77  break;
78  }
79  // The two number sequences have the same length (J-I), just memcmp them.
80  if (int Res = compareMemory(Data + I, RHS.Data + I, J - I))
81  return Res < 0 ? -1 : 1;
82  // Identical number sequences, continue search after the numbers.
83  I = J - 1;
84  continue;
85  }
86  if (Data[I] != RHS.Data[I])
87  return (unsigned char)Data[I] < (unsigned char)RHS.Data[I] ? -1 : 1;
88  }
89  if (Length == RHS.Length)
90  return 0;
91  return Length < RHS.Length ? -1 : 1;
92 }
93 
94 // Compute the edit distance between the two given strings.
96  bool AllowReplacements,
97  unsigned MaxEditDistance) const {
99  makeArrayRef(data(), size()),
100  makeArrayRef(Other.data(), Other.size()),
101  AllowReplacements, MaxEditDistance);
102 }
103 
104 //===----------------------------------------------------------------------===//
105 // String Operations
106 //===----------------------------------------------------------------------===//
107 
108 std::string StringRef::lower() const {
109  return std::string(map_iterator(begin(), toLower),
110  map_iterator(end(), toLower));
111 }
112 
113 std::string StringRef::upper() const {
114  return std::string(map_iterator(begin(), toUpper),
115  map_iterator(end(), toUpper));
116 }
117 
118 //===----------------------------------------------------------------------===//
119 // String Searching
120 //===----------------------------------------------------------------------===//
121 
122 
123 /// find - Search for the first string \arg Str in the string.
124 ///
125 /// \return - The index of the first occurrence of \arg Str, or npos if not
126 /// found.
127 size_t StringRef::find(StringRef Str, size_t From) const {
128  if (From > Length)
129  return npos;
130 
131  const char *Start = Data + From;
132  size_t Size = Length - From;
133 
134  const char *Needle = Str.data();
135  size_t N = Str.size();
136  if (N == 0)
137  return From;
138  if (Size < N)
139  return npos;
140  if (N == 1) {
141  const char *Ptr = (const char *)::memchr(Start, Needle[0], Size);
142  return Ptr == nullptr ? npos : Ptr - Data;
143  }
144 
145  const char *Stop = Start + (Size - N + 1);
146 
147  // For short haystacks or unsupported needles fall back to the naive algorithm
148  if (Size < 16 || N > 255) {
149  do {
150  if (std::memcmp(Start, Needle, N) == 0)
151  return Start - Data;
152  ++Start;
153  } while (Start < Stop);
154  return npos;
155  }
156 
157  // Build the bad char heuristic table, with uint8_t to reduce cache thrashing.
158  uint8_t BadCharSkip[256];
159  std::memset(BadCharSkip, N, 256);
160  for (unsigned i = 0; i != N-1; ++i)
161  BadCharSkip[(uint8_t)Str[i]] = N-1-i;
162 
163  do {
164  uint8_t Last = Start[N - 1];
165  if (LLVM_UNLIKELY(Last == (uint8_t)Needle[N - 1]))
166  if (std::memcmp(Start, Needle, N - 1) == 0)
167  return Start - Data;
168 
169  // Otherwise skip the appropriate number of bytes.
170  Start += BadCharSkip[Last];
171  } while (Start < Stop);
172 
173  return npos;
174 }
175 
176 size_t StringRef::find_lower(StringRef Str, size_t From) const {
178  while (This.size() >= Str.size()) {
179  if (This.startswith_lower(Str))
180  return From;
181  This = This.drop_front();
182  ++From;
183  }
184  return npos;
185 }
186 
187 size_t StringRef::rfind_lower(char C, size_t From) const {
188  From = std::min(From, Length);
189  size_t i = From;
190  while (i != 0) {
191  --i;
192  if (toLower(Data[i]) == toLower(C))
193  return i;
194  }
195  return npos;
196 }
197 
198 /// rfind - Search for the last string \arg Str in the string.
199 ///
200 /// \return - The index of the last occurrence of \arg Str, or npos if not
201 /// found.
202 size_t StringRef::rfind(StringRef Str) const {
203  size_t N = Str.size();
204  if (N > Length)
205  return npos;
206  for (size_t i = Length - N + 1, e = 0; i != e;) {
207  --i;
208  if (substr(i, N).equals(Str))
209  return i;
210  }
211  return npos;
212 }
213 
215  size_t N = Str.size();
216  if (N > Length)
217  return npos;
218  for (size_t i = Length - N + 1, e = 0; i != e;) {
219  --i;
220  if (substr(i, N).equals_lower(Str))
221  return i;
222  }
223  return npos;
224 }
225 
226 /// find_first_of - Find the first character in the string that is in \arg
227 /// Chars, or npos if not found.
228 ///
229 /// Note: O(size() + Chars.size())
231  size_t From) const {
232  std::bitset<1 << CHAR_BIT> CharBits;
233  for (size_type i = 0; i != Chars.size(); ++i)
234  CharBits.set((unsigned char)Chars[i]);
235 
236  for (size_type i = std::min(From, Length), e = Length; i != e; ++i)
237  if (CharBits.test((unsigned char)Data[i]))
238  return i;
239  return npos;
240 }
241 
242 /// find_first_not_of - Find the first character in the string that is not
243 /// \arg C or npos if not found.
245  for (size_type i = std::min(From, Length), e = Length; i != e; ++i)
246  if (Data[i] != C)
247  return i;
248  return npos;
249 }
250 
251 /// find_first_not_of - Find the first character in the string that is not
252 /// in the string \arg Chars, or npos if not found.
253 ///
254 /// Note: O(size() + Chars.size())
256  size_t From) const {
257  std::bitset<1 << CHAR_BIT> CharBits;
258  for (size_type i = 0; i != Chars.size(); ++i)
259  CharBits.set((unsigned char)Chars[i]);
260 
261  for (size_type i = std::min(From, Length), e = Length; i != e; ++i)
262  if (!CharBits.test((unsigned char)Data[i]))
263  return i;
264  return npos;
265 }
266 
267 /// find_last_of - Find the last character in the string that is in \arg C,
268 /// or npos if not found.
269 ///
270 /// Note: O(size() + Chars.size())
272  size_t From) const {
273  std::bitset<1 << CHAR_BIT> CharBits;
274  for (size_type i = 0; i != Chars.size(); ++i)
275  CharBits.set((unsigned char)Chars[i]);
276 
277  for (size_type i = std::min(From, Length) - 1, e = -1; i != e; --i)
278  if (CharBits.test((unsigned char)Data[i]))
279  return i;
280  return npos;
281 }
282 
283 /// find_last_not_of - Find the last character in the string that is not
284 /// \arg C, or npos if not found.
286  for (size_type i = std::min(From, Length) - 1, e = -1; i != e; --i)
287  if (Data[i] != C)
288  return i;
289  return npos;
290 }
291 
292 /// find_last_not_of - Find the last character in the string that is not in
293 /// \arg Chars, or npos if not found.
294 ///
295 /// Note: O(size() + Chars.size())
297  size_t From) const {
298  std::bitset<1 << CHAR_BIT> CharBits;
299  for (size_type i = 0, e = Chars.size(); i != e; ++i)
300  CharBits.set((unsigned char)Chars[i]);
301 
302  for (size_type i = std::min(From, Length) - 1, e = -1; i != e; --i)
303  if (!CharBits.test((unsigned char)Data[i]))
304  return i;
305  return npos;
306 }
307 
309  StringRef Separator, int MaxSplit,
310  bool KeepEmpty) const {
311  StringRef S = *this;
312 
313  // Count down from MaxSplit. When MaxSplit is -1, this will just split
314  // "forever". This doesn't support splitting more than 2^31 times
315  // intentionally; if we ever want that we can make MaxSplit a 64-bit integer
316  // but that seems unlikely to be useful.
317  while (MaxSplit-- != 0) {
318  size_t Idx = S.find(Separator);
319  if (Idx == npos)
320  break;
321 
322  // Push this split.
323  if (KeepEmpty || Idx > 0)
324  A.push_back(S.slice(0, Idx));
325 
326  // Jump forward.
327  S = S.slice(Idx + Separator.size(), npos);
328  }
329 
330  // Push the tail.
331  if (KeepEmpty || !S.empty())
332  A.push_back(S);
333 }
334 
336  int MaxSplit, bool KeepEmpty) const {
337  StringRef S = *this;
338 
339  // Count down from MaxSplit. When MaxSplit is -1, this will just split
340  // "forever". This doesn't support splitting more than 2^31 times
341  // intentionally; if we ever want that we can make MaxSplit a 64-bit integer
342  // but that seems unlikely to be useful.
343  while (MaxSplit-- != 0) {
344  size_t Idx = S.find(Separator);
345  if (Idx == npos)
346  break;
347 
348  // Push this split.
349  if (KeepEmpty || Idx > 0)
350  A.push_back(S.slice(0, Idx));
351 
352  // Jump forward.
353  S = S.slice(Idx + 1, npos);
354  }
355 
356  // Push the tail.
357  if (KeepEmpty || !S.empty())
358  A.push_back(S);
359 }
360 
361 //===----------------------------------------------------------------------===//
362 // Helpful Algorithms
363 //===----------------------------------------------------------------------===//
364 
365 /// count - Return the number of non-overlapped occurrences of \arg Str in
366 /// the string.
367 size_t StringRef::count(StringRef Str) const {
368  size_t Count = 0;
369  size_t N = Str.size();
370  if (!N || N > Length)
371  return 0;
372  for (size_t i = 0, e = Length - N + 1; i < e;) {
373  if (substr(i, N).equals(Str)) {
374  ++Count;
375  i += N;
376  }
377  else
378  ++i;
379  }
380  return Count;
381 }
382 
383 static unsigned GetAutoSenseRadix(StringRef &Str) {
384  if (Str.empty())
385  return 10;
386 
387  if (Str.startswith("0x") || Str.startswith("0X")) {
388  Str = Str.substr(2);
389  return 16;
390  }
391 
392  if (Str.startswith("0b") || Str.startswith("0B")) {
393  Str = Str.substr(2);
394  return 2;
395  }
396 
397  if (Str.startswith("0o")) {
398  Str = Str.substr(2);
399  return 8;
400  }
401 
402  if (Str[0] == '0' && Str.size() > 1 && isDigit(Str[1])) {
403  Str = Str.substr(1);
404  return 8;
405  }
406 
407  return 10;
408 }
409 
410 bool llvm::consumeUnsignedInteger(StringRef &Str, unsigned Radix,
411  unsigned long long &Result) {
412  // Autosense radix if not specified.
413  if (Radix == 0)
414  Radix = GetAutoSenseRadix(Str);
415 
416  // Empty strings (after the radix autosense) are invalid.
417  if (Str.empty()) return true;
418 
419  // Parse all the bytes of the string given this radix. Watch for overflow.
420  StringRef Str2 = Str;
421  Result = 0;
422  while (!Str2.empty()) {
423  unsigned CharVal;
424  if (Str2[0] >= '0' && Str2[0] <= '9')
425  CharVal = Str2[0] - '0';
426  else if (Str2[0] >= 'a' && Str2[0] <= 'z')
427  CharVal = Str2[0] - 'a' + 10;
428  else if (Str2[0] >= 'A' && Str2[0] <= 'Z')
429  CharVal = Str2[0] - 'A' + 10;
430  else
431  break;
432 
433  // If the parsed value is larger than the integer radix, we cannot
434  // consume any more characters.
435  if (CharVal >= Radix)
436  break;
437 
438  // Add in this character.
439  unsigned long long PrevResult = Result;
440  Result = Result * Radix + CharVal;
441 
442  // Check for overflow by shifting back and seeing if bits were lost.
443  if (Result / Radix < PrevResult)
444  return true;
445 
446  Str2 = Str2.substr(1);
447  }
448 
449  // We consider the operation a failure if no characters were consumed
450  // successfully.
451  if (Str.size() == Str2.size())
452  return true;
453 
454  Str = Str2;
455  return false;
456 }
457 
458 bool llvm::consumeSignedInteger(StringRef &Str, unsigned Radix,
459  long long &Result) {
460  unsigned long long ULLVal;
461 
462  // Handle positive strings first.
463  if (Str.empty() || Str.front() != '-') {
464  if (consumeUnsignedInteger(Str, Radix, ULLVal) ||
465  // Check for value so large it overflows a signed value.
466  (long long)ULLVal < 0)
467  return true;
468  Result = ULLVal;
469  return false;
470  }
471 
472  // Get the positive part of the value.
473  StringRef Str2 = Str.drop_front(1);
474  if (consumeUnsignedInteger(Str2, Radix, ULLVal) ||
475  // Reject values so large they'd overflow as negative signed, but allow
476  // "-0". This negates the unsigned so that the negative isn't undefined
477  // on signed overflow.
478  (long long)-ULLVal > 0)
479  return true;
480 
481  Str = Str2;
482  Result = -ULLVal;
483  return false;
484 }
485 
486 /// GetAsUnsignedInteger - Workhorse method that converts a integer character
487 /// sequence of radix up to 36 to an unsigned long long value.
488 bool llvm::getAsUnsignedInteger(StringRef Str, unsigned Radix,
489  unsigned long long &Result) {
490  if (consumeUnsignedInteger(Str, Radix, Result))
491  return true;
492 
493  // For getAsUnsignedInteger, we require the whole string to be consumed or
494  // else we consider it a failure.
495  return !Str.empty();
496 }
497 
498 bool llvm::getAsSignedInteger(StringRef Str, unsigned Radix,
499  long long &Result) {
500  if (consumeSignedInteger(Str, Radix, Result))
501  return true;
502 
503  // For getAsSignedInteger, we require the whole string to be consumed or else
504  // we consider it a failure.
505  return !Str.empty();
506 }
507 
508 bool StringRef::getAsInteger(unsigned Radix, APInt &Result) const {
509  StringRef Str = *this;
510 
511  // Autosense radix if not specified.
512  if (Radix == 0)
513  Radix = GetAutoSenseRadix(Str);
514 
515  assert(Radix > 1 && Radix <= 36);
516 
517  // Empty strings (after the radix autosense) are invalid.
518  if (Str.empty()) return true;
519 
520  // Skip leading zeroes. This can be a significant improvement if
521  // it means we don't need > 64 bits.
522  while (!Str.empty() && Str.front() == '0')
523  Str = Str.substr(1);
524 
525  // If it was nothing but zeroes....
526  if (Str.empty()) {
527  Result = APInt(64, 0);
528  return false;
529  }
530 
531  // (Over-)estimate the required number of bits.
532  unsigned Log2Radix = 0;
533  while ((1U << Log2Radix) < Radix) Log2Radix++;
534  bool IsPowerOf2Radix = ((1U << Log2Radix) == Radix);
535 
536  unsigned BitWidth = Log2Radix * Str.size();
537  if (BitWidth < Result.getBitWidth())
538  BitWidth = Result.getBitWidth(); // don't shrink the result
539  else if (BitWidth > Result.getBitWidth())
540  Result = Result.zext(BitWidth);
541 
542  APInt RadixAP, CharAP; // unused unless !IsPowerOf2Radix
543  if (!IsPowerOf2Radix) {
544  // These must have the same bit-width as Result.
545  RadixAP = APInt(BitWidth, Radix);
546  CharAP = APInt(BitWidth, 0);
547  }
548 
549  // Parse all the bytes of the string given this radix.
550  Result = 0;
551  while (!Str.empty()) {
552  unsigned CharVal;
553  if (Str[0] >= '0' && Str[0] <= '9')
554  CharVal = Str[0]-'0';
555  else if (Str[0] >= 'a' && Str[0] <= 'z')
556  CharVal = Str[0]-'a'+10;
557  else if (Str[0] >= 'A' && Str[0] <= 'Z')
558  CharVal = Str[0]-'A'+10;
559  else
560  return true;
561 
562  // If the parsed value is larger than the integer radix, the string is
563  // invalid.
564  if (CharVal >= Radix)
565  return true;
566 
567  // Add in this character.
568  if (IsPowerOf2Radix) {
569  Result <<= Log2Radix;
570  Result |= CharVal;
571  } else {
572  Result *= RadixAP;
573  CharAP = CharVal;
574  Result += CharAP;
575  }
576 
577  Str = Str.substr(1);
578  }
579 
580  return false;
581 }
582 
583 bool StringRef::getAsDouble(double &Result, bool AllowInexact) const {
584  APFloat F(0.0);
585  auto StatusOrErr = F.convertFromString(*this, APFloat::rmNearestTiesToEven);
586  if (errorToBool(StatusOrErr.takeError()))
587  return true;
588 
589  APFloat::opStatus Status = *StatusOrErr;
590  if (Status != APFloat::opOK) {
591  if (!AllowInexact || !(Status & APFloat::opInexact))
592  return true;
593  }
594 
595  Result = F.convertToDouble();
596  return false;
597 }
598 
599 // Implementation of StringRef hashing.
601  return hash_combine_range(S.begin(), S.end());
602 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
i
i
Definition: README.txt:29
llvm::StringRef::startswith_lower
LLVM_NODISCARD bool startswith_lower(StringRef Prefix) const
Check if this string starts with the given Prefix, ignoring case.
Definition: StringRef.cpp:47
llvm::StringRef::startswith
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:289
llvm::APFloatBase::opStatus
opStatus
IEEE-754R 7: Default exception handling.
Definition: APFloat.h:206
llvm
Definition: AllocatorList.h:23
llvm::StringRef::empty
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:156
llvm::StringRef::count
LLVM_NODISCARD size_t count(char C) const
Return the number of occurrences of C in the string.
Definition: StringRef.h:490
llvm::cl::Prefix
@ Prefix
Definition: CommandLine.h:164
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:378
StringRef.h
llvm::StringRef::npos
static constexpr size_t npos
Definition: StringRef.h:59
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:318
memcmp
Merge contiguous icmps into a memcmp
Definition: MergeICmps.cpp:928
Error.h
llvm::StringRef::find_lower
LLVM_NODISCARD size_t find_lower(char C, size_t From=0) const
Search for the first character C in the string, ignoring case.
Definition: StringRef.cpp:58
APInt.h
llvm::StringRef::getAsDouble
bool getAsDouble(double &Result, bool AllowInexact=true) const
Parse the current string as an IEEE double-precision floating point value.
Definition: StringRef.cpp:583
Hashing.h
llvm::hash_value
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
Definition: APFloat.cpp:4803
size_t
llvm::map_iterator
mapped_iterator< ItTy, FuncTy > map_iterator(ItTy I, FuncTy F)
Definition: STLExtras.h:297
F
#define F(x, y, z)
Definition: MD5.cpp:56
edit_distance.h
llvm::StringRef::endswith_lower
LLVM_NODISCARD bool endswith_lower(StringRef Suffix) const
Check if this string ends with the given Suffix, ignoring case.
Definition: StringRef.cpp:53
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:612
llvm::consumeSignedInteger
bool consumeSignedInteger(StringRef &Str, unsigned Radix, long long &Result)
Definition: StringRef.cpp:458
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:439
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
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:730
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::StringRef::rfind_lower
LLVM_NODISCARD size_t rfind_lower(char C, size_t From=npos) const
Search for the last character C in the string, ignoring case.
Definition: StringRef.cpp:187
llvm::getAsUnsignedInteger
bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result)
Helper functions for StringRef::getAsInteger.
Definition: StringRef.cpp:488
llvm::APFloatBase::opInexact
@ opInexact
Definition: APFloat.h:212
llvm::StringRef::compare_lower
LLVM_NODISCARD int compare_lower(StringRef RHS) const
compare_lower - Compare two strings, ignoring case.
Definition: StringRef.cpp:38
llvm::APFloatBase::opOK
@ opOK
Definition: APFloat.h:207
APFloat.h
This file declares a class to represent arbitrary precision floating point values and provide a varie...
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:511
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:190
llvm::APFloat
Definition: APFloat.h:701
llvm::StringRef::upper
LLVM_NODISCARD std::string upper() const
Convert the given ASCII string to uppercase.
Definition: StringRef.cpp:113
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::StringRef::end
iterator end() const
Definition: StringRef.h:133
llvm::consumeUnsignedInteger
bool consumeUnsignedInteger(StringRef &Str, unsigned Radix, unsigned long long &Result)
Definition: StringRef.cpp:410
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:57
llvm::StringRef::front
LLVM_NODISCARD char front() const
front - Get the first character in the string.
Definition: StringRef.h:164
I
#define I(x, y, z)
Definition: MD5.cpp:59
ascii_strncasecmp
static int ascii_strncasecmp(const char *LHS, const char *RHS, size_t Length)
Definition: StringRef.cpp:27
StringExtras.h
llvm::StringRef::lower
LLVM_NODISCARD std::string lower() const
Definition: StringRef.cpp:108
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::StringRef::find_first_not_of
LLVM_NODISCARD size_t find_first_not_of(char C, size_t From=0) const
Find the first character in the string that is not C or npos if not found.
Definition: StringRef.cpp:244
llvm::errorToBool
bool errorToBool(Error Err)
Helper for converting an Error to a bool.
Definition: Error.h:1029
llvm::StringRef::compare_numeric
LLVM_NODISCARD int compare_numeric(StringRef RHS) const
compare_numeric - Compare two strings, treating sequences of digits as numbers.
Definition: StringRef.cpp:64
Status
Definition: SIModeRegister.cpp:28
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:70
isDigit
static bool isDigit(const char C)
Definition: RustDemangle.cpp:81
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:57
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::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:654
llvm::BitWidth
constexpr unsigned BitWidth
Definition: BitmaskEnum.h:147
llvm::StringRef::equals_lower
LLVM_NODISCARD bool equals_lower(StringRef RHS) const
equals_lower - Check for string equality, ignoring case.
Definition: StringRef.h:197
llvm::makeArrayRef
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:474
This
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 This
Definition: README.txt:418
llvm::getAsSignedInteger
bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result)
Definition: StringRef.cpp:498
llvm::ComputeEditDistance
unsigned ComputeEditDistance(ArrayRef< T > FromArray, ArrayRef< T > ToArray, bool AllowReplacements=true, unsigned MaxEditDistance=0)
Determine the edit distance between two sequences.
Definition: edit_distance.h:42
llvm::APFloatBase::rmNearestTiesToEven
static constexpr roundingMode rmNearestTiesToEven
Definition: APFloat.h:190
N
#define N
llvm::hash_combine_range
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Definition: Hashing.h:482
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:152
llvm::SmallVectorImpl< StringRef >
llvm::StringRef::find_last_not_of
LLVM_NODISCARD size_t find_last_not_of(char C, size_t From=npos) const
Find the last character in the string that is not C, or npos if not found.
Definition: StringRef.cpp:285
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:413
llvm::StringRef::edit_distance
LLVM_NODISCARD unsigned edit_distance(StringRef Other, bool AllowReplacements=true, unsigned MaxEditDistance=0) const
Determine the edit distance between this string and another string.
Definition: StringRef.cpp:95
GetAutoSenseRadix
static unsigned GetAutoSenseRadix(StringRef &Str)
Definition: StringRef.cpp:383
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:340
From
BlockVerifier::State From
Definition: BlockVerifier.cpp:55
LLVM_UNLIKELY
#define LLVM_UNLIKELY(EXPR)
Definition: Compiler.h:220
llvm::StringRef::size
LLVM_NODISCARD size_t size() const
size - Get the string size.
Definition: StringRef.h:160
llvm::StringRef::begin
iterator begin() const
Definition: StringRef.h:131
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1167
llvm::hash_code
An opaque object representing a hash code.
Definition: Hashing.h:72