1//===- StringRef.h - Constant String Reference Wrapper ----------*- C++ -*-===// 
  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 
  7//===----------------------------------------------------------------------===// 
  9#ifndef LLVM_ADT_STRINGREF_H 
  10#define LLVM_ADT_STRINGREF_H 
  34 /// Helper functions for StringRef::getAsInteger. 
  36 unsigned long long &Result);
 
  44 unsigned long long &Result);
 
  48 /// StringRef - Represent a constant reference to a string, i.e. a character 
  49 /// array and a length, which need not be null terminated. 
  51 /// This class does not own the string data, it is expected to be used in 
  52 /// situations where the character data resides in some other buffer, whose 
  53 /// lifetime extends past that of the StringRef. For this reason, it is not in 
  54 /// general safe to store a StringRef. 
  57  static constexpr size_t npos = ~size_t(0);
 
  67 /// The start of the string, in an external buffer. 
  68 const char *Data = 
nullptr;
 
  70 /// The length of the string. 
  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);
 
  81 /// @name Constructors 
  84 /// Construct an empty string ref. 
  87 /// Disable conversion from nullptr. This prevents things like 
  91 /// Construct a string ref from a cstring. 
  95 /// Construct a string ref from a pointer and length. 
  98 : Data(
data), Length(length) {}
 
 
  100 /// Construct a string ref from an std::string. 
  102 : Data(Str.
data()), Length(Str.length()) {}
 
 
  104 /// Construct a string ref from an std::string_view. 
  106 : Data(Str.
data()), Length(Str.
size()) {}
 
 
  117 return std::make_reverse_iterator(
end());
 
 
  121 return std::make_reverse_iterator(
begin());
 
 
  125 return reinterpret_cast<const unsigned char *
>(
begin());
 
 
  128 return reinterpret_cast<const unsigned char *
>(
end());
 
 
  135 /// @name String Operations 
  138 /// data - Get a pointer to the start of the string (which may not be null 
  140  [[nodiscard]] 
constexpr const char *
data()
 const { 
return Data; }
 
  142 /// empty - Check if the string is empty. 
  143  [[nodiscard]] 
constexpr bool empty()
 const { 
return size() == 0; }
 
  145 /// size - Get the string size. 
  146  [[nodiscard]] 
constexpr size_t size()
 const { 
return Length; }
 
  148 /// front - Get the first character in the string. 
  154 /// back - Get the last character in the string. 
  155  [[nodiscard]] 
char back()
 const {
 
 
  160 // copy - Allocate copy in Allocator and return StringRef to it. 
  161 template <
typename Allocator>
 
  163 // Don't request a length 0 copy from the allocator. 
  166 char *S = 
A.template Allocate<char>(
size());
 
 
  171 /// Check for string equality, ignoring case. 
  176 /// compare - Compare two strings; the result is negative, zero, or positive 
  177 /// if this string is lexicographically less than, equal to, or greater than 
  180 // Check the prefix for a mismatch. 
  183 return Res < 0 ? -1 : 1;
 
  185 // Otherwise the prefixes match, so we only need to check the lengths. 
  188 return size() < 
RHS.size() ? -1 : 1;
 
 
  191 /// Compare two strings, ignoring case. 
  194 /// compare_numeric - Compare two strings, treating sequences of digits as 
  198 /// Determine the edit distance between this string and another 
  201 /// \param Other the string to compare this string against. 
  203 /// \param AllowReplacements whether to allow character 
  204 /// replacements (change one character into another) as a single 
  205 /// operation, rather than as two operations (an insertion and a 
  208 /// \param MaxEditDistance If non-zero, the maximum edit distance that 
  209 /// this routine is allowed to compute. If the edit distance will exceed 
  210 /// that maximum, returns \c MaxEditDistance+1. 
  212 /// \returns the minimum number of character insertions, removals, 
  213 /// or (if \p AllowReplacements is \c true) replacements needed to 
  214 /// transform one of the given strings into the other. If zero, 
  215 /// the strings are identical. 
  218 unsigned MaxEditDistance = 0) 
const;
 
  221 edit_distance_insensitive(
StringRef Other, 
bool AllowReplacements = 
true,
 
  222 unsigned MaxEditDistance = 0) 
const;
 
  224 /// str - Get the contents as an std::string. 
  225  [[nodiscard]] std::string 
str()
 const {
 
  227 return std::string();
 
 
  232 /// @name Operator Overloads 
  237 return data()[Index];
 
 
  240 /// Disallow accidental assignment from a temporary std::string. 
  242 /// The declaration here is extra complicated so that `stringRef = {}` 
  243 /// and `stringRef = "abc"` continue to select the move assignment operator. 
  244 template <
typename T>
 
  245 std::enable_if_t<std::is_same<T, std::string>::value, 
StringRef> &
 
  249 /// @name Type Conversions 
  252  constexpr operator std::string_view()
 const {
 
  253 return std::string_view(
data(), 
size());
 
 
  257 /// @name String Predicates 
  260 /// Check if this string starts with the given \p Prefix. 
  262 return size() >= Prefix.size() &&
 
  263 compareMemory(
data(), Prefix.data(), Prefix.size()) == 0;
 
 
  269 /// Check if this string starts with the given \p Prefix, ignoring case. 
  272 /// Check if this string ends with the given \p Suffix. 
  275 compareMemory(
end() - Suffix.
size(), Suffix.
data(),
 
 
  282 /// Check if this string ends with the given \p Suffix, ignoring case. 
  286 /// @name String Searching 
  289 /// Search for the first character \p C in the string. 
  291 /// \returns The index of the first occurrence of \p C, or npos if not 
  293  [[nodiscard]] 
size_t find(
char C, 
size_t From = 0)
 const {
 
  294 return std::string_view(*this).find(
C, From);
 
 
  297 /// Search for the first character \p C in the string, ignoring case. 
  299 /// \returns The index of the first occurrence of \p C, or npos if not 
  301 [[nodiscard]] 
LLVM_ABI size_t find_insensitive(
char C,
 
  302 size_t From = 0) 
const;
 
  304 /// Search for the first character satisfying the predicate \p F 
  306 /// \returns The index of the first character satisfying \p F starting from 
  307 /// \p From, or npos if not found. 
  309 size_t From = 0)
 const {
 
 
  319 /// Search for the first character not satisfying the predicate \p F 
  321 /// \returns The index of the first character not satisfying \p F starting 
  322 /// from \p From, or npos if not found. 
  324 size_t From = 0)
 const {
 
  325 return find_if([
F](
char c) { 
return !
F(c); }, From);
 
 
  328 /// Search for the first string \p Str in the string. 
  330 /// \returns The index of the first occurrence of \p Str, or npos if not 
  334 /// Search for the first string \p Str in the string, ignoring case. 
  336 /// \returns The index of the first occurrence of \p Str, or npos if not 
  339 size_t From = 0) 
const;
 
  341 /// Search for the last character \p C in the string. 
  343 /// \returns The index of the last occurrence of \p C, or npos if not 
  345  [[nodiscard]] 
size_t rfind(
char C, 
size_t From = 
npos)
 const {
 
  346 size_t I = std::min(From, 
size());
 
 
  355 /// Search for the last character \p C in the string, ignoring case. 
  357 /// \returns The index of the last occurrence of \p C, or npos if not 
  359 [[nodiscard]] 
LLVM_ABI size_t rfind_insensitive(
char C,
 
  360 size_t From = 
npos) 
const;
 
  362 /// Search for the last string \p Str in the string. 
  364 /// \returns The index of the last occurrence of \p Str, or npos if not 
  368 /// Search for the last string \p Str in the string, ignoring case. 
  370 /// \returns The index of the last occurrence of \p Str, or npos if not 
  374 /// Find the first character in the string that is \p C, or npos if not 
  375 /// found. Same as find. 
  377 return find(
C, From);
 
 
  380 /// Find the first character in the string that is in \p Chars, or npos if 
  383 /// Complexity: O(size() + Chars.size()) 
  385 size_t From = 0) 
const;
 
  387 /// Find the first character in the string that is not \p C or npos if not 
  389 [[nodiscard]] 
LLVM_ABI size_t find_first_not_of(
char C,
 
  390 size_t From = 0) 
const;
 
  392 /// Find the first character in the string that is not in the string 
  393 /// \p Chars, or npos if not found. 
  395 /// Complexity: O(size() + Chars.size()) 
  397 size_t From = 0) 
const;
 
  399 /// Find the last character in the string that is \p C, or npos if not 
  405 /// Find the last character in the string that is in \p C, or npos if not 
  408 /// Complexity: O(size() + Chars.size()) 
  410 size_t From = 
npos) 
const;
 
  412 /// Find the last character in the string that is not \p C, or npos if not 
  414 [[nodiscard]] 
LLVM_ABI size_t find_last_not_of(
char C,
 
  415 size_t From = 
npos) 
const;
 
  417 /// Find the last character in the string that is not in \p Chars, or 
  418 /// npos if not found. 
  420 /// Complexity: O(size() + Chars.size()) 
  422 size_t From = 
npos) 
const;
 
  424 /// Return true if the given string is a substring of *this, and false 
  430 /// Return true if the given character is contained in *this, and false 
  436 /// Return true if the given string is a substring of *this, and false 
  442 /// Return true if the given character is contained in *this, and false 
  449 /// @name Helpful Algorithms 
  452 /// Return the number of occurrences of \p C in the string. 
  453  [[nodiscard]] 
size_t count(
char C)
 const {
 
  455 for (
size_t I = 0; 
I != 
size(); ++
I)
 
 
  461 /// Return the number of non-overlapped occurrences of \p Str in 
  465 /// Parse the current string as an integer of the specified radix. If 
  466 /// \p Radix is specified as zero, this does radix autosensing using 
  467 /// extended C rules: 0 is octal, 0x is hex, 0b is binary. 
  469 /// If the string is invalid or if only a subset of the string is valid, 
  470 /// this returns true to signify the error. The string is considered 
  471 /// erroneous if empty or if it overflows T. 
  473 if constexpr (std::numeric_limits<T>::is_signed) {
 
  476 static_cast<T >(LLVal) != LLVal)
 
  480 unsigned long long ULLVal;
 
  481 // The additional cast to unsigned long long is required to avoid the 
  482 // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type 
  483 // 'unsigned __int64' when instantiating getAsInteger with T = bool. 
  485 static_cast<unsigned long long>(
static_cast<T >(ULLVal)) != ULLVal)
 
 
  492 /// Parse the current string as an integer of the specified radix. If 
  493 /// \p Radix is specified as zero, this does radix autosensing using 
  494 /// extended C rules: 0 is octal, 0x is hex, 0b is binary. 
  496 /// If the string does not begin with a number of the specified radix, 
  497 /// this returns true to signify the error. The string is considered 
  498 /// erroneous if empty or if it overflows T. 
  499 /// The portion of the string representing the discovered numeric value 
  500 /// is removed from the beginning of the string. 
  502 if constexpr (std::numeric_limits<T>::is_signed) {
 
  505 static_cast<long long>(
static_cast<T >(LLVal)) != LLVal)
 
  509 unsigned long long ULLVal;
 
  511 static_cast<unsigned long long>(
static_cast<T >(ULLVal)) != ULLVal)
 
 
  518 /// Parse the current string as an integer of the specified \p Radix, or of 
  519 /// an autosensed radix if the \p Radix given is 0. The current value in 
  520 /// \p Result is discarded, and the storage is changed to be wide enough to 
  521 /// store the parsed integer. 
  523 /// \returns true if the string does not solely consist of a valid 
  524 /// non-empty number in the appropriate base. 
  526 /// APInt::fromString is superficially similar but assumes the 
  527 /// string is well-formed in the given radix. 
  528 LLVM_ABI bool getAsInteger(
unsigned Radix, 
APInt &Result) 
const;
 
  530 /// Parse the current string as an integer of the specified \p Radix. If 
  531 /// \p Radix is specified as zero, this does radix autosensing using 
  532 /// extended C rules: 0 is octal, 0x is hex, 0b is binary. 
  534 /// If the string does not begin with a number of the specified radix, 
  535 /// this returns true to signify the error. The string is considered 
  536 /// erroneous if empty. 
  537 /// The portion of the string representing the discovered numeric value 
  538 /// is removed from the beginning of the string. 
  541 /// Parse the current string as an IEEE double-precision floating 
  542 /// point value. The string must be a well-formed double. 
  544 /// If \p AllowInexact is false, the function will fail if the string 
  545 /// cannot be represented exactly. Otherwise, the function only fails 
  546 /// in case of an overflow or underflow, or an invalid floating point 
  548 LLVM_ABI bool getAsDouble(
double &Result, 
bool AllowInexact = 
true) 
const;
 
  551 /// @name String Operations 
  554 // Convert the given ASCII string to lowercase. 
  555 [[nodiscard]] 
LLVM_ABI std::string lower() 
const;
 
  557 /// Convert the given ASCII string to uppercase. 
  558 [[nodiscard]] 
LLVM_ABI std::string upper() 
const;
 
  561 /// @name Substring Operations 
  564 /// Return a reference to the substring from [Start, Start + N). 
  566 /// \param Start The index of the starting character in the substring; if 
  567 /// the index is npos or greater than the length of the string then the 
  568 /// empty substring will be returned. 
  570 /// \param N The number of characters to included in the substring. If N 
  571 /// exceeds the number of characters remaining in the string, the string 
  572 /// suffix (starting with \p Start) will be returned. 
  574 size_t N = 
npos)
 const {
 
  575 Start = std::min(Start, 
size());
 
 
  579 /// Return a StringRef equal to 'this' but with only the first \p N 
  580 /// elements remaining. If \p N is greater than the length of the 
  581 /// string, the entire string is returned. 
  588 /// Return a StringRef equal to 'this' but with only the last \p N 
  589 /// elements remaining. If \p N is greater than the length of the 
  590 /// string, the entire string is returned. 
  597 /// Return the longest prefix of 'this' such that every character 
  598 /// in the prefix satisfies the given predicate. 
  603 /// Return the longest prefix of 'this' such that no character in 
  604 /// the prefix satisfies the given predicate. 
  609 /// Return a StringRef equal to 'this' but with the first \p N elements 
  612 assert(
size() >= 
N && 
"Dropping more elements than exist");
 
 
  616 /// Return a StringRef equal to 'this' but with the last \p N elements 
  619 assert(
size() >= 
N && 
"Dropping more elements than exist");
 
 
  623 /// Return a StringRef equal to 'this', but with all characters satisfying 
  624 /// the given predicate dropped from the beginning of the string. 
  629 /// Return a StringRef equal to 'this', but with all characters not 
  630 /// satisfying the given predicate dropped from the beginning of the string. 
  635 /// Returns true if this StringRef has the given prefix and removes that 
  641 *
this = 
substr(Prefix.size());
 
 
  645 /// Returns true if this StringRef has the given prefix, ignoring case, 
  646 /// and removes that prefix. 
  651 *
this = 
substr(Prefix.size());
 
 
  655 /// Returns true if this StringRef has the given suffix and removes that 
  665 /// Returns true if this StringRef has the given suffix, ignoring case, 
  666 /// and removes that suffix. 
  675 /// Return a reference to the substring from [Start, End). 
  677 /// \param Start The index of the starting character in the substring; if 
  678 /// the index is npos or greater than the length of the string then the 
  679 /// empty substring will be returned. 
  681 /// \param End The index following the last character to include in the 
  682 /// substring. If this is npos or exceeds the number of characters 
  683 /// remaining in the string, the string suffix (starting with \p Start) 
  684 /// will be returned. If this is less than \p Start, an empty string will 
  687 Start = std::min(Start, 
size());
 
  688 End = std::clamp(End, Start, 
size());
 
 
  692 /// Split into two substrings around the first occurrence of a separator 
  695 /// If \p Separator is in the string, then the result is a pair (LHS, RHS) 
  696 /// such that (*this == LHS + Separator + RHS) is true and RHS is 
  697 /// maximal. If \p Separator is not in the string, then the result is a 
  698 /// pair (LHS, RHS) where (*this == LHS) and (RHS == ""). 
  700 /// \param Separator The character to split on. 
  701 /// \returns The split substrings. 
  702  [[nodiscard]] std::pair<StringRef, StringRef> 
split(
char Separator)
 const {
 
 
  706 /// Split into two substrings around the first occurrence of a separator 
  709 /// If \p Separator is in the string, then the result is a pair (LHS, RHS) 
  710 /// such that (*this == LHS + Separator + RHS) is true and RHS is 
  711 /// maximal. If \p Separator is not in the string, then the result is a 
  712 /// pair (LHS, RHS) where (*this == LHS) and (RHS == ""). 
  714 /// \param Separator - The string to split on. 
  715 /// \return - The split substrings. 
  716 [[nodiscard]] std::pair<StringRef, StringRef>
 
  718 size_t Idx = 
find(Separator);
 
 
  724 /// Split into two substrings around the last occurrence of a separator 
  727 /// If \p Separator is in the string, then the result is a pair (LHS, RHS) 
  728 /// such that (*this == LHS + Separator + RHS) is true and RHS is 
  729 /// minimal. If \p Separator is not in the string, then the result is a 
  730 /// pair (LHS, RHS) where (*this == LHS) and (RHS == ""). 
  732 /// \param Separator - The string to split on. 
  733 /// \return - The split substrings. 
  734 [[nodiscard]] std::pair<StringRef, StringRef>
 
  736 size_t Idx = 
rfind(Separator);
 
 
  742 /// Split into substrings around the occurrences of a separator string. 
  744 /// Each substring is stored in \p A. If \p MaxSplit is >= 0, at most 
  745 /// \p MaxSplit splits are done and consequently <= \p MaxSplit + 1 
  746 /// elements are added to A. 
  747 /// If \p KeepEmpty is false, empty strings are not added to \p A. They 
  748 /// still count when considering \p MaxSplit 
  749 /// An useful invariant is that 
  750 /// Separator.join(A) == *this if MaxSplit == -1 and KeepEmpty == true 
  752 /// \param A - Where to put the substrings. 
  753 /// \param Separator - The string to split on. 
  754 /// \param MaxSplit - The maximum number of times the string is split. 
  755 /// \param KeepEmpty - True if empty substring should be added. 
  757 int MaxSplit = -1, 
bool KeepEmpty = 
true) 
const;
 
  759 /// Split into substrings around the occurrences of a separator character. 
  761 /// Each substring is stored in \p A. If \p MaxSplit is >= 0, at most 
  762 /// \p MaxSplit splits are done and consequently <= \p MaxSplit + 1 
  763 /// elements are added to A. 
  764 /// If \p KeepEmpty is false, empty strings are not added to \p A. They 
  765 /// still count when considering \p MaxSplit 
  766 /// An useful invariant is that 
  767 /// Separator.join(A) == *this if MaxSplit == -1 and KeepEmpty == true 
  769 /// \param A - Where to put the substrings. 
  770 /// \param Separator - The string to split on. 
  771 /// \param MaxSplit - The maximum number of times the string is split. 
  772 /// \param KeepEmpty - True if empty substring should be added. 
  774 int MaxSplit = -1, 
bool KeepEmpty = 
true) 
const;
 
  776 /// Split into two substrings around the last occurrence of a separator 
  779 /// If \p Separator is in the string, then the result is a pair (LHS, RHS) 
  780 /// such that (*this == LHS + Separator + RHS) is true and RHS is 
  781 /// minimal. If \p Separator is not in the string, then the result is a 
  782 /// pair (LHS, RHS) where (*this == LHS) and (RHS == ""). 
  784 /// \param Separator - The character to split on. 
  785 /// \return - The split substrings. 
  786  [[nodiscard]] std::pair<StringRef, StringRef> 
rsplit(
char Separator)
 const {
 
 
  790 /// Return string with consecutive \p Char characters starting from the 
  791 /// the left removed. 
  796 /// Return string with consecutive characters in \p Chars starting from 
  797 /// the left removed. 
  802 /// Return string with consecutive \p Char characters starting from the 
  808 /// Return string with consecutive characters in \p Chars starting from 
  809 /// the right removed. 
  814 /// Return string with consecutive \p Char characters starting from the 
  815 /// left and right removed. 
  817 return ltrim(Char).rtrim(Char);
 
 
  820 /// Return string with consecutive characters in \p Chars starting from 
  821 /// the left and right removed. 
  823 return ltrim(Chars).rtrim(Chars);
 
 
  826 /// Detect the line ending style of the string. 
  828 /// If the string contains a line ending, return the line ending character 
  829 /// sequence that is detected. Otherwise return '\n' for unix line endings. 
  831 /// \return - The line ending character sequence. 
  833 size_t Pos = 
find(
'\r');
 
  835 // If there is no carriage return, assume unix 
  838 if (Pos + 1 < 
size() && 
data()[Pos + 1] == 
'\n')
 
  839 return "\r\n"; 
// Windows 
  840 if (Pos > 0 && 
data()[Pos - 1] == 
'\n')
 
  841 return "\n\r"; 
// You monster! 
  842 return "\r"; 
// Classic Mac 
 
 
  847 /// A wrapper around a string literal that serves as a proxy for constructing 
  848 /// global tables of StringRefs with the length computed at compile time. 
  849 /// In order to avoid the invocation of a global constructor, StringLiteral 
  850 /// should *only* be used in a constexpr context, as such: 
  852 /// constexpr StringLiteral S("test"); 
  856 constexpr StringLiteral(
const char *Str, 
size_t N) : 
StringRef(Str, 
N) {
 
  862#if defined(__clang__) && __has_attribute(enable_if) 
  863#pragma clang diagnostic push 
  864#pragma clang diagnostic ignored "-Wgcc-compat" 
  865 __attribute((enable_if(__builtin_strlen(Str) == 
N - 1,
 
  866 "invalid string literal")))
 
  867#pragma clang diagnostic pop 
 
  872 // Explicit construction for strings like "foo0円bar". 
  875 return StringLiteral(Str, 
N - 1);
 
 
 
  879 /// @name StringRef Comparison Operators 
  883 if (
LHS.size() != 
RHS.size())
 
  887 return ::memcmp(
LHS.data(), 
RHS.data(), 
LHS.size()) == 0;
 
 
  893 return LHS.compare(
RHS) < 0;
 
 
  897 return LHS.compare(
RHS) <= 0;
 
 
  901 return LHS.compare(
RHS) > 0;
 
 
  905 return LHS.compare(
RHS) >= 0;
 
 
  909 return buffer.append(
string.
data(), 
string.
size());
 
 
  914 /// Compute a hash_code for a StringRef. 
  917 // Provide DenseMapInfo for StringRefs. 
  921 reinterpret_cast<const char *
>(~
static_cast<uintptr_t
>(0)), 0);
 
 
  926 reinterpret_cast<const char *
>(~
static_cast<uintptr_t
>(1)), 0);
 
 
 
  940} 
// end namespace llvm 
  942#endif // LLVM_ADT_STRINGREF_H 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_LIFETIME_BOUND
#define LLVM_GSL_POINTER
LLVM_GSL_POINTER - Apply this to non-owning classes like StringRef to enable lifetime warnings.
static constexpr size_t npos
This file defines DenseMapInfo traits for DenseMap.
static StringRef substr(StringRef Str, uint64_t Len)
static const BasicSubtargetSubTypeKV * find(StringRef S, ArrayRef< BasicSubtargetSubTypeKV > A)
Find KV in array using binary search.
Class for arbitrary precision integers.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
constexpr StringLiteral(const char(&Str)[N])
static constexpr StringLiteral withInnerNUL(const char(&Str)[N])
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
LLVM_ABI 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.
StringRef trim(StringRef Chars=" \t\n\v\f\r") const
Return string with consecutive characters in Chars starting from the left and right removed.
bool consume_back(StringRef Suffix)
Returns true if this StringRef has the given suffix and removes that suffix.
bool consumeInteger(unsigned Radix, T &Result)
Parse the current string as an integer of the specified radix.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
iterator_range< const unsigned char * > bytes() const
std::string str() const
str - Get the contents as an std::string.
size_t find_if(function_ref< bool(char)> F, size_t From=0) const
Search for the first character satisfying the predicate F.
const unsigned char * bytes_end() const
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
empty - Check if the string is empty.
std::reverse_iterator< const_iterator > const_reverse_iterator
bool contains_insensitive(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
LLVM_ABI bool starts_with_insensitive(StringRef Prefix) const
Check if this string starts with the given Prefix, ignoring case.
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...
bool ends_with(char Suffix) const
char operator[](size_t Index) const
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
bool contains_insensitive(char C) const
Return true if the given character is contained in *this, and false otherwise.
std::pair< StringRef, StringRef > rsplit(char Separator) const
Split into two substrings around the last occurrence of a separator character.
const char * const_iterator
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...
char back() const
back - Get the last character in the string.
StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
constexpr size_t size() const
size - Get the string size.
char front() const
front - Get the first character in the string.
reverse_iterator rbegin() const
constexpr StringRef(const char *data LLVM_LIFETIME_BOUND, size_t length)
Construct a string ref from a pointer and length.
std::reverse_iterator< iterator > reverse_iterator
bool starts_with(char Prefix) const
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.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
StringRef ltrim(char Char) const
Return string with consecutive Char characters starting from the the left removed.
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
StringRef detectEOL() const
Detect the line ending style of the string.
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.
StringRef()=default
Construct an empty string ref.
size_t rfind(char C, size_t From=npos) const
Search for the last character C in the string.
StringRef rtrim(char Char) const
Return string with consecutive Char characters starting from the right removed.
constexpr StringRef(const char *Str LLVM_LIFETIME_BOUND)
Construct a string ref from a cstring.
bool contains(char C) const
Return true if the given character is contained in *this, and false otherwise.
StringRef(std::nullptr_t)=delete
Disable conversion from nullptr.
StringRef take_back(size_t N=1) const
Return a StringRef equal to 'this' but with only the last N elements remaining.
StringRef take_front(size_t N=1) const
Return a StringRef equal to 'this' but with only the first N elements remaining.
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...
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
StringRef trim(char Char) const
Return string with consecutive Char characters starting from the left and right removed.
LLVM_ABI size_t find_insensitive(char C, size_t From=0) const
Search for the first character C in the string, ignoring case.
size_t count(char C) const
Return the number of occurrences of C in the string.
bool consume_back_insensitive(StringRef Suffix)
Returns true if this StringRef has the given suffix, ignoring case, and removes that suffix.
StringRef copy(Allocator &A) const
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
std::pair< StringRef, StringRef > rsplit(StringRef Separator) const
Split into two substrings around the last occurrence of a separator string.
std::pair< StringRef, StringRef > split(StringRef Separator) const
Split into two substrings around the first occurrence of a separator string.
StringRef ltrim(StringRef Chars=" \t\n\v\f\r") const
Return string with consecutive characters in Chars starting from the left removed.
std::enable_if_t< std::is_same< T, std::string >::value, StringRef > & operator=(T &&Str)=delete
Disallow accidental assignment from a temporary std::string.
StringRef rtrim(StringRef Chars=" \t\n\v\f\r") const
Return string with consecutive characters in Chars starting from the right removed.
static constexpr size_t npos
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...
const unsigned char * bytes_begin() const
int compare(StringRef RHS) const
compare - Compare two strings; the result is negative, zero, or positive if this string is lexicograp...
StringRef drop_back(size_t N=1) const
Return a StringRef equal to 'this' but with the last N elements dropped.
bool equals_insensitive(StringRef RHS) const
Check for string equality, ignoring case.
LLVM_ABI bool ends_with_insensitive(StringRef Suffix) const
Check if this string ends with the given Suffix, ignoring case.
LLVM_ABI 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.
bool consume_front_insensitive(StringRef Prefix)
Returns true if this StringRef has the given prefix, ignoring case, and removes that prefix.
LLVM_ABI int compare_insensitive(StringRef RHS) const
Compare two strings, ignoring case.
StringRef(const std::string &Str)
Construct a string ref from an std::string.
constexpr operator std::string_view() const
reverse_iterator rend() const
constexpr StringRef(std::string_view Str)
Construct a string ref from an std::string_view.
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.
An efficient, type-erasing, non-owning reference to a callable.
An opaque object representing a hash code.
A range adaptor for a pair of iterators.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
bool operator<(int64_t V1, const APSInt &V2)
LLVM_ABI bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result)
hash_code hash_value(const FixedPointSemantics &Val)
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.
LLVM_ABI unsigned getAutoSenseRadix(StringRef &Str)
bool operator!=(uint64_t V1, const APInt &V2)
bool operator>=(int64_t V1, const APSInt &V2)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator+=(DynamicAPInt &A, int64_t B)
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
LLVM_ABI bool consumeUnsignedInteger(StringRef &Str, unsigned Radix, unsigned long long &Result)
bool operator>(int64_t V1, const APSInt &V2)
FunctionAddr VTableAddr Count
iterator_range< SplittingIterator > split(StringRef Str, StringRef Separator)
Split the specified string over a separator and return a range-compatible iterable over its partition...
LLVM_ABI bool consumeSignedInteger(StringRef &Str, unsigned Radix, long long &Result)
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...
LLVM_ABI bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result)
Helper functions for StringRef::getAsInteger.
bool operator<=(int64_t V1, const APSInt &V2)
Implement std::hash so that hash_code can be used in STL containers.
static StringRef getEmptyKey()
static bool isEqual(StringRef LHS, StringRef RHS)
static LLVM_ABI unsigned getHashValue(StringRef Val)
static StringRef getTombstoneKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...