LLVM  6.0.0svn
Public Types | Static Public Attributes | List of all members
llvm::StringRef Class Reference

StringRef - Represent a constant reference to a string, i.e. More...

#include "llvm/ADT/StringRef.h"

Inheritance diagram for llvm::StringRef:
Inheritance graph
[legend]
Collaboration diagram for llvm::StringRef:
Collaboration graph
[legend]

Public Types

using iterator = const char *
 
using const_iterator = const char *
 
using size_type = size_t
 

Public Member Functions

Iterators
iterator begin () const
 
iterator end () const
 
const unsigned charbytes_begin () const
 
const unsigned charbytes_end () const
 
iterator_range< const unsigned char * > bytes () const
 
String Operations
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const chardata () const
 data - Get a pointer to the start of the string (which may not be null terminated). More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty () const
 empty - Check if the string is empty. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size () const
 size - Get the string size. More...
 
LLVM_NODISCARD char front () const
 front - Get the first character in the string. More...
 
LLVM_NODISCARD char back () const
 back - Get the last character in the string. More...
 
template<typename Allocator >
LLVM_NODISCARD StringRef copy (Allocator &A) const
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool equals (StringRef RHS) const
 equals - Check for string equality, this is more efficient than compare() when the relative ordering of inequal strings isn't needed. More...
 
LLVM_NODISCARD bool equals_lower (StringRef RHS) const
 equals_lower - Check for string equality, ignoring case. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE int compare (StringRef RHS) const
 compare - Compare two strings; the result is -1, 0, or 1 if this string is lexicographically less than, equal to, or greater than the RHS. More...
 
LLVM_NODISCARD int compare_lower (StringRef RHS) const
 compare_lower - Compare two strings, ignoring case. More...
 
LLVM_NODISCARD int compare_numeric (StringRef RHS) const
 compare_numeric - Compare two strings, treating sequences of digits as numbers. More...
 
LLVM_NODISCARD unsigned edit_distance (StringRef Other, bool AllowReplacements=true, unsigned MaxEditDistance=0) const
 Determine the edit distance between this string and another string. More...
 
LLVM_NODISCARD std::string str () const
 str - Get the contents as an std::string. More...
 
LLVM_NODISCARD std::string lower () const
 
LLVM_NODISCARD std::string upper () const
 Convert the given ASCII string to uppercase. More...
 
Operator Overloads
LLVM_NODISCARD char operator[] (size_t Index) const
 
template<typename T >
std::enable_if< std::is_same< T, std::string >::value, StringRef >::type & operator= (T &&Str)=delete
 Disallow accidental assignment from a temporary std::string. More...
 
Type Conversions
 operator std::string () const
 
String Predicates
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith (StringRef Prefix) const
 Check if this string starts with the given Prefix. More...
 
LLVM_NODISCARD bool startswith_lower (StringRef Prefix) const
 Check if this string starts with the given Prefix, ignoring case. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool endswith (StringRef Suffix) const
 Check if this string ends with the given Suffix. More...
 
LLVM_NODISCARD bool endswith_lower (StringRef Suffix) const
 Check if this string ends with the given Suffix, ignoring case. More...
 
String Searching
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find (char C, size_t From=0) const
 Search for the first character C in the string. More...
 
LLVM_NODISCARD size_t find_lower (char C, size_t From=0) const
 Search for the first character C in the string, ignoring case. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find_if (function_ref< bool(char)> F, size_t From=0) const
 Search for the first character satisfying the predicate F. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE 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. More...
 
LLVM_NODISCARD size_t find (StringRef Str, size_t From=0) const
 Search for the first string Str in the string. More...
 
LLVM_NODISCARD size_t find_lower (StringRef Str, size_t From=0) const
 Search for the first string Str in the string, ignoring case. More...
 
LLVM_NODISCARD size_t rfind (char C, size_t From=npos) const
 Search for the last character C in the string. More...
 
LLVM_NODISCARD size_t rfind_lower (char C, size_t From=npos) const
 Search for the last character C in the string, ignoring case. More...
 
LLVM_NODISCARD size_t rfind (StringRef Str) const
 Search for the last string Str in the string. More...
 
LLVM_NODISCARD size_t rfind_lower (StringRef Str) const
 Search for the last string Str in the string, ignoring case. More...
 
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. More...
 
LLVM_NODISCARD size_t find_first_of (StringRef Chars, size_t From=0) const
 Find the first character in the string that is in Chars, or npos if not found. More...
 
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. More...
 
LLVM_NODISCARD size_t find_first_not_of (StringRef Chars, size_t From=0) const
 Find the first character in the string that is not in the string Chars, or npos if not found. More...
 
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. More...
 
LLVM_NODISCARD size_t find_last_of (StringRef Chars, size_t From=npos) const
 Find the last character in the string that is in C, or npos if not found. More...
 
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. More...
 
LLVM_NODISCARD size_t find_last_not_of (StringRef Chars, size_t From=npos) const
 Find the last character in the string that is not in Chars, or npos if not found. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool contains (StringRef Other) const
 Return true if the given string is a substring of *this, and false otherwise. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool contains (char C) const
 Return true if the given character is contained in *this, and false otherwise. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool contains_lower (StringRef Other) const
 Return true if the given string is a substring of *this, and false otherwise. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool contains_lower (char C) const
 Return true if the given character is contained in *this, and false otherwise. More...
 
Helpful Algorithms
LLVM_NODISCARD size_t count (char C) const
 Return the number of occurrences of C in the string. More...
 
size_t count (StringRef Str) const
 Return the number of non-overlapped occurrences of Str in the string. More...
 
template<typename T >
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger (unsigned Radix, T &Result) const
 Parse the current string as an integer of the specified radix. More...
 
template<typename T >
std::enable_if<!std::numeric_limits< T >::is_signed, bool >::type getAsInteger (unsigned Radix, T &Result) const
 
template<typename T >
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type consumeInteger (unsigned Radix, T &Result)
 Parse the current string as an integer of the specified radix. More...
 
template<typename T >
std::enable_if<!std::numeric_limits< T >::is_signed, bool >::type consumeInteger (unsigned Radix, T &Result)
 
bool getAsInteger (unsigned Radix, APInt &Result) const
 Parse the current string as an integer of the specified Radix, or of an autosensed radix if the Radix given is 0. More...
 
bool getAsDouble (double &Result, bool AllowInexact=true) const
 Parse the current string as an IEEE double-precision floating point value. More...
 
Substring Operations
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr (size_t Start, size_t N=npos) const
 Return a reference to the substring from [Start, Start + N). More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef take_front (size_t N=1) const
 Return a StringRef equal to 'this' but with only the first N elements remaining. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef take_back (size_t N=1) const
 Return a StringRef equal to 'this' but with only the last N elements remaining. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE 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 predicate. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE 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 predicate. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_front (size_t N=1) const
 Return a StringRef equal to 'this' but with the first N elements dropped. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_back (size_t N=1) const
 Return a StringRef equal to 'this' but with the last N elements dropped. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_while (function_ref< bool(char)> F) const
 Return a StringRef equal to 'this', but with all characters satisfying the given predicate dropped from the beginning of the string. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_until (function_ref< bool(char)> F) const
 Return a StringRef equal to 'this', but with all characters not satisfying the given predicate dropped from the beginning of the string. More...
 
LLVM_ATTRIBUTE_ALWAYS_INLINE bool consume_front (StringRef Prefix)
 Returns true if this StringRef has the given prefix and removes that prefix. More...
 
LLVM_ATTRIBUTE_ALWAYS_INLINE bool consume_back (StringRef Suffix)
 Returns true if this StringRef has the given suffix and removes that suffix. More...
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef slice (size_t Start, size_t End) const
 Return a reference to the substring from [Start, End). More...
 
LLVM_NODISCARD std::pair< StringRef, StringRefsplit (char Separator) const
 Split into two substrings around the first occurrence of a separator character. More...
 
LLVM_NODISCARD std::pair< StringRef, StringRefsplit (StringRef Separator) const
 Split into two substrings around the first occurrence of a separator string. More...
 
void split (SmallVectorImpl< StringRef > &A, StringRef Separator, int MaxSplit=-1, bool KeepEmpty=true) const
 Split into substrings around the occurrences of a separator string. More...
 
void split (SmallVectorImpl< StringRef > &A, char Separator, int MaxSplit=-1, bool KeepEmpty=true) const
 Split into substrings around the occurrences of a separator character. More...
 
LLVM_NODISCARD std::pair< StringRef, StringRefrsplit (char Separator) const
 Split into two substrings around the last occurrence of a separator character. More...
 
LLVM_NODISCARD StringRef ltrim (char Char) const
 Return string with consecutive Char characters starting from the the left removed. More...
 
LLVM_NODISCARD StringRef ltrim (StringRef Chars=" \\\) const
 Return string with consecutive characters in Chars starting from the left removed. More...
 
LLVM_NODISCARD StringRef rtrim (char Char) const
 Return string with consecutive Char characters starting from the right removed. More...
 
LLVM_NODISCARD StringRef rtrim (StringRef Chars=" \\\) const
 Return string with consecutive characters in Chars starting from the right removed. More...
 
LLVM_NODISCARD StringRef trim (char Char) const
 Return string with consecutive Char characters starting from the left and right removed. More...
 
LLVM_NODISCARD StringRef trim (StringRef Chars=" \\\) const
 Return string with consecutive characters in Chars starting from the left and right removed. More...
 

Static Public Attributes

static const size_t npos = ~size_t(0)
 

Constructors

 StringRef ()=default
 Construct an empty string ref. More...
 
 StringRef (std::nullptr_t)=delete
 Disable conversion from nullptr. More...
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef (const char *Str)
 Construct a string ref from a cstring. More...
 
LLVM_ATTRIBUTE_ALWAYS_INLINE constexpr StringRef (const char *data, size_t length)
 Construct a string ref from a pointer and length. More...
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef (const std::string &Str)
 Construct a string ref from an std::string. More...
 
static StringRef withNullAsEmpty (const char *data)
 

Detailed Description

StringRef - Represent a constant reference to a string, i.e.

a character array and a length, which need not be null terminated.

This class does not own the string data, it is expected to be used in situations where the character data resides in some other buffer, whose lifetime extends past that of the StringRef. For this reason, it is not in general safe to store a StringRef.

Definition at line 49 of file StringRef.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 54 of file StringRef.h.

◆ iterator

Definition at line 53 of file StringRef.h.

◆ size_type

Definition at line 55 of file StringRef.h.

Constructor & Destructor Documentation

◆ StringRef() [1/5]

llvm::StringRef::StringRef ( )
default

Construct an empty string ref.

Referenced by copy(), rsplit(), slice(), split(), substr(), and withNullAsEmpty().

◆ StringRef() [2/5]

llvm::StringRef::StringRef ( std::nullptr_t  )
delete

Disable conversion from nullptr.

This prevents things like if (S == nullptr)

◆ StringRef() [3/5]

LLVM_ATTRIBUTE_ALWAYS_INLINE llvm::StringRef::StringRef ( const char Str)
inline

Construct a string ref from a cstring.

Definition at line 85 of file StringRef.h.

References LLVM_ATTRIBUTE_ALWAYS_INLINE.

◆ StringRef() [4/5]

LLVM_ATTRIBUTE_ALWAYS_INLINE constexpr llvm::StringRef::StringRef ( const char data,
size_t  length 
)
inline

Construct a string ref from a pointer and length.

Definition at line 90 of file StringRef.h.

References LLVM_ATTRIBUTE_ALWAYS_INLINE.

◆ StringRef() [5/5]

LLVM_ATTRIBUTE_ALWAYS_INLINE llvm::StringRef::StringRef ( const std::string &  Str)
inline

Construct a string ref from an std::string.

Definition at line 95 of file StringRef.h.

Member Function Documentation

◆ back()

LLVM_NODISCARD char llvm::StringRef::back ( ) const
inline

◆ begin()

iterator llvm::StringRef::begin ( ) const
inline

Definition at line 106 of file StringRef.h.

Referenced by llvm::SmallString< 256 >::append(), llvm::sys::path::append(), llvm::SmallString< 256 >::assign(), llvm::MDString::begin(), llvm::yaml::BlockScalarNode::BlockScalarNode(), bytes_begin(), llvm::detail::IEEEFloat::convertFromString(), llvm::detail::IEEEFloat::convertFromZeroExtendedInteger(), llvm::convertUTF8ToUTF16String(), llvm::ConvertUTF8toWide(), copy(), llvm::MachineFunction::createExternalSymbolName(), llvm::sys::fs::createTemporaryFile(), decodeUTF8(), llvm::MCObjectStreamer::EmitBytes(), emitSignedInt64(), llvm::yaml::escape(), llvm::symbolize::LLVMSymbolizer::flush(), getAttrKindEncoding(), llvm::APInt::getBitsNeeded(), llvm::MemoryBufferRef::getBufferStart(), llvm::sys::detail::getHostCPUNameForPowerPC(), getHostID(), llvm::TGLexer::getLoc(), llvm::object::ArchiveMemberHeader::getName(), llvm::object::Archive::Symbol::getName(), llvm::object::Archive::getNumberOfSymbols(), llvm::StringToOffsetTable::GetOrAddStringOffset(), llvm::object::ELFFile< ELFT >::getRelocationTypeName(), llvm::object::WasmObjectFile::getRelocationTypeName(), llvm::object::MachOObjectFile::getRelocationTypeName(), llvm::object::COFFObjectFile::getRelocationTypeName(), llvm::ConstantDataArray::getString(), llvm::TargetLoweringObjectFile::getSymbolWithGlobalValueBase(), llvm::yaml::ScalarNode::getValue(), llvm::TextInstrProfReader::hasFormat(), llvm::hash_value(), llvm::pdb::hashStringV2(), hasUnaryFloatFn(), llvm::detail::IEEEFloat::IEEEFloat(), llvm::Timer::init(), isWeak(), llvm::LLLexer::LLLexer(), llvm::MIToken::location(), llvm::object::MachOUniversalBinary::MachOUniversalBinary(), llvm::sys::fs::make_absolute(), mangleCoveragePath(), llvm::object::MachOUniversalBinary::ObjectForArch::ObjectForArch(), llvm::SmallString< 256 >::operator+=(), llvm::sys::path::const_iterator::operator==(), llvm::sys::path::reverse_iterator::operator==(), llvm::object::Archive::Child::operator==(), llvm::opt::OptTable::OptTable(), llvm::InlineAsm::ConstraintInfo::Parse(), llvm::InlineAsm::ParseConstraints(), llvm::DWARFDebugLoc::parseOneLocationList(), llvm::DWARFDebugLocDWO::parseOneLocationList(), parsePhysicalReg(), llvm::parseType(), printName(), llvm::sys::path::replace_extension(), llvm::sys::path::replace_path_prefix(), rewritesSort(), llvm::yaml::ScalarNode::ScalarNode(), llvm::AsmLexer::setBuffer(), llvm::EngineBuilder::setMArch(), llvm::EngineBuilder::setMCPU(), llvm::TimerGroup::setName(), llvm::yaml::Document::skip(), llvm::Regex::sub(), llvm::object::Archive::symbol_begin(), llvm::TGLexer::TGLexer(), llvm::APInt::ushl_ov(), and llvm::ValueSymbolTable::~ValueSymbolTable().

◆ bytes()

iterator_range<const unsigned char *> llvm::StringRef::bytes ( ) const
inline

◆ bytes_begin()

const unsigned char* llvm::StringRef::bytes_begin ( ) const
inline

◆ bytes_end()

const unsigned char* llvm::StringRef::bytes_end ( ) const
inline

◆ compare()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE int llvm::StringRef::compare ( StringRef  RHS) const
inline

compare - Compare two strings; the result is -1, 0, or 1 if this string is lexicographically less than, equal to, or greater than the RHS.

Definition at line 184 of file StringRef.h.

References compare_lower(), compare_numeric(), edit_distance(), LLVM_NODISCARD, and Other.

Referenced by CheckBaseRegAndIndexRegAndScale(), llvm::FunctionComparator::cmpMem(), llvm::SmallString< 256 >::compare(), compareNames(), hasUnaryFloatFn(), llvm::operator<(), llvm::operator<=(), llvm::operator>(), llvm::operator>=(), and SortSymbolPair().

◆ compare_lower()

int StringRef::compare_lower ( StringRef  RHS) const

compare_lower - Compare two strings, ignoring case.

compare_lower - Compare strings, ignoring case.

Definition at line 53 of file StringRef.cpp.

References ascii_strncasecmp().

Referenced by compare(), llvm::SmallString< 256 >::compare_lower(), equals_lower(), isOperator(), and llvm::DetectRoundChange::runOnMachineFunction().

◆ compare_numeric()

int StringRef::compare_numeric ( StringRef  RHS) const

compare_numeric - Compare two strings, treating sequences of digits as numbers.

compare_numeric - Compare strings, handle embedded numbers.

Definition at line 79 of file StringRef.cpp.

References ascii_isdigit(), E, and I.

Referenced by compare(), and llvm::SmallString< 256 >::compare_numeric().

◆ consume_back()

LLVM_ATTRIBUTE_ALWAYS_INLINE bool llvm::StringRef::consume_back ( StringRef  Suffix)
inline

Returns true if this StringRef has the given suffix and removes that suffix.

Definition at line 689 of file StringRef.h.

References drop_back(), endswith(), LLVM_ATTRIBUTE_ALWAYS_INLINE, LLVM_NODISCARD, and size().

Referenced by parseDevirtPassName(), and parseRepeatPassName().

◆ consume_front()

LLVM_ATTRIBUTE_ALWAYS_INLINE bool llvm::StringRef::consume_front ( StringRef  Prefix)
inline

◆ consumeInteger() [1/2]

template<typename T >
std::enable_if<std::numeric_limits<T>::is_signed, bool>::type llvm::StringRef::consumeInteger ( unsigned  Radix,
T Result 
)
inline

Parse the current string as an integer of the specified radix.

If Radix is specified as zero, this does radix autosensing using extended C rules: 0 is octal, 0x is hex, 0b is binary.

If the string does not begin with a number of the specified radix, this returns true to signify the error. The string is considered erroneous if empty or if it overflows T. The portion of the string representing the discovered numeric value is removed from the beginning of the string.

Definition at line 531 of file StringRef.h.

References llvm::consumeSignedInteger().

Referenced by llvm::formatv_object_base::consumeFieldLayout(), llvm::detail::HelperFunctions::consumeNumHexDigits(), llvm::format_provider< T, typename std::enable_if< detail::use_integral_formatter< T >::value >::type >::format(), and llvm::formatv_object_base::parseReplacementItem().

◆ consumeInteger() [2/2]

template<typename T >
std::enable_if<!std::numeric_limits<T>::is_signed, bool>::type llvm::StringRef::consumeInteger ( unsigned  Radix,
T Result 
)
inline

◆ contains() [1/2]

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool llvm::StringRef::contains ( StringRef  Other) const
inline

Return true if the given string is a substring of *this, and false otherwise.

Definition at line 448 of file StringRef.h.

References find(), LLVM_ATTRIBUTE_ALWAYS_INLINE, LLVM_NODISCARD, and npos.

Referenced by llvm::AMDGPUSubtarget::initializeSubtargetDependencies(), llvm::PassArgFilter< Args >::operator()(), and useStringTable().

◆ contains() [2/2]

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool llvm::StringRef::contains ( char  C) const
inline

Return true if the given character is contained in *this, and false otherwise.

Definition at line 454 of file StringRef.h.

References find_first_of(), LLVM_ATTRIBUTE_ALWAYS_INLINE, LLVM_NODISCARD, and npos.

◆ contains_lower() [1/2]

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool llvm::StringRef::contains_lower ( StringRef  Other) const
inline

Return true if the given string is a substring of *this, and false otherwise.

Definition at line 460 of file StringRef.h.

References find_lower(), LLVM_ATTRIBUTE_ALWAYS_INLINE, LLVM_NODISCARD, and npos.

◆ contains_lower() [2/2]

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool llvm::StringRef::contains_lower ( char  C) const
inline

Return true if the given character is contained in *this, and false otherwise.

Definition at line 468 of file StringRef.h.

References find_lower(), LLVM_NODISCARD, and npos.

◆ copy()

template<typename Allocator >
LLVM_NODISCARD StringRef llvm::StringRef::copy ( Allocator A) const
inline

◆ count() [1/2]

LLVM_NODISCARD size_t llvm::StringRef::count ( char  C) const
inline

Return the number of occurrences of C in the string.

Definition at line 476 of file StringRef.h.

Referenced by CheckBaseRegAndIndexRegAndScale(), llvm::SmallString< 256 >::count(), llvm::HexagonInstrInfo::getInlineAsmLength(), and llvm::InlineAsm::ConstraintInfo::Parse().

◆ count() [2/2]

size_t StringRef::count ( StringRef  Str) const

Return the number of non-overlapped occurrences of Str in the string.

count - Return the number of non-overlapped occurrences of

  • Str in the string.

Definition at line 388 of file StringRef.cpp.

References equals(), N, size(), and substr().

◆ data()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char* llvm::StringRef::data ( ) const
inline

data - Get a pointer to the start of the string (which may not be null terminated).

Definition at line 128 of file StringRef.h.

References LLVM_ATTRIBUTE_ALWAYS_INLINE, and LLVM_NODISCARD.

Referenced by llvm::SourceMgr::AddIncludeFile(), llvm::FoldingSetNodeID::AddString(), annotateAllFunctions(), llvm::object::ArchiveMemberHeader::ArchiveMemberHeader(), llvm::object::ELFFile< ELFT >::base(), llvm::CachedHashString::CachedHashString(), llvm::StringSwitch< T, R >::Case(), CheckBaseRegAndIndexRegAndScale(), llvm::object::Archive::Child::Child(), llvm::sys::unicode::columnWidthUTF8(), llvm::zlib::compress(), llvm::ConvertUTF8toWide(), CopyStringRef(), llvm::zlib::crc32(), llvm::StringMapEntry< llvm::Comdat >::Create(), llvm::createPGOInstrumentationUseLegacyPass(), llvm::X86Operand::CreateToken(), llvm::NVPTXAsmPrinter::doFinalization(), llvm::DWARFDebugPubTable::dump(), llvm::DWARFDebugLine::Prologue::dump(), edit_distance(), llvm::BitstreamWriter::emitBlob(), EmitFileEntry(), llvm::InstrProfRecordWriterTrait::EmitKey(), llvm::DWARFYAML::EmitPubSection(), llvm::RuntimeDyldImpl::emitSection(), encodeCnt(), llvm::StringSwitch< T, R >::EndsWith(), llvm::cl::Option::error(), llvm::RuntimeDyldCheckerExprEval::evaluate(), ExecGraphViewer(), llvm::BitstreamWriter::ExitBlock(), llvm::DWARFFormValue::extractValue(), find(), llvm::pdb::DIASession::findSourceFiles(), llvm::irsymtab::storage::Str::get(), llvm::object::ArchiveMemberHeader::getAccessMode(), llvm::object::Archive::Child::getBuffer(), llvm::object::Archive::Child::getChildOffset(), llvm::DataExtractor::getCStr(), llvm::DataExtractor::getCStrRef(), getFunctionName(), llvm::object::ArchiveMemberHeader::getGID(), llvm::DenseMapInfo< StringRef >::getHashValue(), getID(), llvm::object::MachOObjectFile::getIndirectName(), llvm::Mips16InstrInfo::getInlineAsmLength(), llvm::HexagonInstrInfo::getInlineAsmLength(), llvm::TargetInstrInfo::getInlineAsmLength(), llvm::object::ArchiveMemberHeader::getLastModified(), llvm::MemoryBuffer::getMemBufferCopy(), llvm::object::ArchiveMemberHeader::getName(), llvm::object::Elf_Sym_Impl< ELFT >::getName(), llvm::object::Archive::Child::getNext(), llvm::opt::ArgList::GetOrMakeJoinedArgString(), llvm::object::ArchiveMemberHeader::getRawName(), llvm::SparcTargetLowering::getRegForInlineAsmConstraint(), llvm::TargetLowering::getRegForInlineAsmConstraint(), llvm::RuntimeDyldMachO::getRelocationValueRef(), llvm::object::ELFFile< ELFT >::getSectionName(), llvm::object::ArchiveMemberHeader::getSize(), llvm::ConstantDataArray::getString(), llvm::object::MachOObjectFile::getSymbolName(), llvm::DataExtractor::getU16(), llvm::DataExtractor::getU24(), llvm::DataExtractor::getU32(), llvm::DataExtractor::getU64(), llvm::DataExtractor::getU8(), llvm::object::ArchiveMemberHeader::getUID(), getUnderlyingArgReg(), llvm::AMDGPUMangledLibFunc::getUnmangledName(), llvm::PerFunctionMIParsingState::getVRegInfo(), hasConflictingReferenceFlags(), llvm::SHA1::hash(), llvm::pdb::hashStringV1(), hasUnaryFloatFn(), llvm::identify_magic(), llvm::MIRParserImpl::initializeJumpTableInfo(), llvm::ExecutionEngine::InitializeMemory(), llvm::yaml::ScalarTraits< char_16 >::input(), llvm::DenseMapInfo< StringRef >::isEqual(), isIdentifierChar(), isValidEncoding(), LLVMGetAsString(), LLVMGetSectionContents(), LLVMGetSectionName(), LLVMGetStructName(), LLVMTargetMachineEmitToMemoryBuffer(), loadTestingFormat(), llvm::Intrinsic::lookupLLVMIntrinsicByName(), llvm::TargetIntrinsicInfo::lookupName(), llvm::LTOModule::makeBuffer(), mapArchToCVCPUType(), llvm::Regex::match(), matchPair(), llvm::sys::path::native(), llvm::operator+=(), llvm::raw_ostream::operator<<(), llvm::cl::ParseEnvironmentOptions(), llvm::opt::OptTable::ParseOneArg(), llvm::PassNameParser::passRegistered(), llvm::AsmLexer::peekTokens(), previousIsLoop(), llvm::ScopedPrinter::printBinary(), llvm::ScopedPrinter::printBinaryBlock(), llvm::RuntimeDyldELF::processRelocationRef(), ProvideOption(), llvm::irsymtab::readBitcode(), readCoverageMappingData(), llvm::GCOVBuffer::readInt(), llvm::readPGOFuncNameStrings(), llvm::LessRecordRegister::RecordParts::RecordParts(), llvm::Regex::Regex(), llvm::report_fatal_error(), llvm::RuntimeDyldImpl::resolveExternalSymbols(), rewritesSort(), llvm::StringSaver::save(), llvm::yaml::Output::scalarString(), llvm::orc::rpc::SerializationTraits< ChannelT, std::string, StringRef, typename std::enable_if< std::is_base_of< RawByteChannel, ChannelT >::value >::type >::serialize(), setRequiredFeatureString(), llvm::X86Operand::setTokenValue(), StackMallocSizeClass(), llvm::StringSwitch< T, R >::StartsWith(), llvm::detail::to_float(), llvm::cl::TokenizeGNUCommandLine(), llvm::cl::TokenizeWindowsCommandLine(), llvm::codeview::TypeServer2Record::TypeServer2Record(), llvm::zlib::uncompress(), llvm::SHA1::update(), llvm::MD5::update(), llvm::yaml::MappingTraits< ELFYAML::Symbol >::validate(), llvm::object::WasmObjectFile::WasmObjectFile(), llvm::StringTableBuilder::write(), writeIdentificationBlock(), writeUstarHeader(), and llvm::xxHash64().

◆ drop_back()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef llvm::StringRef::drop_back ( size_t  N = 1) const
inline

◆ drop_front()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef llvm::StringRef::drop_front ( size_t  N = 1) const
inline

◆ drop_until()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef llvm::StringRef::drop_until ( function_ref< bool(char)>  F) const
inline

Return a StringRef equal to 'this', but with all characters not satisfying the given predicate dropped from the beginning of the string.

Definition at line 671 of file StringRef.h.

References F(), find_if(), LLVM_ATTRIBUTE_ALWAYS_INLINE, and substr().

◆ drop_while()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef llvm::StringRef::drop_while ( function_ref< bool(char)>  F) const
inline

Return a StringRef equal to 'this', but with all characters satisfying the given predicate dropped from the beginning of the string.

Definition at line 663 of file StringRef.h.

References F(), find_if_not(), LLVM_ATTRIBUTE_ALWAYS_INLINE, LLVM_NODISCARD, and substr().

◆ edit_distance()

unsigned StringRef::edit_distance ( llvm::StringRef  Other,
bool  AllowReplacements = true,
unsigned  MaxEditDistance = 0 
) const

Determine the edit distance between this string and another string.

Parameters
Otherthe string to compare this string against.
AllowReplacementswhether to allow character replacements (change one character into another) as a single operation, rather than as two operations (an insertion and a removal).
MaxEditDistanceIf non-zero, the maximum edit distance that this routine is allowed to compute. If the edit distance will exceed that maximum, returns MaxEditDistance+1.
Returns
the minimum number of character insertions, removals, or (if AllowReplacements is true) replacements needed to transform one of the given strings into the other. If zero, the strings are identical.

Definition at line 110 of file StringRef.cpp.

References llvm::ComputeEditDistance(), data(), llvm::makeArrayRef(), and size().

Referenced by compare(), and LookupNearestOption().

◆ empty()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool llvm::StringRef::empty ( ) const
inline

empty - Check if the string is empty.

Definition at line 133 of file StringRef.h.

References LLVM_ATTRIBUTE_ALWAYS_INLINE, and LLVM_NODISCARD.

Referenced by llvm::SubtargetFeatures::AddFeature(), llvm::CodeViewContext::addFile(), llvm::InstrProfSymtab::addFuncName(), llvm::ExecutionEngine::addGlobalMapping(), llvm::DwarfUnit::addLinkageName(), llvm::DIEHash::addSLEB128(), llvm::cl::basic_parser_impl::anchor(), llvm::DwarfUnit::applySubprogramAttributes(), llvm::DwarfUnit::applySubprogramDefinitionAttributes(), llvm::DwarfCompileUnit::applyVariableAttributes(), llvm::APSInt::APSInt(), back(), llvm::BinaryStreamError::BinaryStreamError(), branchDiv(), llvm::DICompositeType::buildODRType(), llvm::canRenameComdatFunc(), checkFunctionsAttributeConsistency(), CloneInstructionInExitBlock(), llvm::ModuleSymbolTable::CollectAsmSymbols(), llvm::pdb::PDBFileBuilder::commit(), llvm::DIEHash::computeCUSignature(), llvm::ARM::computeDefaultTargetABI(), llvm::MipsABIInfo::computeTargetABI(), computeTargetABI(), llvm::ConstantFoldLoadFromConstPtr(), llvm::DwarfCompileUnit::constructImportedEntityDIE(), llvm::DwarfUnit::constructTypeDIE(), llvm::formatv_object_base::consumeFieldLayout(), llvm::consumeSignedInteger(), llvm::consumeUnsignedInteger(), llvm::detail::IEEEFloat::convertFromString(), llvm::convertUTF8ToUTF16String(), copy(), copyFeaturesToFunction(), CopyStringRef(), llvm::GlobPattern::create(), llvm::StructType::create(), llvm::sys::fs::create_directories(), createAArch64MCSubtargetInfo(), llvm::MDBuilder::createAnonymousAARoot(), llvm::ARM_MC::createARMMCSubtargetInfo(), llvm::DIBuilder::createBasicType(), llvm::DIBuilder::createEnumerator(), llvm::DIBuilder::createMacro(), llvm::createSanitizerCtorAndInitFunctions(), createSparcMCSubtargetInfo(), llvm::sys::fs::createTemporaryFile(), llvm::DIBuilder::createUnspecifiedType(), llvm::X86_MC::createX86MCSubtargetInfo(), llvm::declareSanitizerInitFunction(), decodeBase64StringEntry(), llvm::DelimitedScope< Open, Close >::DelimitedScope(), llvm::pdb::DIAError::DIAError(), llvm::GlobalValue::dropLLVMManglingEscape(), dumpAttribute(), dumpLocation(), EatNumber(), emitComments(), emitDebugValueComment(), EmitGenDwarfAbbrev(), EmitGenDwarfInfo(), llvm::TargetLoweringObjectFileELF::emitModuleMetadata(), llvm::TargetLoweringObjectFileMachO::emitModuleMetadata(), llvm::TargetLoweringObjectFileCOFF::emitModuleMetadata(), llvm::X86FrameLowering::emitPrologue(), llvm::ARMTargetStreamer::emitTargetAttributes(), llvm::cl::Option::error(), llvm::RuntimeDyldCheckerExprEval::evaluate(), llvm::coverage::CounterMappingContext::evaluate(), llvm::DWARFFormValue::extractValue(), find_if(), llvm::pdb::DIASession::findSourceFiles(), llvm::symbolize::LLVMSymbolizer::flush(), foldBlockIntoPredecessor(), llvm::format_provider< T, typename std::enable_if< detail::use_integral_formatter< T >::value >::type >::format(), llvm::format_provider< std::chrono::duration< Rep, Period > >::format(), llvm::format_provider< T, typename std::enable_if< detail::use_string_formatter< T >::value >::type >::format(), llvm::format_provider< T, typename std::enable_if< detail::use_char_formatter< T >::value >::type >::format(), llvm::fromHex(), front(), FunctionNumber(), llvm::pdb::GenericError::GenericError(), llvm::Attribute::get(), GetAEABIUnwindPersonalityName(), getARClassRegisterMask(), llvm::Triple::getARMCPUForArch(), getAsInteger(), llvm::getAsSignedInteger(), llvm::getAsUnsignedInteger(), getAttrKindEncoding(), GetAutoSenseRadix(), llvm::getBitcodeFileContents(), llvm::APInt::getBitsNeeded(), llvm::ARM::getCanonicalArchName(), llvm::DINode::getCanonicalMDString(), llvm::DIMacroNode::getCanonicalMDString(), getChompedLineBreaks(), llvm::MCContext::getCOFFSection(), getCommonClassOptions(), llvm::DOTGraphTraits< const Function * >::getCompleteNodeLabel(), llvm::LineEditor::getCompletionAction(), llvm::getCPU(), getELFKindForNamedSection(), llvm::SubtargetFeatures::getFeatureBits(), llvm::MCDwarfLineTableHeader::getFile(), llvm::getFuncNameWithoutPrefix(), llvm::object::ArchiveMemberHeader::getGID(), llvm::GlobalValue::getGlobalIdentifier(), getGNUBinOpPrecedence(), getGPUOrDefault(), getItineraryLatency(), llvm::TargetLibraryInfoImpl::getLibFunc(), llvm::object::MachOObjectFile::getLibraryShortNameByIndex(), llvm::getMemOPSizeRangeFromOption(), llvm::Value::getName(), getNameWithPrefixImpl(), getNextRegister(), llvm::DILocalScope::getNonLexicalBlockFileScope(), llvm::DICompositeType::getODRTypeIfExists(), getOpEnabled(), getOpRefinementSteps(), llvm::DwarfUnit::getOrCreateModule(), llvm::DwarfUnit::getOrCreateNameSpace(), llvm::MCContext::getOrCreateSymbol(), llvm::DwarfUnit::getParentContextString(), getPassInfo(), getPrettyScopeName(), llvm::SparcTargetLowering::getRegForInlineAsmConstraint(), llvm::TargetLowering::getRegForInlineAsmConstraint(), llvm::TargetLibraryInfoImpl::getScalarizedFunction(), getSearchPaths(), llvm::DOTGraphTraits< const Function * >::getSimpleNodeLabel(), llvm::getSimpleNodeName(), llvm::DataExtractor::getSLEB128(), llvm::SparcTargetMachine::getSubtargetImpl(), llvm::X86TargetMachine::getSubtargetImpl(), llvm::PPCTargetMachine::getSubtargetImpl(), llvm::ARMBaseTargetMachine::getSubtargetImpl(), llvm::MipsTargetMachine::getSubtargetImpl(), GetSymbolFromOperand(), getSymbolKindName(), llvm::TargetLoweringObjectFile::getSymbolWithGlobalValueBase(), llvm::lto::getThinLTOOutputFile(), llvm::getTypeName(), llvm::object::ArchiveMemberHeader::getUID(), llvm::DataExtractor::getULEB128(), getUnderlyingArgReg(), getUnicodeEncoding(), llvm::yaml::ScalarNode::getValue(), getValueStr(), llvm::TargetLibraryInfoImpl::getVectorizedFunction(), llvm::yaml::Node::getVerbatimTag(), llvm::DWARFVerifier::handleAccelTables(), llvm::DWARFVerifier::handleDebugAbbrev(), llvm::sys::path::has_extension(), llvm::sys::path::has_filename(), llvm::sys::path::has_parent_path(), llvm::sys::path::has_relative_path(), llvm::sys::path::has_root_directory(), llvm::sys::path::has_root_name(), llvm::sys::path::has_root_path(), llvm::sys::path::has_stem(), llvm::cl::Option::hasArgStr(), hasConflictingReferenceFlags(), hasFlag(), hasPrefix(), llvm::object::Archive::hasSymbolTable(), hasUnaryFloatFn(), llvm::HexagonGetLastSlot(), llvm::PassNameParser::ignorablePass(), inBytes(), incrementLoc(), llvm::NVPTXSubtarget::initializeSubtargetDependencies(), llvm::MCSubtargetInfo::InitMCProcessorInfo(), llvm::StringSet< AllocatorTy >::insert(), instrumentMaskedLoadOrStore(), isCanonical(), isCoverageMappingDummy(), isEnabled(), llvm::AArch64TargetLowering::isFPImmLegal(), llvm::TargetLibraryInfoImpl::isFunctionVectorizable(), isIdentifierChar(), isLoopPassName(), isOperator(), isRepeatedByteSequence(), isReportingError(), llvm::DiagnosticLocation::isValid(), isValidEncoding(), llvm::MCAsmInfo::isValidUnquotedName(), isXor1OfSetCC(), llvm::ARMSubtarget::isXRaySupported(), llvm::LoadAndStorePromoter::LoadAndStorePromoter(), loadBinaryFormat(), loadTestingFormat(), LookupNearestOption(), mapArchToCVCPUType(), llvm::yaml::MappingTraits< DWARFYAML::FormValue >::mapping(), llvm::yaml::MappingTraits< DWARFYAML::LineTableOpcode >::mapping(), llvm::codeview::CodeViewRecordIO::mapStringZVectorZ(), llvm::GlobPattern::match(), matchAsm(), maybePrintComdat(), llvm::yaml::needsQuotes(), needsRuntimeRegistrationOfSectionRange(), llvm::Triple::normalize(), llvm::cl::SubCommand::operator bool(), llvm::DWARFGdbIndex::parse(), llvm::object::Parser::parse(), llvm::AMDGPULibFunc::parse(), llvm::PassBuilder::parseAAPipeline(), parseARMArch(), llvm::ARM_MC::ParseARMTriple(), parseDuration(), llvm::formatv_object_base::parseFormatString(), parseNamePrefix(), llvm::detail::HelperFunctions::parseNumericPrecision(), llvm::formatv_object_base::parseReplacementItem(), llvm::MCSectionMachO::ParseSectionSpecifier(), parseSubArch(), parseV2DirFileTables(), parseVersionFromName(), previousIsLoop(), llvm::MCExpr::print(), llvm::DWARFExpression::Operation::print(), llvm::MIPrinter::print(), llvm::MCInstPrinter::printAnnotation(), llvm::AArch64InstPrinter::printBarrierOption(), PrintCFIEscape(), printExtendedName(), printFile(), PrintLLVMName(), llvm::printLLVMNameWithoutPrefix(), printMetadataIdentifier(), llvm::cl::generic_parser_base::printOptionInfo(), PrintQuotedString(), llvm::MCSectionMachO::PrintSwitchToSection(), printSymbolizedStackTrace(), llvm::codeview::printTypeIndex(), llvm::AttributeImpl::Profile(), llvm::pruneCache(), llvm::GCOVBuffer::readArcTag(), llvm::irsymtab::readBitcode(), llvm::GCOVBuffer::readBlockTag(), llvm::GCOVBuffer::readEdgeTag(), llvm::GCOVBuffer::readFunctionTag(), llvm::GCOVBuffer::readLineTag(), llvm::GCOVBuffer::readObjectTag(), llvm::GCOVBuffer::readProgramTag(), readWideAPInt(), llvm::CodeViewContext::recordInlinedCallSiteId(), llvm::LessRecordRegister::RecordParts::RecordParts(), RefineErrorLoc(), llvm::sys::path::replace_path_prefix(), llvm::cl::ResetAllOptionOccurrences(), rewritesSort(), sanitizeFunctionName(), llvm::yaml::Output::scalarString(), llvm::Hexagon_MC::selectHexagonCPU(), llvm::MIPS_MC::selectMipsCPU(), llvm::EngineBuilder::selectTarget(), llvm::cl::Option::setArgStr(), setFunctionAttributes(), llvm::StructType::setName(), setRequiredFeatureString(), llvm::GlobalObject::setSection(), llvm::lto::setupOptimizationRemarks(), llvm::DwarfDebug::shareAcrossDWOCUs(), shouldEmitUdt(), sortSubCommands(), split(), split(), srcMgrDiagHandler(), llvm::StripDebugInfo(), StripTypeNames(), llvm::Regex::sub(), llvm::to_hexString(), truncateToSize(), llvm::DwarfUnit::updateAcceleratorTables(), llvm::ExecutionEngine::updateGlobalMapping(), useFuncSeen(), UsesVectorABI(), llvm::APInt::ushl_ov(), llvm::InlineAsm::Verify(), llvm::object::WasmObjectFile::WasmObjectFile(), llvm::InnerLoopVectorizer::widenInstruction(), llvm::StringTableBuilder::write(), WriteAsOperandInternal(), writeGeneratedObject(), and llvm::yaml::yamlize().

◆ end()

iterator llvm::StringRef::end ( ) const
inline

Definition at line 108 of file StringRef.h.

Referenced by llvm::SmallString< 256 >::append(), llvm::sys::path::append(), llvm::SmallString< 256 >::assign(), llvm::yaml::BlockScalarNode::BlockScalarNode(), bytes_end(), llvm::detail::IEEEFloat::convertFromZeroExtendedInteger(), llvm::convertUTF8ToUTF16String(), llvm::ConvertUTF8toWide(), copy(), llvm::MachineFunction::createExternalSymbolName(), decodeUTF8(), llvm::MCObjectStreamer::EmitBytes(), emitSignedInt64(), llvm::MDString::end(), endswith(), endswith_lower(), llvm::yaml::escape(), llvm::symbolize::LLVMSymbolizer::flush(), getAttrKindEncoding(), llvm::MemoryBufferRef::getBufferEnd(), llvm::sys::detail::getHostCPUNameForPowerPC(), getHostID(), llvm::TGLexer::getLoc(), llvm::StringToOffsetTable::GetOrAddStringOffset(), llvm::SparcTargetLowering::getRegForInlineAsmConstraint(), llvm::TargetLowering::getRegForInlineAsmConstraint(), llvm::object::ELFFile< ELFT >::getRelocationTypeName(), llvm::object::WasmObjectFile::getRelocationTypeName(), llvm::object::MachOObjectFile::getRelocationTypeName(), llvm::object::COFFObjectFile::getRelocationTypeName(), llvm::ConstantDataArray::getString(), llvm::TargetLoweringObjectFile::getSymbolWithGlobalValueBase(), llvm::yaml::ScalarNode::getValue(), llvm::hash_value(), llvm::pdb::hashStringV2(), hasUnaryFloatFn(), llvm::detail::IEEEFloat::IEEEFloat(), llvm::Timer::init(), IsIdentifierChar(), llvm::AsmLexer::LexUntilEndOfStatement(), llvm::line_iterator::line_iterator(), llvm::LLLexer::LLLexer(), llvm::sys::fs::make_absolute(), mangleCoveragePath(), llvm::SmallString< 256 >::operator+=(), llvm::opt::OptTable::OptTable(), llvm::InlineAsm::ConstraintInfo::Parse(), llvm::InlineAsm::ParseConstraints(), llvm::DWARFDebugLoc::parseOneLocationList(), llvm::DWARFDebugLocDWO::parseOneLocationList(), parsePhysicalReg(), parseRegisterNumber(), printName(), llvm::Regex::Regex(), llvm::sys::path::replace_extension(), llvm::sys::path::replace_path_prefix(), rewritesSort(), llvm::yaml::ScalarNode::ScalarNode(), llvm::AsmLexer::setBuffer(), llvm::EngineBuilder::setMArch(), llvm::EngineBuilder::setMCPU(), llvm::TimerGroup::setName(), llvm::Regex::sub(), llvm::APInt::ushl_ov(), and llvm::ValueSymbolTable::~ValueSymbolTable().

◆ endswith()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool llvm::StringRef::endswith ( StringRef  Suffix) const
inline

◆ endswith_lower()

bool StringRef::endswith_lower ( StringRef  Suffix) const

Check if this string ends with the given Suffix, ignoring case.

Definition at line 68 of file StringRef.cpp.

References ascii_strncasecmp(), and end().

Referenced by endswith(), and llvm::StringSwitch< T, R >::EndsWithLower().

◆ equals()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool llvm::StringRef::equals ( StringRef  RHS) const
inline

◆ equals_lower()

LLVM_NODISCARD bool llvm::StringRef::equals_lower ( StringRef  RHS) const
inline

◆ find() [1/2]

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t llvm::StringRef::find ( char  C,
size_t  From = 0 
) const
inline

Search for the first character C in the string.

Returns
The index of the first occurrence of C, or npos if not found.

Definition at line 298 of file StringRef.h.

References C, find_lower(), LLVM_ATTRIBUTE_ALWAYS_INLINE, LLVM_NODISCARD, npos, and P.

Referenced by addNegOperand(), llvm::X86FrameLowering::adjustForHiPEPrologue(), checkLinkerOptCommand(), CommaSeparateAndAddOccurrence(), contains(), emitComments(), llvm::RuntimeDyldCheckerExprEval::evaluate(), llvm::SmallString< 256 >::find(), find_first_of(), find_if_not(), llvm::ARM::getCanonicalArchName(), llvm::getConstantStringInfo(), llvm::DataExtractor::getCStr(), llvm::DataExtractor::getCStrRef(), llvm::HexagonTargetObjectFile::getExplicitSectionGlobal(), llvm::getMemOPSizeRangeFromOption(), llvm::object::ArchiveMemberHeader::getName(), getNextRegister(), getObjCClassCategory(), getObjCMethodName(), llvm::object::ArchiveMemberHeader::getRawName(), llvm::getTypeName(), llvm::yaml::ScalarNode::getValue(), llvm::object::MachOObjectFile::guessLibraryShortName(), hasObjCCategory(), hasUnaryFloatFn(), llvm::MIRParserImpl::initializeJumpTableInfo(), instrumentMaskedLoadOrStore(), llvm::ConstantDataSequential::isCString(), llvm::objcarc::IsObjCIdentifiedObject(), isReportingError(), isSmallDataSection(), isWeak(), llvm::Intrinsic::lookupLLVMIntrinsicByName(), MCAttrForString(), llvm::cl::SubCommand::operator bool(), ParseLine(), parseRefinementStep(), parseValidVectorKind(), printSymbolizedStackTrace(), llvm::object::replace(), RequiresVFPRegListValidation(), sanitizeFunctionName(), scan(), setRequiredFeatureString(), llvm::shouldBeSls(), shouldInstrumentBlock(), split(), UpgradeIntrinsicFunction1(), and llvm::sroa::AllocaSliceRewriter::visit().

◆ find() [2/2]

size_t StringRef::find ( StringRef  Str,
size_t  From = 0 
) const

Search for the first string Str in the string.

find - Search for the first string

Returns
The index of the first occurrence of Str, or npos if not found.
  • Str in the string.
Returns
- The index of the first occurrence of
  • Str, or npos if not found.

Definition at line 148 of file StringRef.cpp.

References data(), LLVM_UNLIKELY, memcmp, N, npos, size(), and llvm::AMDGPU::CodeObject::Kernel::Arg::Key::Size.

◆ find_first_not_of() [1/2]

StringRef::size_type StringRef::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.

find_first_not_of - Find the first character in the string that is not

  • C or npos if not found.

Definition at line 265 of file StringRef.cpp.

References npos.

Referenced by llvm::DWARFContext::defaultErrorHandler(), llvm::RuntimeDyldCheckerExprEval::evaluate(), llvm::SmallString< 256 >::find_first_not_of(), find_first_of(), llvm::symbolize::LLVMSymbolizer::flush(), llvm::getToken(), hasUnaryFloatFn(), llvm::yaml::isNumber(), ltrim(), matchAsm(), llvm::yaml::needsQuotes(), ParseLine(), printName(), llvm::Regex::sub(), and llvm::sroa::AllocaSliceRewriter::visit().

◆ find_first_not_of() [2/2]

StringRef::size_type StringRef::find_first_not_of ( StringRef  Chars,
size_t  From = 0 
) const

Find the first character in the string that is not in the string Chars, or npos if not found.

find_first_not_of - Find the first character in the string that is not in the string

Complexity: O(size() + Chars.size())

  • Chars, or npos if not found.

Note: O(size() + Chars.size())

Definition at line 276 of file StringRef.cpp.

References npos, and size().

◆ find_first_of() [1/2]

LLVM_NODISCARD size_t llvm::StringRef::find_first_of ( char  C,
size_t  From = 0 
) const
inline

◆ find_first_of() [2/2]

StringRef::size_type StringRef::find_first_of ( StringRef  Chars,
size_t  From = 0 
) const

Find the first character in the string that is in Chars, or npos if not found.

find_first_of - Find the first character in the string that is in

Complexity: O(size() + Chars.size())

  • Chars, or npos if not found.

Note: O(size() + Chars.size())

Definition at line 251 of file StringRef.cpp.

References npos, and size().

◆ find_if()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t llvm::StringRef::find_if ( function_ref< bool(char)>  F,
size_t  From = 0 
) const
inline

Search for the first character satisfying the predicate F.

Returns
The index of the first character satisfying F starting from From, or npos if not found.

Definition at line 321 of file StringRef.h.

References drop_front(), empty(), F(), front(), LLVM_ATTRIBUTE_ALWAYS_INLINE, LLVM_NODISCARD, npos, and size().

Referenced by drop_until(), find_if_not(), find_lower(), and take_until().

◆ find_if_not()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t llvm::StringRef::find_if_not ( function_ref< bool(char)>  F,
size_t  From = 0 
) const
inline

Search for the first character not satisfying the predicate F.

Returns
The index of the first character not satisfying F starting from From, or npos if not found.

Definition at line 337 of file StringRef.h.

References F(), find(), find_if(), find_lower(), and LLVM_NODISCARD.

Referenced by drop_while(), and take_while().

◆ find_last_not_of() [1/2]

StringRef::size_type StringRef::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.

find_last_not_of - Find the last character in the string that is not

  • C, or npos if not found.

Definition at line 306 of file StringRef.cpp.

References npos.

Referenced by find_last_of(), and rtrim().

◆ find_last_not_of() [2/2]

StringRef::size_type StringRef::find_last_not_of ( StringRef  Chars,
size_t  From = npos 
) const

Find the last character in the string that is not in Chars, or npos if not found.

find_last_not_of - Find the last character in the string that is not in

Complexity: O(size() + Chars.size())

  • Chars, or npos if not found.

Note: O(size() + Chars.size())

Definition at line 317 of file StringRef.cpp.

References npos, and size().

◆ find_last_of() [1/2]

LLVM_NODISCARD size_t llvm::StringRef::find_last_of ( char  C,
size_t  From = npos 
) const
inline

◆ find_last_of() [2/2]

StringRef::size_type StringRef::find_last_of ( StringRef  Chars,
size_t  From = npos 
) const

Find the last character in the string that is in C, or npos if not found.

find_last_of - Find the last character in the string that is in

Complexity: O(size() + Chars.size())

  • C, or npos if not found.

Note: O(size() + Chars.size())

Definition at line 292 of file StringRef.cpp.

References npos, and size().

◆ find_lower() [1/2]

size_t StringRef::find_lower ( char  C,
size_t  From = 0 
) const

Search for the first character C in the string, ignoring case.

Returns
The index of the first occurrence of C, or npos if not found.

Definition at line 73 of file StringRef.cpp.

References ascii_tolower(), D, and find_if().

Referenced by contains_lower(), find(), and find_if_not().

◆ find_lower() [2/2]

size_t StringRef::find_lower ( StringRef  Str,
size_t  From = 0 
) const

Search for the first string Str in the string, ignoring case.

Returns
The index of the first occurrence of Str, or npos if not found.

Definition at line 197 of file StringRef.cpp.

References drop_front(), npos, size(), startswith_lower(), and substr().

◆ front()

LLVM_NODISCARD char llvm::StringRef::front ( ) const
inline

◆ getAsDouble()

bool StringRef::getAsDouble ( double &  Result,
bool  AllowInexact = true 
) const

Parse the current string as an IEEE double-precision floating point value.

The string must be a well-formed double.

If AllowInexact is false, the function will fail if the string cannot be represented exactly. Otherwise, the function only fails in case of an overflow or underflow.

Definition at line 599 of file StringRef.cpp.

References llvm::APFloat::convertFromString(), llvm::APFloat::convertToDouble(), F(), llvm::APFloatBase::opInexact, llvm::APFloatBase::opOK, and llvm::APFloatBase::rmNearestTiesToEven.

Referenced by consumeInteger().

◆ getAsInteger() [1/3]

template<typename T >
std::enable_if<std::numeric_limits<T>::is_signed, bool>::type llvm::StringRef::getAsInteger ( unsigned  Radix,
T Result 
) const
inline

Parse the current string as an integer of the specified radix.

If Radix is specified as zero, this does radix autosensing using extended C rules: 0 is octal, 0x is hex, 0b is binary.

If the string is invalid or if only a subset of the string is valid, this returns true to signify the error. The string is considered erroneous if empty or if it overflows T.

Definition at line 497 of file StringRef.h.

References llvm::getAsSignedInteger().

Referenced by addNegOperand(), adjustCallerStackProbeSize(), CheckBaseRegAndIndexRegAndScale(), llvm::object::Archive::Child::Child(), consumeInteger(), EmitGCCInlineAsmStr(), EmitMSInlineAsmStr(), llvm::X86FrameLowering::emitPrologue(), encodeCnt(), llvm::RuntimeDyldCheckerExprEval::evaluate(), llvm::format_provider< T, typename std::enable_if< detail::use_string_formatter< T >::value >::type >::format(), llvm::object::ArchiveMemberHeader::getAccessMode(), getEstimate(), llvm::object::ArchiveMemberHeader::getGID(), getInt(), llvm::AMDGPU::getIntegerAttribute(), llvm::object::ArchiveMemberHeader::getLastModified(), llvm::getMemOPSizeRangeFromOption(), llvm::object::ArchiveMemberHeader::getName(), llvm::SITargetLowering::getRegForInlineAsmConstraint(), llvm::object::COFFObjectFile::getSectionName(), llvm::object::ArchiveMemberHeader::getSize(), getSpecialRegForName(), getSubOpcode(), llvm::object::ArchiveMemberHeader::getUID(), llvm::yaml::ScalarNode::getValue(), hasPrefix(), llvm::yaml::CustomMappingTraits< std::map< uint64_t, WholeProgramDevirtResolution > >::inputOne(), llvm::yaml::CustomMappingTraits< GlobalValueSummaryMapTy >::inputOne(), intToken(), llvm::object::Parser::parse(), llvm::parseCachePruningPolicy(), parseDevirtPassName(), parseDuration(), ParseHead(), ParseLine(), llvm::detail::HelperFunctions::parseNumericPrecision(), parseRepeatPassName(), parseSectionFlags(), llvm::MCSectionMachO::ParseSectionSpecifier(), llvm::parseStatepointDirectivesFromAttrs(), parseValidVectorKind(), llvm::cl::basic_parser_impl::printOptionName(), RefineErrorLoc(), llvm::StackProtector::runOnFunction(), llvm::Regex::sub(), llvm::to_integer(), WindowsRequiresStackProbe(), and llvm::yaml::BinaryRef::writeAsBinary().

◆ getAsInteger() [2/3]

template<typename T >
std::enable_if<!std::numeric_limits<T>::is_signed, bool>::type llvm::StringRef::getAsInteger ( unsigned  Radix,
T Result 
) const
inline

Definition at line 508 of file StringRef.h.

References llvm::getAsUnsignedInteger().

◆ getAsInteger() [3/3]

bool StringRef::getAsInteger ( unsigned  Radix,
APInt Result 
) const

Parse the current string as an integer of the specified Radix, or of an autosensed radix if the Radix given is 0.

The current value in Result is discarded, and the storage is changed to be wide enough to store the parsed integer.

Returns
true if the string does not solely consist of a valid non-empty number in the appropriate base.

APInt::fromString is superficially similar but assumes the string is well-formed in the given radix.

Definition at line 524 of file StringRef.cpp.

References assert(), empty(), front(), GetAutoSenseRadix(), llvm::APInt::getBitWidth(), size(), substr(), and llvm::APInt::zext().

◆ lower()

std::string StringRef::lower ( ) const

◆ ltrim() [1/2]

LLVM_NODISCARD StringRef llvm::StringRef::ltrim ( char  Char) const
inline

Return string with consecutive Char characters starting from the the left removed.

Definition at line 808 of file StringRef.h.

References drop_front(), find_first_not_of(), and LLVM_NODISCARD.

Referenced by llvm::RuntimeDyldCheckerExprEval::evaluate(), llvm::yaml::Document::parseBlockNode(), llvm::opt::OptTable::ParseOneArg(), and trim().

◆ ltrim() [2/2]

LLVM_NODISCARD StringRef llvm::StringRef::ltrim ( StringRef  Chars = " \t\n\v\f\r") const
inline

Return string with consecutive characters in Chars starting from the left removed.

Definition at line 815 of file StringRef.h.

References drop_front(), find_first_not_of(), and LLVM_NODISCARD.

◆ operator std::string()

llvm::StringRef::operator std::string ( ) const
inline

Definition at line 256 of file StringRef.h.

References LLVM_ATTRIBUTE_ALWAYS_INLINE, LLVM_NODISCARD, and str().

◆ operator=()

template<typename T >
std::enable_if<std::is_same<T, std::string>::value, StringRef>::type& llvm::StringRef::operator= ( T &&  Str)
delete

Disallow accidental assignment from a temporary std::string.

The declaration here is extra complicated so that stringRef = {} and stringRef = "abc" continue to select the move assignment operator.

Referenced by operator[]().

◆ operator[]()

LLVM_NODISCARD char llvm::StringRef::operator[] ( size_t  Index) const
inline

Definition at line 238 of file StringRef.h.

References assert(), and operator=().

◆ rfind() [1/2]

LLVM_NODISCARD size_t llvm::StringRef::rfind ( char  C,
size_t  From = npos 
) const
inline

◆ rfind() [2/2]

size_t StringRef::rfind ( StringRef  Str) const

Search for the last string Str in the string.

rfind - Search for the last string

Returns
The index of the last occurrence of Str, or npos if not found.
  • Str in the string.
Returns
- The index of the last occurrence of
  • Str, or npos if not found.

Definition at line 223 of file StringRef.cpp.

References equals(), N, npos, size(), and substr().

◆ rfind_lower() [1/2]

size_t StringRef::rfind_lower ( char  C,
size_t  From = npos 
) const

Search for the last character C in the string, ignoring case.

Returns
The index of the last occurrence of C, or npos if not found.

Definition at line 208 of file StringRef.cpp.

References ascii_tolower(), and npos.

Referenced by rfind().

◆ rfind_lower() [2/2]

size_t StringRef::rfind_lower ( StringRef  Str) const

Search for the last string Str in the string, ignoring case.

Returns
The index of the last occurrence of Str, or npos if not found.

Definition at line 235 of file StringRef.cpp.

References equals_lower(), N, npos, size(), and substr().

◆ rsplit()

LLVM_NODISCARD std::pair<StringRef, StringRef> llvm::StringRef::rsplit ( char  Separator) const
inline

Split into two substrings around the last occurrence of a separator character.

If Separator is in the string, then the result is a pair (LHS, RHS) such that (*this == LHS + Separator + RHS) is true and RHS is minimal. If Separator is not in the string, then the result is a pair (LHS, RHS) where (*this == LHS) and (RHS == "").

Parameters
Separator- The character to split on.
Returns
- The split substrings.

Definition at line 798 of file StringRef.h.

References LLVM_NODISCARD, rfind(), slice(), and StringRef().

Referenced by getARClassRegisterMask(), and llvm::HexagonGetLastSlot().

◆ rtrim() [1/2]

LLVM_NODISCARD StringRef llvm::StringRef::rtrim ( char  Char) const
inline

◆ rtrim() [2/2]

LLVM_NODISCARD StringRef llvm::StringRef::rtrim ( StringRef  Chars = " \t\n\v\f\r") const
inline

Return string with consecutive characters in Chars starting from the right removed.

Definition at line 829 of file StringRef.h.

References drop_back(), find_last_not_of(), and LLVM_NODISCARD.

◆ size()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t llvm::StringRef::size ( ) const
inline

size - Get the string size.

Definition at line 138 of file StringRef.h.

References LLVM_NODISCARD.

Referenced by llvm::FoldingSetNodeID::AddString(), llvm::TarWriter::append(), llvm::APSInt::APSInt(), llvm::CachedHashString::CachedHashString(), llvm::CachedHashStringRef::CachedHashStringRef(), llvm::canConstantFoldCallTo(), llvm::yaml::Output::canElideEmptySequence(), llvm::StringSwitch< T, R >::Case(), charTailAt(), llvm::RuntimeDyldCheckerImpl::checkAllRulesInBuffer(), CheckBaseRegAndIndexRegAndScale(), llvm::FunctionComparator::cmpMem(), llvm::sys::locale::columnWidth(), llvm::sys::unicode::columnWidthUTF8(), llvm::zlib::compress(), llvm::ConstantFoldLoadFromConstPtr(), consume_back(), consume_front(), llvm::formatv_object_base::consumeFieldLayout(), llvm::consumeUnsignedInteger(), llvm::detail::IEEEFloat::convertFromString(), llvm::convertUTF8ToUTF16String(), llvm::ConvertUTF8toWide(), llvm::ConvertUTF8toWideInternal(), CopyStringRef(), count(), llvm::zlib::crc32(), llvm::StringMapEntry< llvm::Comdat >::Create(), llvm::MachineFunction::createExternalSymbolName(), llvm::Hexagon_MC::createHexagonMCSubtargetInfo(), llvm::X86Operand::CreateToken(), decodeBase64StringEntry(), drop_back(), drop_front(), dumpDWARFv5StringOffsetsSection(), dumpStringOffsetsSection(), llvm::DWARFDebugPubTable::DWARFDebugPubTable(), edit_distance(), llvm::object::ELFFile< ELFT >::ELFFile(), llvm::BitstreamWriter::emitBlob(), llvm::AMDGPUTargetELFStreamer::EmitDirectiveHSACodeObjectISA(), EmitFileEntry(), llvm::InstrProfRecordWriterTrait::EmitKeyDataLength(), llvm::DWARFYAML::EmitPubSection(), llvm::emitSourceFileHeader(), encodeBitmaskPerm(), llvm::CodeViewContext::encodeDefRange(), llvm::sys::path::end(), llvm::StringSwitch< T, R >::EndsWith(), llvm::Regex::escape(), llvm::RuntimeDyldCheckerExprEval::evaluate(), llvm::coverage::CounterMappingContext::evaluate(), llvm::BitstreamWriter::ExitBlock(), expand(), llvm::sys::path::extension(), llvm::StringTableBuilder::finalizeInOrder(), find(), find_first_not_of(), find_first_of(), find_if(), find_last_not_of(), find_last_of(), find_lower(), fitsInUstar(), formatPax(), llvm::fromHex(), llvm::DWARFUnit::getAddrOffsetSectionItem(), llvm::ConstantDataSequential::getAsCString(), getAsInteger(), GetAutoSenseRadix(), llvm::APInt::getBitsNeeded(), llvm::MemoryBufferRef::getBufferSize(), llvm::object::ELFFile< ELFT >::getBufSize(), llvm::ARM::getCanonicalArchName(), llvm::SparcTargetLowering::getConstraintType(), llvm::MSP430TargetLowering::getConstraintType(), llvm::AVRTargetLowering::getConstraintType(), llvm::HexagonTargetLowering::getConstraintType(), llvm::SITargetLowering::getConstraintType(), llvm::ARMTargetLowering::getConstraintType(), llvm::SystemZTargetLowering::getConstraintType(), llvm::NVPTXTargetLowering::getConstraintType(), llvm::PPCTargetLowering::getConstraintType(), llvm::X86TargetLowering::getConstraintType(), llvm::TargetLowering::getConstraintType(), llvm::object::getElfArchType(), getEncodedUnnamedAddr(), llvm::DwarfStringPool::getEntry(), llvm::object::ELFFile< ELFT >::getEntry(), llvm::Triple::getEnvironmentVersion(), getEstimate(), llvm::getFuncNameWithoutPrefix(), getFunctionName(), getGNUBinOpPrecedence(), llvm::object::MachOObjectFile::getIndirectName(), llvm::Mips16InstrInfo::getInlineAsmLength(), llvm::HexagonInstrInfo::getInlineAsmLength(), llvm::TargetInstrInfo::getInlineAsmLength(), llvm::ARMTargetLowering::getInlineAsmMemConstraint(), llvm::SystemZTargetLowering::getInlineAsmMemConstraint(), getItaniumTypeName(), llvm::MDString::getLength(), llvm::object::MachOObjectFile::getLibraryShortNameByIndex(), llvm::DWARFContext::getLineTableForUnit(), llvm::ThinLTOBuffer::getMemBuffer(), llvm::MemoryBuffer::getMemBufferCopy(), llvm::getMemOPSizeRangeFromOption(), llvm::object::ArchiveMemberHeader::getName(), llvm::object::Elf_Sym_Impl< ELFT >::getName(), llvm::MemoryBuffer::getNewUninitMemBuffer(), llvm::object::Archive::Child::getNext(), getNextRegister(), getOptionPred(), llvm::cl::generic_parser_base::getOptionWidth(), llvm::cl::basic_parser_impl::getOptionWidth(), llvm::StringToOffsetTable::GetOrAddStringOffset(), llvm::MCContext::getOrCreateLSDASymbol(), llvm::opt::ArgList::GetOrMakeJoinedArgString(), llvm::Triple::getOSVersion(), llvm::BPFTargetLowering::getRegForInlineAsmConstraint(), llvm::SparcTargetLowering::getRegForInlineAsmConstraint(), llvm::LanaiTargetLowering::getRegForInlineAsmConstraint(), llvm::MSP430TargetLowering::getRegForInlineAsmConstraint(), llvm::AVRTargetLowering::getRegForInlineAsmConstraint(), llvm::HexagonTargetLowering::getRegForInlineAsmConstraint(), llvm::SITargetLowering::getRegForInlineAsmConstraint(), llvm::ARMTargetLowering::getRegForInlineAsmConstraint(), llvm::SystemZTargetLowering::getRegForInlineAsmConstraint(), llvm::NVPTXTargetLowering::getRegForInlineAsmConstraint(), llvm::PPCTargetLowering::getRegForInlineAsmConstraint(), llvm::X86TargetLowering::getRegForInlineAsmConstraint(), llvm::TargetLowering::getRegForInlineAsmConstraint(), llvm::object::ELFFile< ELFT >::getSectionContentsAsArray(), llvm::object::ELFFile< ELFT >::getSectionName(), llvm::X86TargetLowering::getSingleConstraintMatchWeight(), llvm::object::Archive::Child::getSize(), getSpecialRegForName(), llvm::ConstantDataArray::getString(), llvm::AsmToken::getStringContents(), llvm::DWARFUnit::getStringOffsetSectionItem(), llvm::X86TargetMachine::getSubtargetImpl(), getTime(), llvm::getTypeName(), getUnicodeEncoding(), llvm::AMDGPUMangledLibFunc::getUnmangledName(), llvm::yaml::ScalarNode::getValue(), getValueStr(), getVarName(), llvm::PerFunctionMIParsingState::getVRegInfo(), llvm::object::MachOObjectFile::guessLibraryShortName(), llvm::DWARFVerifier::handleDebugInfo(), HandlePrefixedOrGroupedOption(), llvm::IntelExpr::hasBaseReg(), llvm::SHA1::hash(), llvm::HashString(), llvm::pdb::hashStringV1(), llvm::IntelExpr::hasIndexReg(), hasUnaryFloatFn(), llvm::identify_magic(), inBytes(), incrementLoc(), INITIALIZE_PASS(), llvm::ExecutionEngine::InitializeMemory(), llvm::yaml::ScalarTraits< char_16 >::input(), llvm::yaml::ScalarTraits< uuid_t >::input(), llvm::codeview::DebugStringTableSubsection::insert(), isCoverageMappingDummy(), llvm::TrigramIndex::isDefinitelyOut(), isIdentifierChar(), isImplicitOperandIn(), llvm::XCoreTargetLowering::isLegalAddressingMode(), isOperator(), isRepeatedByteSequence(), isReportingError(), isValidEncoding(), llvm::DataExtractor::isValidOffset(), isWeak(), llvm::detail::join_impl(), LLVMGetAsString(), LLVMTargetMachineEmitToMemoryBuffer(), loadTestingFormat(), llvm::Function::lookupIntrinsicID(), llvm::Intrinsic::lookupLLVMIntrinsicByName(), llvm::AMDGPUIntrinsicInfo::lookupName(), llvm::TargetIntrinsicInfo::lookupName(), lower(), llvm::object::MachOUniversalBinary::MachOUniversalBinary(), llvm::MCGenDwarfLabelEntry::Make(), llvm::LTOModule::makeBuffer(), llvm::opt::DerivedArgList::MakeJoinedArg(), mapArchToCVCPUType(), mapNameAndUniqueName(), llvm::GlobPattern::match(), llvm::Regex::match(), MatchCoprocessorOperandName(), matchOption(), maybeLexHexadecimalLiteral(), maybeLexIndex(), maybeLexIndexAndName(), maybeLexIRBlock(), maybeLexIRValue(), maybeLexMachineBasicBlock(), maybeLexSubRegisterIndex(), MCAttrForString(), llvm::DWARFExpression::iterator::operator++(), llvm::operator+=(), llvm::raw_ostream::operator<<(), optimizeUnaryDoubleFP(), llvm::DWARFDebugFrame::parse(), llvm::parseAnalysisUtilityPasses(), parseBackslash(), parseDuration(), llvm::MetadataLoader::MetadataLoaderImpl::parseMetadata(), llvm::DWARFDebugLoc::parseOneLocationList(), llvm::DWARFDebugLocDWO::parseOneLocationList(), parsePhysicalReg(), parseRefinementStep(), parseRegisterNumber(), llvm::MCSectionMachO::ParseSectionSpecifier(), llvm::parseType(), llvm::AsmLexer::peekTokens(), previousIsLoop(), llvm::ScopedPrinter::printBinary(), llvm::ScopedPrinter::printBinaryBlock(), printBSDMemberHeader(), PrintCFIEscape(), llvm::PrintEscapedString(), llvm::cl::generic_parser_base::printGenericOptionDiff(), PrintHelpOptionList(), printLine(), llvm::printLLVMNameWithoutPrefix(), printMetadataIdentifier(), llvm::cl::generic_parser_base::printOptionInfo(), llvm::cl::basic_parser_impl::printOptionName(), PrintQuotedString(), printSourceLine(), promoteToConstantPool(), llvm::sys::path::rbegin(), llvm::irsymtab::readBitcode(), readCoverageMappingData(), llvm::readPGOFuncNameStrings(), llvm::sampleprof::SampleProfileReaderBinary::readString(), llvm::LessRecordRegister::RecordParts::RecordParts(), llvm::sys::path::relative_path(), llvm::sys::path::remove_leading_dotslash(), llvm::object::replace(), llvm::sys::path::replace_extension(), llvm::sys::path::replace_path_prefix(), llvm::report_fatal_error(), RequiresVFPRegListValidation(), llvm::RuntimeDyldImpl::resolveExternalSymbols(), rewritesSort(), rfind(), rfind_lower(), llvm::StringSaver::save(), llvm::yaml::Output::scalarString(), llvm::object::ELFFile< ELFT >::sections(), llvm::orc::rpc::SerializationTraits< ChannelT, std::string, StringRef, typename std::enable_if< std::is_base_of< RawByteChannel, ChannelT >::value >::type >::serialize(), llvm::StructType::setName(), llvm::X86Operand::setTokenValue(), llvm::shouldBeSls(), split(), llvm::formatv_object_base::splitLiteralAndReplacement(), splitPath(), srcMgrDiagHandler(), llvm::StringSwitch< T, R >::StartsWith(), llvm::sys::path::stem(), llvm::StrInStrNoCase(), llvm::Regex::sub(), take_back(), take_front(), llvm::toHex(), llvm::cl::TokenizeGNUCommandLine(), llvm::cl::TokenizeWindowsCommandLine(), truncateToSize(), llvm::codeview::TypeServer2Record::TypeServer2Record(), llvm::zlib::uncompress(), unescapeQuotedString(), UnpackFromArgumentSlot(), llvm::SHA1::update(), llvm::MD5::update(), UpgradeIntrinsicFunction1(), upgradeLoopTag(), upper(), useStringTable(), llvm::APInt::ushl_ov(), llvm::WebAssemblyTargetLowering::WebAssemblyTargetLowering(), llvm::StringTableBuilder::write(), llvm::MCObjectWriter::writeBytes(), llvm::WriteIndexToFile(), llvm::MachObjectWriter::writeSegmentLoadCommand(), writeStringRecord(), writeSymbolTable(), writeUstarHeader(), and llvm::xxHash64().

◆ slice()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef llvm::StringRef::slice ( size_t  Start,
size_t  End 
) const
inline

Return a reference to the substring from [Start, End).

Parameters
StartThe index of the starting character in the substring; if the index is npos or greater than the length of the string then the empty substring will be returned.
EndThe index following the last character to include in the substring. If this is npos or exceeds the number of characters remaining in the string, the string suffix (starting with Start) will be returned. If this is less than Start, an empty string will be returned.

Definition at line 710 of file StringRef.h.

References LLVM_NODISCARD, llvm::max(), and StringRef().

Referenced by addNegOperand(), CheckBaseRegAndIndexRegAndScale(), llvm::object::ObjectFile::createMachOObjectFile(), getEstimate(), getNextRegister(), getObjCClassCategory(), getObjCMethodName(), llvm::AsmToken::getStringContents(), llvm::getToken(), llvm::object::MachOObjectFile::guessLibraryShortName(), llvm::yaml::ScalarTraits< uuid_t >::input(), isIdentifierChar(), isValidEncoding(), llvm::DWARFDebugFrame::parse(), parseDuration(), llvm::MetadataLoader::MetadataLoaderImpl::parseMetadata(), parseRegisterNumber(), parseValidVectorKind(), llvm::GCOVBuffer::readGCOVVersion(), llvm::GCOVBuffer::readInt(), llvm::GCOVBuffer::readString(), RequiresVFPRegListValidation(), rsplit(), setRequiredFeatureString(), llvm::shouldBeSls(), llvm::SmallString< 256 >::slice(), split(), llvm::formatv_object_base::splitLiteralAndReplacement(), llvm::Regex::sub(), and truncateToSize().

◆ split() [1/4]

LLVM_NODISCARD std::pair<StringRef, StringRef> llvm::StringRef::split ( char  Separator) const
inline

Split into two substrings around the first occurrence of a separator character.

If Separator is in the string, then the result is a pair (LHS, RHS) such that (*this == LHS + Separator + RHS) is true and RHS is maximal. If Separator is not in the string, then the result is a pair (LHS, RHS) where (*this == LHS) and (RHS == "").

Parameters
SeparatorThe character to split on.
Returns
The split substrings.

Definition at line 727 of file StringRef.h.

References find(), LLVM_NODISCARD, slice(), and StringRef().

Referenced by addForcedAttributes(), branchDiv(), CheckBaseRegAndIndexRegAndScale(), ExecGraphViewer(), findTargetSubtable(), llvm::Triple::getArchName(), llvm::codeview::getBytesAsCString(), llvm::Triple::getEnvironmentName(), getFullyQualifiedName(), llvm::object::COFFObjectFile::getHintName(), llvm::sys::detail::getHostCPUNameForARM(), llvm::sys::detail::getHostCPUNameForS390x(), llvm::AMDGPU::getIntegerPairAttribute(), getIntOperandFromRegisterString(), getIntOperandsFromRegisterString(), llvm::ModuleSummaryIndex::getOriginalNameBeforePromote(), llvm::Triple::getOSAndEnvironmentName(), llvm::Triple::getOSName(), llvm::sampleprof::SampleProfileReader::getSamplesFor(), getSearchPaths(), llvm::codeview::getSymbolName(), llvm::Triple::getVendorName(), llvm::HexagonGetLastSlot(), incrementLoc(), llvm::yaml::CustomMappingTraits< std::map< std::vector< uint64_t >, WholeProgramDevirtResolution::ByArg > >::inputOne(), isThumbFunction(), llvm::object::Lexer::lex(), LookupNearestOption(), llvm::Triple::normalize(), llvm::PassBuilder::parseAAPipeline(), llvm::parseCachePruningPolicy(), parseNamePrefix(), llvm::MCSectionMachO::ParseSectionSpecifier(), previousIsLoop(), llvm::cl::Option::printHelpStr(), printSymbolizedStackTrace(), llvm::DebugCounter::push_back(), llvm::readPGOFuncNameStrings(), llvm::GCOVBuffer::readString(), llvm::setCurrentDebugTypes(), Split(), split(), split(), llvm::Regex::sub(), llvm::opt::OptTable::suggestValueCompletions(), llvm::Triple::Triple(), UsesVectorABI(), and WriteAsOperandInternal().

◆ split() [2/4]

LLVM_NODISCARD std::pair<StringRef, StringRef> llvm::StringRef::split ( StringRef  Separator) const
inline

Split into two substrings around the first occurrence of a separator string.

If Separator is in the string, then the result is a pair (LHS, RHS) such that (*this == LHS + Separator + RHS) is true and RHS is maximal. If Separator is not in the string, then the result is a pair (LHS, RHS) where (*this == LHS) and (RHS == "").

Parameters
Separator- The string to split on.
Returns
- The split substrings.

Definition at line 745 of file StringRef.h.

References find(), LLVM_NODISCARD, npos, size(), slice(), split(), and StringRef().

◆ split() [3/4]

void StringRef::split ( SmallVectorImpl< StringRef > &  A,
StringRef  Separator,
int  MaxSplit = -1,
bool  KeepEmpty = true 
) const

Split into substrings around the occurrences of a separator string.

Each substring is stored in A. If MaxSplit is >= 0, at most MaxSplit splits are done and consequently <= MaxSplit + 1 elements are added to A. If KeepEmpty is false, empty strings are not added to A. They still count when considering MaxSplit An useful invariant is that Separator.join(A) == *this if MaxSplit == -1 and KeepEmpty == true

Parameters
A- Where to put the substrings.
Separator- The string to split on.
MaxSplit- The maximum number of times the string is split.
KeepEmpty- True if empty substring should be added.

Definition at line 329 of file StringRef.cpp.

References empty(), find(), npos, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), size(), and slice().

◆ split() [4/4]

void StringRef::split ( SmallVectorImpl< StringRef > &  A,
char  Separator,
int  MaxSplit = -1,
bool  KeepEmpty = true 
) const

Split into substrings around the occurrences of a separator character.

Each substring is stored in A. If MaxSplit is >= 0, at most MaxSplit splits are done and consequently <= MaxSplit + 1 elements are added to A. If KeepEmpty is false, empty strings are not added to A. They still count when considering MaxSplit An useful invariant is that Separator.join(A) == *this if MaxSplit == -1 and KeepEmpty == true

Parameters
A- Where to put the substrings.
Separator- The string to split on.
MaxSplit- The maximum number of times the string is split.
KeepEmpty- True if empty substring should be added.

Definition at line 356 of file StringRef.cpp.

References empty(), find(), npos, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), and slice().

◆ startswith()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool llvm::StringRef::startswith ( StringRef  Prefix) const
inline

Check if this string starts with the given Prefix.

Definition at line 267 of file StringRef.h.

References LLVM_ATTRIBUTE_ALWAYS_INLINE, LLVM_NODISCARD, llvm::cl::Prefix, and startswith_lower().

Referenced by llvm::InnerLoopVectorizer::addMetadata(), llvm::analyzeBuiltinArguments(), llvm::object::Archive::Archive(), llvm::ARMBuildAttrs::AttrTypeFromString(), llvm::RuntimeDyldCheckerImpl::checkAllRulesInBuffer(), CheckBaseRegAndIndexRegAndScale(), llvm::object::Archive::Child::Child(), CloneLoopBlocks(), llvm::MipsABIInfo::computeTargetABI(), computeTargetABI(), consume_front(), llvm::GlobPattern::create(), doesIgnoreDataTypeSuffix(), llvm::NVPTXAsmPrinter::doFinalization(), llvm::ARMTargetStreamer::emitTargetAttributes(), encodeCnt(), llvm::Function::eraseFromParent(), llvm::RuntimeDyldCheckerExprEval::evaluate(), findTargetSubtable(), forEachUser(), llvm::AArch64::getArchAttr(), llvm::ARM::getArchExtFeature(), GetAutoSenseRadix(), llvm::ARM::getCanonicalArchName(), getELFKindForNamedSection(), getELFSectionType(), llvm::Triple::getEnvironmentVersion(), llvm::XCoreTargetObjectFile::getExplicitSectionGlobal(), llvm::getFuncNameWithoutPrefix(), getName(), llvm::object::ArchiveMemberHeader::getName(), llvm::object::getNameType(), llvm::Mangler::getNameWithPrefix(), getNextRegister(), llvm::MCContext::getOrCreateLSDASymbol(), llvm::opt::ArgList::GetOrMakeJoinedArgString(), llvm::Triple::getOSVersion(), getPow(), llvm::object::COFFObjectFile::getSectionName(), getSignature(), getSpecialRegForName(), getSuccPad(), llvm::object::ELFObjectFile< ELFT >::getSymbolFlags(), llvm::yaml::Node::getVerbatimTag(), GlobalWasGeneratedByCompiler(), llvm::object::MachOObjectFile::guessLibraryShortName(), hasPrefix(), INITIALIZE_PASS(), instrumentMaskedLoadOrStore(), intToken(), llvm::LTOModule::isBitcodeForTarget(), llvm::object::isDecorated(), llvm::object::Decompressor::isGnuStyle(), llvm::MCSectionCOFF::isImplicitlyDiscardable(), isInput(), llvm::yaml::isNumber(), isObjCClass(), llvm::objcarc::IsObjCIdentifiedObject(), isWeak(), llvm::LLLexer::LLLexer(), llvm::Intrinsic::lookupLLVMIntrinsicByName(), llvm::AMDGPUIntrinsicInfo::lookupName(), llvm::MCGenDwarfLabelEntry::Make(), llvm::GlobPattern::match(), matchAsm(), matchOption(), llvm::mayBeOldLoopAttachmentTag(), llvm::MaybePredicatedInst(), llvm::PassInfoMixin< PromotePass >::name(), llvm::orc::GlobalRenamer::needsRenaming(), llvm::Triple::normalize(), optimizeUnaryDoubleFP(), llvm::parseAnalysisUtilityPasses(), parseArch(), llvm::ARM::parseArchEndian(), parseARMArch(), parsePhysicalReg(), parseValidVectorKind(), parseVersionFromName(), printSymbolizedStackTrace(), processGlobal(), PushArgMD(), llvm::Function::recalculateIntrinsicID(), RefineErrorLoc(), llvm::object::replace(), llvm::XCoreTargetLowering::ReplaceNodeResults(), RequiresVFPRegListValidation(), llvm::runFuzzerOnInputs(), llvm::HexagonTargetObjectFile::SelectSectionForGlobal(), SetLoopAlreadyUnrolled(), llvm::shouldBeSls(), shouldInstrumentBlock(), ShouldUpgradeX86Intrinsic(), startswith(), llvm::SmallString< 256 >::startswith(), startsWithDefaultPipelineAliasPrefix(), llvm::StripDebugInfo(), StripSymtab(), StripTypeNames(), truncateToSize(), llvm::UpgradeIntrinsicCall(), UpgradeIntrinsicFunction1(), upgradeLoopTag(), UpgradeX86IntrinsicFunction(), and llvm::object::WasmObjectFile::WasmObjectFile().

◆ startswith_lower()

bool StringRef::startswith_lower ( StringRef  Prefix) const

Check if this string starts with the given Prefix, ignoring case.

Definition at line 62 of file StringRef.cpp.

References ascii_strncasecmp().

Referenced by addNegOperand(), llvm::detail::HelperFunctions::consumeHexStyle(), find_lower(), incrementLoc(), matchOption(), startswith(), and llvm::StringSwitch< T, R >::StartsWithLower().

◆ str()

LLVM_NODISCARD std::string llvm::StringRef::str ( ) const
inline

str - Get the contents as an std::string.

Definition at line 228 of file StringRef.h.

References LLVM_NODISCARD.

Referenced by llvm::DwarfCompileUnit::addGlobalName(), llvm::DwarfCompileUnit::addGlobalNameForTypeUnit(), llvm::DwarfCompileUnit::addGlobalType(), llvm::DwarfCompileUnit::addGlobalTypeUnitType(), llvm::cacheAnnotationFromMD(), llvm::yaml::Output::canElideEmptySequence(), llvm::sys::path::convert_to_slash(), llvm::Hexagon_MC::createHexagonMCSubtargetInfo(), llvm::createPGOInstrumentationUseLegacyPass(), findInputFile(), llvm::StringInit::getAsString(), llvm::CodeInit::getAsString(), llvm::FieldInit::getAsString(), llvm::bfi_detail::getBlockName(), getChompedLineBreaks(), llvm::LineEditor::getCompletionAction(), getDescription(), llvm::GlobalValue::getGlobalIdentifier(), llvm::DOTGraphTraits< const Function * >::getGraphName(), llvm::AMDGPUIntrinsicInfo::getName(), llvm::getPGOFuncName(), llvm::DOTGraphTraits< const Function * >::getSimpleNodeLabel(), llvm::Nios2TargetMachine::getSubtargetImpl(), llvm::HexagonTargetMachine::getSubtargetImpl(), llvm::SparcTargetMachine::getSubtargetImpl(), llvm::WebAssemblyTargetMachine::getSubtargetImpl(), llvm::AArch64TargetMachine::getSubtargetImpl(), llvm::PPCTargetMachine::getSubtargetImpl(), llvm::ARMBaseTargetMachine::getSubtargetImpl(), llvm::MipsTargetMachine::getSubtargetImpl(), llvm::Record::getValueAsBitOrUnset(), llvm::NVPTXAsmPrinter::ignoreLoc(), llvm::yaml::ScalarTraits< StringValue >::input(), llvm::yaml::CustomMappingTraits< std::map< std::vector< uint64_t >, WholeProgramDevirtResolution::ByArg > >::inputOne(), llvm::yaml::CustomMappingTraits< std::map< uint64_t, WholeProgramDevirtResolution > >::inputOne(), llvm::yaml::CustomMappingTraits< GlobalValueSummaryMapTy >::inputOne(), llvm::yaml::StdMapStringCustomMappingTraitsImpl< T >::inputOne(), isImplicitOperandIn(), LLVMGetFunctionAddress(), llvm::LockFileManager::LockFileManager(), mangleCoveragePath(), normalizePBQPSpillWeight(), operator std::string(), llvm::DWARFDebugLine::LineTable::parse(), llvm::cl::parser< std::string >::parse(), llvm::AVROperand::print(), llvm::detail::PrintTo(), reportFastISelFailure(), rewriteComdat(), rewritesSort(), llvm::DOTGraphTraitsViewer< AnalysisT, IsSimple, GraphT, AnalysisGraphTraitsT >::runOnFunction(), llvm::DOTGraphTraitsPrinter< AnalysisT, IsSimple, GraphT, AnalysisGraphTraitsT >::runOnFunction(), llvm::MCContext::setCompilationDir(), llvm::MCParsedAsmOperand::setConstraint(), llvm::DwarfDebug::shareAcrossDWOCUs(), smallData(), StackMallocSizeClass(), llvm::Twine::str(), suffixed_name_or(), truncateToSize(), and writeTimestampFile().

◆ substr()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef llvm::StringRef::substr ( size_t  Start,
size_t  N = npos 
) const
inline

Return a reference to the substring from [Start, Start + N).

Parameters
StartThe index of the starting character in the substring; if the index is npos or greater than the length of the string then the empty substring will be returned.
NThe number of characters to included in the substring. If N exceeds the number of characters remaining in the string, the string suffix (starting with Start) will be returned.

Definition at line 598 of file StringRef.h.

References LLVM_ATTRIBUTE_ALWAYS_INLINE, LLVM_NODISCARD, N, and StringRef().

Referenced by llvm::InnerLoopVectorizer::addMetadata(), addNegOperand(), llvm::RuntimeDyldCheckerImpl::checkAllRulesInBuffer(), CheckBaseRegAndIndexRegAndScale(), llvm::object::Archive::Child::Child(), CommaSeparateAndAddOccurrence(), llvm::consumeUnsignedInteger(), count(), decodeBase64StringEntry(), llvm::DWARFContext::defaultErrorHandler(), drop_back(), drop_front(), drop_until(), drop_while(), llvm::GlobalValue::dropLLVMManglingEscape(), EatNumber(), emitComments(), llvm::emitSourceFileHeader(), llvm::RuntimeDyldCheckerExprEval::evaluate(), expand(), llvm::sys::path::extension(), llvm::DWARFFormValue::extractValue(), find_lower(), llvm::MCJIT::findModuleForSymbol(), llvm::symbolize::LLVMSymbolizer::flush(), llvm::format_provider< T, typename std::enable_if< detail::use_string_formatter< T >::value >::type >::format(), llvm::AArch64::getArchAttr(), llvm::ARM::getArchExtFeature(), llvm::object::MachOUniversalBinary::ObjectForArch::getAsArchive(), llvm::ConstantDataSequential::getAsCString(), getAsInteger(), llvm::object::MachOUniversalBinary::ObjectForArch::getAsObjectFile(), GetAutoSenseRadix(), llvm::ARM::getCanonicalArchName(), llvm::getConstantStringInfo(), llvm::TargetLowering::getConstraintType(), llvm::Triple::getEnvironmentVersion(), llvm::GlobalValue::getGlobalIdentifier(), getGNUBinOpPrecedence(), llvm::getMemOPSizeRangeFromOption(), getName(), llvm::object::ArchiveMemberHeader::getName(), getNameWithPrefixImpl(), getNextRegister(), getOpEnabled(), getOpRefinementSteps(), getOptionPred(), llvm::Triple::getOSVersion(), llvm::SITargetLowering::getRegForInlineAsmConstraint(), llvm::object::MachOObjectFile::getSectionContents(), llvm::object::COFFObjectFile::getSectionName(), getSpecialRegForName(), llvm::getToken(), llvm::getTypeName(), llvm::yaml::ScalarNode::getValue(), getVarName(), llvm::yaml::Node::getVerbatimTag(), HandlePrefixedOrGroupedOption(), hasUnaryFloatFn(), inBytes(), incrementLoc(), INITIALIZE_PASS(), intToken(), isIdentifierChar(), isLoopPassName(), isValidEncoding(), isWeak(), llvm::object::Lexer::lex(), llvm::LibCallSimplifier::LibCallSimplifier(), loadTestingFormat(), llvm::MCGenDwarfLabelEntry::Make(), llvm::GlobPattern::match(), matchAsm(), matchOption(), llvm::cl::SubCommand::operator bool(), llvm::sys::path::parent_path(), llvm::parseAnalysisUtilityPasses(), llvm::yaml::Document::parseBlockNode(), ParseHead(), ParseLine(), llvm::DWARFDebugLoc::parseOneLocationList(), llvm::DWARFDebugLocDWO::parseOneLocationList(), parseRefinementStep(), parseVersionFromName(), previousIsLoop(), PrintCFIEscape(), PrintQuotedString(), RefineErrorLoc(), llvm::sys::path::relative_path(), llvm::sys::path::remove_leading_dotslash(), llvm::sys::path::rend(), llvm::object::replace(), llvm::sys::path::replace_path_prefix(), RequiresVFPRegListValidation(), llvm::cl::ResetAllOptionOccurrences(), rfind(), rfind_lower(), llvm::sys::path::root_path(), scan(), llvm::shouldBeSls(), llvm::formatv_object_base::splitLiteralAndReplacement(), splitPath(), srcMgrDiagHandler(), llvm::sys::path::stem(), llvm::StrInStrNoCase(), StripFlag(), llvm::Regex::sub(), llvm::SmallString< 256 >::substr(), take_until(), take_while(), unescapeQuotedString(), llvm::UpgradeIntrinsicCall(), UpgradeIntrinsicFunction1(), UpgradeX86IntrinsicFunction(), llvm::sroa::AllocaSliceRewriter::visit(), and llvm::object::WasmObjectFile::WasmObjectFile().

◆ take_back()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef llvm::StringRef::take_back ( size_t  N = 1) const
inline

Return a StringRef equal to 'this' but with only the last N elements remaining.

If N is greater than the length of the string, the entire string is returned.

Definition at line 619 of file StringRef.h.

References drop_front(), LLVM_ATTRIBUTE_ALWAYS_INLINE, LLVM_NODISCARD, N, and size().

Referenced by llvm::codeview::consume(), and encodeCnt().

◆ take_front()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef llvm::StringRef::take_front ( size_t  N = 1) const
inline

Return a StringRef equal to 'this' but with only the first N elements remaining.

If N is greater than the length of the string, the entire string is returned.

Definition at line 608 of file StringRef.h.

References drop_back(), LLVM_ATTRIBUTE_ALWAYS_INLINE, LLVM_NODISCARD, N, and size().

Referenced by emitNullTerminatedSymbolName(), mapNameAndUniqueName(), and llvm::codeview::CodeViewRecordIO::mapStringZ().

◆ take_until()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef llvm::StringRef::take_until ( function_ref< bool(char)>  F) const
inline

Return the longest prefix of 'this' such that no character in the prefix satisfies the given predicate.

Definition at line 637 of file StringRef.h.

References F(), find_if(), LLVM_ATTRIBUTE_ALWAYS_INLINE, LLVM_NODISCARD, and substr().

◆ take_while()

LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef llvm::StringRef::take_while ( function_ref< bool(char)>  F) const
inline

Return the longest prefix of 'this' such that every character in the prefix satisfies the given predicate.

Definition at line 629 of file StringRef.h.

References F(), find_if_not(), LLVM_ATTRIBUTE_ALWAYS_INLINE, LLVM_NODISCARD, and substr().

Referenced by llvm::formatv_object_base::splitLiteralAndReplacement().

◆ trim() [1/2]

LLVM_NODISCARD StringRef llvm::StringRef::trim ( char  Char) const
inline

Return string with consecutive Char characters starting from the left and right removed.

Definition at line 836 of file StringRef.h.

References LLVM_NODISCARD, ltrim(), and rtrim().

Referenced by llvm::RuntimeDyldCheckerImpl::check(), llvm::RuntimeDyldCheckerExprEval::evaluate(), incrementLoc(), llvm::IsCPSRDead< MCInst >(), isValidEncoding(), llvm::formatv_object_base::parseReplacementItem(), and llvm::detail::PrintTo().

◆ trim() [2/2]

LLVM_NODISCARD StringRef llvm::StringRef::trim ( StringRef  Chars = " \t\n\v\f\r") const
inline

Return string with consecutive characters in Chars starting from the left and right removed.

Definition at line 843 of file StringRef.h.

References ltrim(), and rtrim().

◆ upper()

std::string StringRef::upper ( ) const

◆ withNullAsEmpty()

static StringRef llvm::StringRef::withNullAsEmpty ( const char data)
inlinestatic

Definition at line 98 of file StringRef.h.

References StringRef().

Member Data Documentation

◆ npos

const size_t StringRef::npos = ~size_t(0)
static

Definition at line 51 of file StringRef.h.

Referenced by llvm::InnerLoopVectorizer::addMetadata(), addNegOperand(), llvm::X86FrameLowering::adjustForHiPEPrologue(), buildFixItLine(), CommaSeparateAndAddOccurrence(), contains(), contains_lower(), llvm::sys::fs::createTemporaryFile(), llvm::RuntimeDyldCheckerExprEval::evaluate(), llvm::sys::path::extension(), find(), find_first_not_of(), find_first_of(), find_if(), find_last_not_of(), find_last_of(), find_lower(), llvm::symbolize::LLVMSymbolizer::flush(), forceRenaming(), llvm::format_provider< T, typename std::enable_if< detail::use_string_formatter< T >::value >::type >::format(), getAttrFromCode(), llvm::ARM::getCanonicalArchName(), getChompedLineBreaks(), llvm::DataExtractor::getCStr(), llvm::DataExtractor::getCStrRef(), llvm::HexagonTargetObjectFile::getExplicitSectionGlobal(), llvm::sys::detail::getHostCPUNameForS390x(), llvm::SourceMgr::getLineAndColumn(), llvm::Value::getName(), getNextRegister(), llvm::InstrProfSymtab::getOrigFuncName(), llvm::object::ArchiveMemberHeader::getRawName(), llvm::getTypeName(), llvm::yaml::ScalarNode::getValue(), llvm::object::MachOObjectFile::guessLibraryShortName(), hasObjCCategory(), hasUnaryFloatFn(), hasWildcard(), llvm::MIRParserImpl::initializeJumpTableInfo(), instrumentMaskedLoadOrStore(), is_ns_word_char(), llvm::ConstantDataSequential::isCString(), llvm::Regex::isLiteralERE(), isLoopPassName(), llvm::yaml::isNumber(), llvm::objcarc::IsObjCIdentifiedObject(), isReportingError(), isSmallDataSection(), isWeak(), llvm::LLLexer::LLLexer(), llvm::Intrinsic::lookupLLVMIntrinsicByName(), MCAttrForString(), llvm::yaml::needsQuotes(), llvm::cl::SubCommand::operator bool(), llvm::sys::path::parent_path(), ParseLine(), parseRefinementStep(), parseValidVectorKind(), printName(), llvm::BinaryStreamReader::readCString(), llvm::sys::path::remove_filename(), llvm::object::replace(), llvm::sys::path::replace_extension(), RequiresVFPRegListValidation(), rfind(), rfind_lower(), sanitizeFunctionName(), scan(), setRequiredFeatureString(), split(), llvm::formatv_object_base::splitLiteralAndReplacement(), splitPath(), llvm::sys::path::stem(), llvm::StrInStrNoCase(), llvm::UpgradeIntrinsicCall(), UpgradeIntrinsicFunction1(), llvm::sroa::AllocaSliceRewriter::visit(), and wasEscaped().


The documentation for this class was generated from the following files: