LLVM 19.0.0git
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]

Public Types

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

Public Member Functions

Constructors
 StringRef ()=default
 Construct an empty string ref.
 
 StringRef (std::nullptr_t)=delete
 Disable conversion from nullptr.
 
constexpr StringRef (const char *Str)
 Construct a string ref from a cstring.
 
constexpr StringRef (const char *data, size_t length)
 Construct a string ref from a pointer and length.
 
 StringRef (const std::string &Str)
 Construct a string ref from an std::string.
 
constexpr StringRef (std::string_view Str)
 Construct a string ref from an std::string_view.
 
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
constexpr const chardata () const
 data - Get a pointer to the start of the string (which may not be null terminated).
 
constexpr bool empty () const
 empty - Check if the string is empty.
 
constexpr size_t size () const
 size - Get the string size.
 
char front () const
 front - Get the first character in the string.
 
char back () const
 back - Get the last character in the string.
 
template<typename Allocator >
StringRef copy (Allocator &A) const
 
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.
 
bool equals_insensitive (StringRef RHS) const
 Check for string equality, ignoring case.
 
int compare (StringRef RHS) const
 compare - Compare two strings; the result is negative, zero, or positive if this string is lexicographically less than, equal to, or greater than the RHS.
 
int compare_insensitive (StringRef RHS) const
 Compare two strings, ignoring case.
 
int compare_numeric (StringRef RHS) const
 compare_numeric - Compare two strings, treating sequences of digits as numbers.
 
unsigned edit_distance (StringRef Other, bool AllowReplacements=true, unsigned MaxEditDistance=0) const
 Determine the edit distance between this string and another string.
 
unsigned edit_distance_insensitive (StringRef Other, bool AllowReplacements=true, unsigned MaxEditDistance=0) const
 
std::string str () const
 str - Get the contents as an std::string.
 
std::string lower () const
 
std::string upper () const
 Convert the given ASCII string to uppercase.
 
Operator Overloads
char operator[] (size_t Index) const
 
template<typename T >
std::enable_if_t< std::is_same< T, std::string >::value, StringRef > & operator= (T &&Str)=delete
 Disallow accidental assignment from a temporary std::string.
 
Type Conversions
constexpr operator std::string_view () const
 
String Predicates
bool starts_with (StringRef Prefix) const
 Check if this string starts with the given Prefix.
 
 LLVM_DEPRECATED ("Use starts_with instead", "starts_with") bool startswith(StringRef Prefix) const
 
bool starts_with_insensitive (StringRef Prefix) const
 Check if this string starts with the given Prefix, ignoring case.
 
bool ends_with (StringRef Suffix) const
 Check if this string ends with the given Suffix.
 
 LLVM_DEPRECATED ("Use ends_with instead", "ends_with") bool endswith(StringRef Suffix) const
 
bool ends_with_insensitive (StringRef Suffix) const
 Check if this string ends with the given Suffix, ignoring case.
 
String Searching
size_t find (char C, size_t From=0) const
 Search for the first character C in the string.
 
size_t find_insensitive (char C, size_t From=0) const
 Search for the first character C in the string, ignoring case.
 
size_t find_if (function_ref< bool(char)> F, size_t From=0) const
 Search for the first character satisfying the predicate F.
 
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.
 
size_t find (StringRef Str, size_t From=0) const
 Search for the first string Str in the string.
 
size_t find_insensitive (StringRef Str, size_t From=0) const
 Search for the first string Str in the string, ignoring case.
 
size_t rfind (char C, size_t From=npos) const
 Search for the last character C in the string.
 
size_t rfind_insensitive (char C, size_t From=npos) const
 Search for the last character C in the string, ignoring case.
 
size_t rfind (StringRef Str) const
 Search for the last string Str in the string.
 
size_t rfind_insensitive (StringRef Str) const
 Search for the last string Str in the string, ignoring case.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
bool contains (StringRef Other) const
 Return true if the given string is a substring of *this, and false otherwise.
 
bool contains (char C) const
 Return true if the given character is contained in *this, and false otherwise.
 
bool contains_insensitive (StringRef Other) const
 Return true if the given string is a substring of *this, and false otherwise.
 
bool contains_insensitive (char C) const
 Return true if the given character is contained in *this, and false otherwise.
 
Helpful Algorithms
size_t count (char C) const
 Return the number of occurrences of C in the string.
 
size_t count (StringRef Str) const
 Return the number of non-overlapped occurrences of Str in the string.
 
template<typename T >
bool getAsInteger (unsigned Radix, T &Result) const
 Parse the current string as an integer of the specified radix.
 
template<typename T >
bool consumeInteger (unsigned Radix, T &Result)
 Parse the current string as an integer of the specified radix.
 
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.
 
bool consumeInteger (unsigned Radix, APInt &Result)
 Parse the current string as an integer of the specified Radix.
 
bool getAsDouble (double &Result, bool AllowInexact=true) const
 Parse the current string as an IEEE double-precision floating point value.
 
Substring Operations
constexpr StringRef substr (size_t Start, size_t N=npos) const
 Return a reference to the substring from [Start, Start + N).
 
StringRef take_front (size_t N=1) const
 Return a StringRef equal to 'this' but with only the first N elements remaining.
 
StringRef take_back (size_t N=1) const
 Return a StringRef equal to 'this' but with only the last N elements remaining.
 
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.
 
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.
 
StringRef drop_front (size_t N=1) const
 Return a StringRef equal to 'this' but with the first N elements dropped.
 
StringRef drop_back (size_t N=1) const
 Return a StringRef equal to 'this' but with the last N elements dropped.
 
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.
 
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.
 
bool consume_front (StringRef Prefix)
 Returns true if this StringRef has the given prefix and removes that prefix.
 
bool consume_front_insensitive (StringRef Prefix)
 Returns true if this StringRef has the given prefix, ignoring case, and removes that prefix.
 
bool consume_back (StringRef Suffix)
 Returns true if this StringRef has the given suffix and removes that suffix.
 
bool consume_back_insensitive (StringRef Suffix)
 Returns true if this StringRef has the given suffix, ignoring case, and removes that suffix.
 
StringRef slice (size_t Start, size_t End) const
 Return a reference to the substring from [Start, End).
 
std::pair< StringRef, StringRefsplit (char Separator) const
 Split into two substrings around the first occurrence of a separator character.
 
std::pair< StringRef, StringRefsplit (StringRef Separator) const
 Split into two substrings around the first occurrence of a separator string.
 
std::pair< StringRef, StringRefrsplit (StringRef Separator) const
 Split into two substrings around the last occurrence of a separator string.
 
void split (SmallVectorImpl< StringRef > &A, StringRef Separator, int MaxSplit=-1, bool KeepEmpty=true) const
 Split into substrings around the occurrences of a separator string.
 
void split (SmallVectorImpl< StringRef > &A, char Separator, int MaxSplit=-1, bool KeepEmpty=true) const
 Split into substrings around the occurrences of a separator character.
 
std::pair< StringRef, StringRefrsplit (char Separator) const
 Split into two substrings around the last occurrence of a separator character.
 
StringRef ltrim (char Char) const
 Return string with consecutive Char characters starting from the the left removed.
 
StringRef ltrim (StringRef Chars=" \t\n\v\f\r") const
 Return string with consecutive characters in Chars starting from the left removed.
 
StringRef rtrim (char Char) const
 Return string with consecutive Char characters starting from the right removed.
 
StringRef rtrim (StringRef Chars=" \t\n\v\f\r") const
 Return string with consecutive characters in Chars starting from the right removed.
 
StringRef trim (char Char) const
 Return string with consecutive Char characters starting from the left and right removed.
 
StringRef trim (StringRef Chars=" \t\n\v\f\r") const
 Return string with consecutive characters in Chars starting from the left and right removed.
 
StringRef detectEOL () const
 Detect the line ending style of the string.
 

Static Public Attributes

static constexpr size_t npos = ~size_t(0)
 

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 50 of file StringRef.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 55 of file StringRef.h.

◆ iterator

Definition at line 54 of file StringRef.h.

◆ size_type

Definition at line 56 of file StringRef.h.

Constructor & Destructor Documentation

◆ StringRef() [1/6]

llvm::StringRef::StringRef ( )
default

Construct an empty string ref.

◆ StringRef() [2/6]

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

Disable conversion from nullptr.

This prevents things like if (S == nullptr)

◆ StringRef() [3/6]

constexpr llvm::StringRef::StringRef ( const char Str)
inlineconstexpr

Construct a string ref from a cstring.

Definition at line 84 of file StringRef.h.

References llvm::Length.

◆ StringRef() [4/6]

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

Construct a string ref from a pointer and length.

Definition at line 96 of file StringRef.h.

References llvm::Length.

◆ StringRef() [5/6]

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

Construct a string ref from an std::string.

Definition at line 100 of file StringRef.h.

References llvm::Length.

◆ StringRef() [6/6]

constexpr llvm::StringRef::StringRef ( std::string_view  Str)
inlineconstexpr

Construct a string ref from an std::string_view.

Definition at line 104 of file StringRef.h.

References llvm::Length, and llvm::size().

Member Function Documentation

◆ back()

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

◆ begin()

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

Definition at line 111 of file StringRef.h.

Referenced by llvm::sys::path::append(), llvm::MDString::begin(), llvm::object::ViewArray< T >::begin(), llvm::object::BigArchive::BigArchive(), llvm::yaml::BlockScalarNode::BlockScalarNode(), chopOneUTF32(), llvm::dwarf_linker::parallel::CompileUnit::cloneDieAttrExpression(), llvm::detail::IEEEFloat::convertFromString(), llvm::convertUTF8ToUTF16String(), llvm::object::Archive::ec_symbols(), llvm::yaml::escape(), llvm::APInt::getBitsNeeded(), llvm::MemoryBufferRef::getBufferStart(), llvm::sys::detail::getHostCPUNameForPowerPC(), getHostID(), llvm::object::Archive::Symbol::getName(), llvm::object::ArchiveMemberHeader::getName(), llvm::object::Archive::getNumberOfECSymbols(), llvm::object::Archive::getNumberOfSymbols(), llvm::InstrProfReaderItaniumRemapper< HashTableImpl >::getRecords(), llvm::object::COFFObjectFile::getRelocationTypeName(), llvm::object::MachOObjectFile::getRelocationTypeName(), llvm::object::WasmObjectFile::getRelocationTypeName(), llvm::object::XCOFFObjectFile::getRelocationTypeName(), llvm::TargetLoweringObjectFile::getSymbolWithGlobalValueBase(), llvm::TextInstrProfReader::hasFormat(), llvm::hash_value(), llvm::Timer::init(), llvm::object::DirectX::Signature::initialize(), llvm::TGLexer::Lex(), llvm::LLLexer::LLLexer(), llvm::pdb::NamedStreamMap::load(), lower(), llvm::object::MachOUniversalBinary::MachOUniversalBinary(), llvm::sys::fs::make_absolute(), makeAbsolute(), llvm::symbolize::MarkupParser::nextNode(), llvm::object::MachOUniversalBinary::ObjectForArch::ObjectForArch(), llvm::SmallString< InternalLen >::operator+=(), llvm::object::ViewArray< T >::iterator::operator--(), llvm::object::Archive::Child::operator==(), llvm::sys::path::const_iterator::operator==(), llvm::sys::path::reverse_iterator::operator==(), llvm::InlineAsm::ParseConstraints(), parseMaybeMangledName(), readInteger(), readStruct(), llvm::InstrProfReaderItaniumRemapper< HashTableImpl >::reconstituteName(), llvm::sys::path::replace_extension(), llvm::yaml::ScalarNode::ScalarNode(), llvm::AsmLexer::setBuffer(), llvm::EngineBuilder::setMArch(), llvm::EngineBuilder::setMCPU(), llvm::TimerGroup::setName(), llvm::stable_hash_combine_string(), llvm::sys::unicode::startsWith(), llvm::object::Archive::symbol_begin(), llvm::TGLexer::TGLexer(), updateLoadCommandPayloadString(), and upper().

◆ bytes()

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

Definition at line 121 of file StringRef.h.

References llvm::make_range().

Referenced by llvm::djbHash().

◆ bytes_begin()

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

◆ bytes_end()

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

◆ compare()

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

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

Definition at line 177 of file StringRef.h.

References llvm::Length, and RHS.

Referenced by llvm::SmallString< InternalLen >::compare(), compareNames(), getArgAccessQual(), getKernelArgTypeQual(), and SortSymbolPair().

◆ compare_insensitive()

int StringRef::compare_insensitive ( StringRef  RHS) const

Compare two strings, ignoring case.

Definition at line 37 of file StringRef.cpp.

References ascii_strncasecmp(), and RHS.

Referenced by llvm::SmallString< InternalLen >::compare_insensitive(), 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 61 of file StringRef.cpp.

References E, I, isDigit(), and RHS.

Referenced by llvm::SmallString< InternalLen >::compare_numeric(), and llvm::LessRecord::operator()().

◆ consume_back()

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

◆ consume_back_insensitive()

bool llvm::StringRef::consume_back_insensitive ( StringRef  Suffix)
inline

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

Definition at line 661 of file StringRef.h.

References size(), llvm::size(), and substr().

◆ consume_front()

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

◆ consume_front_insensitive()

bool llvm::StringRef::consume_front_insensitive ( StringRef  Prefix)
inline

Returns true if this StringRef has the given prefix, ignoring case, and removes that prefix.

Definition at line 641 of file StringRef.h.

References substr().

◆ consumeInteger() [1/2]

bool StringRef::consumeInteger ( unsigned  Radix,
APInt Result 
)

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. The portion of the string representing the discovered numeric value is removed from the beginning of the string.

Definition at line 506 of file StringRef.cpp.

References assert(), llvm::BitWidth, GetAutoSenseRadix(), and size().

◆ consumeInteger() [2/2]

template<typename T >
bool 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 495 of file StringRef.h.

References llvm::consumeSignedInteger(), and llvm::consumeUnsignedInteger().

Referenced by llvm::AMDGPUMachineFunction::AMDGPUMachineFunction(), FindCheckType(), llvm::HexagonSubtarget::initializeSubtargetDependencies(), llvm::yaml::ScalarTraits< FrameIndex >::input(), llvm::Pattern::parseNumericSubstitutionBlock(), llvm::formatv_object_base::parseReplacementItem(), llvm::AMDGPUPALMetadata::setFromString(), and llvm::SIMachineFunctionInfo::SIMachineFunctionInfo().

◆ contains() [1/2]

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

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

Definition at line 426 of file StringRef.h.

References C, and npos.

◆ contains() [2/2]

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

◆ contains_insensitive() [1/2]

bool llvm::StringRef::contains_insensitive ( char  C) const
inline

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

Definition at line 438 of file StringRef.h.

References C, and npos.

◆ contains_insensitive() [2/2]

bool llvm::StringRef::contains_insensitive ( StringRef  Other) const
inline

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

Definition at line 432 of file StringRef.h.

References npos, and Other.

Referenced by llvm::generateReadImageInst().

◆ copy()

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

Definition at line 153 of file StringRef.h.

References A, and llvm::Length.

Referenced by llvm::yaml::Document::parseBlockNode().

◆ count() [1/2]

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

◆ 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 371 of file StringRef.cpp.

References find(), N, and npos.

◆ data()

constexpr const char * llvm::StringRef::data ( ) const
inlineconstexpr

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

Definition at line 131 of file StringRef.h.

Referenced by llvm::msgpack::Document::addString(), annotateAllFunctions(), appendGlobalSymbolTableInfo(), llvm::object::ArchiveMemberHeader::ArchiveMemberHeader(), llvm::object::BigArchive::BigArchive(), llvm::CachedHashString::CachedHashString(), llvm::FileCheckString::CheckDag(), llvm::FileCheckString::CheckNext(), llvm::FileCheckString::CheckSame(), llvm::object::Archive::Child::Child(), constructSegment(), constructSymbolEntry(), llvm::objcopy::coff::createGnuDebugLinkSectionContents(), llvm::jitlink::createLinkGraphFromELFObject(), createMemberHeaderParseError(), llvm::DWARFListTableHeader::dump(), llvm::DWARFDebugPubTable::dump(), llvm::DWARFDebugLoclists::dumpRawEntry(), edit_distance(), edit_distance_insensitive(), llvm::DIEAbbrev::Emit(), llvm::BitstreamWriter::emitBlob(), llvm::DWARFYAML::emitDebugAbbrev(), llvm::DWARFYAML::emitDebugLine(), llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::emitFDE(), llvm::RuntimeDyldImpl::emitSection(), llvm::cl::Option::error(), ExpandBasePaths(), llvm::DWARFListType< ListEntryType >::extract(), FindFirstMatchingPrefix(), llvm::json::fixUTF8(), llvm::RuntimeDyldCOFFAArch64::generateRelocationStub(), llvm::RuntimeDyldCOFFX86_64::generateRelocationStub(), llvm::ErrorDiagnostic::get(), llvm::irsymtab::storage::Str::get(), llvm::irsymtab::storage::Range< T >::get(), llvm::DataExtractor::getCStr(), llvm::DataExtractor::getCStrRef(), llvm::LTOModule::getDependentLibrary(), llvm::AsmToken::getEndLoc(), llvm::objcopy::elf::SRecord::getHeader(), llvm::HexagonInstrInfo::getInlineAsmLength(), getInstructionID(), llvm::dwarf_linker::parallel::SectionDescriptor::getIntVal(), llvm::AsmToken::getLoc(), llvm::DWARFDie::getLocations(), llvm::GCOVFunction::getName(), llvm::object::Elf_Sym_Impl< ELFT >::getName(), llvm::object::ArchiveMemberHeader::getName(), llvm::NVPTXRegisterInfo::getName(), llvm::object::BigArchiveMemberHeader::getNextChildLoc(), getNextLoadCommandInfo(), llvm::opt::ArgList::GetOrMakeJoinedArgString(), llvm::object::ArchiveMemberHeader::getRawName(), llvm::object::BigArchiveMemberHeader::getRawName(), llvm::TargetLowering::getRegForInlineAsmConstraint(), llvm::SITargetLowering::getRegForInlineAsmConstraint(), llvm::PPCTargetLowering::getRegForInlineAsmConstraint(), llvm::SparcTargetLowering::getRegForInlineAsmConstraint(), llvm::RuntimeDyldMachO::getRelocationValueRef(), llvm::object::ELFFile< ELFT >::getSectionName(), getUUID(), llvm::object::ELFFile< ELFT >::getVersionDependencies(), gsiRecordCmp(), isAsmComment(), llvm::json::isUTF8(), LLVMGetDebugLocDirectory(), LLVMGetDebugLocFilename(), LLVMGetNamedMetadataName(), LLVMOrcSymbolStringPoolEntryStr(), llvm::NVPTXTargetLowering::LowerCall(), llvm::VETargetLowering::LowerCustomJumpTableEntry(), llvm::LegalizerHelper::lowerReadWriteRegister(), llvm::remarks::magicToFormat(), PrefixMatcher::match(), llvm::Pattern::match(), llvm::sys::path::native(), llvm::MCJIT::notifyFreeingObject(), llvm::MCJIT::notifyObjectLoaded(), llvm::remarks::ParsedStringTable::operator[](), llvm::jitlink::COFFDirectiveParser::parse(), llvm::remarks::ParsedStringTable::ParsedStringTable(), llvm::remarks::parseFormat(), llvm::remarks::parseHotnessThresholdOption(), parseMaybeMangledName(), llvm::Pattern::parseNumericSubstitutionBlock(), llvm::Pattern::parsePattern(), parseRD(), parseStrTab(), parseStrTabSize(), parseTypeIdSummaryRecord(), parseV2DirFileTables(), parseVersion(), parseWholeProgramDevirtResolution(), ProcessMatchResult(), llvm::RuntimeDyldELF::processRelocationRef(), llvm::xray::FileBasedRecordProducer::produce(), llvm::irsymtab::readBitcode(), llvm::FileCheck::readCheckFile(), readCoverageMappingData(), llvm::jitlink::readTargetMachineArch(), llvm::LessRecordRegister::RecordParts::RecordParts(), llvm::Regex::Regex(), llvm::report_fatal_error(), reportError(), llvm::StringSaver::save(), llvm::orc::MachOBuilder< MachOTraits >::Section::Section(), llvm::orc::MachOBuilder< MachOTraits >::Segment::Segment(), llvm::orc::shared::SPSSerializationTraits< SPSString, StringRef >::serialize(), llvm::cl::TokenizeGNUCommandLine(), llvm::codeview::TypeServer2Record::TypeServer2Record(), validateMagicNumber(), llvm::objcopy::wasm::Writer::write(), and llvm::yaml::yaml2archive().

◆ detectEOL()

StringRef llvm::StringRef::detectEOL ( ) const
inline

Detect the line ending style of the string.

If the string contains a line ending, return the line ending character sequence that is detected. Otherwise return '
' for unix line endings.

Returns
- The line ending character sequence.

Definition at line 827 of file StringRef.h.

References llvm::find(), llvm::Length, and npos.

◆ drop_back()

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

◆ drop_front()

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

◆ drop_until()

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 625 of file StringRef.h.

References F, llvm::find_if(), and substr().

◆ drop_while()

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 619 of file StringRef.h.

References F, llvm::find_if_not(), 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 92 of file StringRef.cpp.

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

Referenced by LookupNearestOption().

◆ edit_distance_insensitive()

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

Definition at line 100 of file StringRef.cpp.

References llvm::ComputeMappedEditDistance(), data(), llvm::Other, and size().

◆ empty()

constexpr bool llvm::StringRef::empty ( ) const
inlineconstexpr

empty - Check if the string is empty.

Definition at line 134 of file StringRef.h.

References llvm::Length.

Referenced by llvm::MachO::InterfaceFile::addAllowableClient(), llvm::DwarfDebug::addDwarfTypeUnitType(), llvm::InstrProfSymtab::addFuncName(), addMappingsFromTLI(), llvm::MachO::InterfaceFile::addParentUmbrella(), llvm::MachO::InterfaceFile::addReexportedLibrary(), llvm::MachO::InterfaceFile::addRPath(), llvm::AMDGPUMachineFunction::AMDGPUMachineFunction(), llvm::analyzeImportedModule(), llvm::objcopy::elf::OwnedDataSection::appendHexData(), llvm::DwarfUnit::applySubprogramAttributes(), llvm::DwarfUnit::applySubprogramDefinitionAttributes(), buildDWODescription(), llvm::caseFoldingDjbHash(), llvm::checkDebugInfoMetadata(), chopOneUTF32(), llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::cloneAndEmitDebugFrame(), llvm::InlineAsm::collectAsmStrs(), llvm::DIEHash::computeCUSignature(), computeDefaultCPU(), llvm::ARM::computeDefaultTargetABI(), llvm::RISCVABI::computeTargetABI(), llvm::LoongArchABI::computeTargetABI(), computeTargetABI(), llvm::DwarfUnit::constructTypeDIE(), llvm::consumeUnsignedInteger(), llvm::detail::IEEEFloat::convertFromString(), llvm::convertUTF8ToUTF16String(), llvm::vfs::RedirectingFileSystem::create(), llvm::memprof::RawMemProfReader::create(), llvm::sys::fs::create_directories(), createAArch64MCSubtargetInfo(), llvm::sampleprof::SampleContext::createCtxVectorFromStr(), createLoongArchMCSubtargetInfo(), createProfileFileNameVar(), llvm::createProfileFileNameVar(), createRISCVMCSubtargetInfo(), llvm::createSanitizerCtorAndInitFunctions(), createSparcMCSubtargetInfo(), llvm::sys::fs::createTemporaryFile(), createVEMCSubtargetInfo(), llvm::X86_MC::createX86MCSubtargetInfo(), llvm::declareSanitizerInitFunction(), llvm::FileCheckPatternContext::defineCmdlineVariables(), llvm::DWARFUnit::determineStringOffsetsTableContributionDWO(), llvm::ELFYAML::dropUniqueSuffix(), llvm::gsym::GsymReader::dump(), llvm::DWARFDebugLoclists::dumpRawEntry(), llvm::object::Archive::ec_symbols(), llvm::emitAMDGPUPrintfCall(), emitComments(), EmitGenDwarfAbbrev(), EmitGenDwarfInfo(), llvm::TargetLoweringObjectFileMachO::emitModuleMetadata(), llvm::ARMTargetStreamer::emitTargetAttributes(), llvm::cl::Option::error(), ExpandBasePaths(), llvm::cl::ExpansionContext::expandResponseFiles(), llvm::AMDGPU::fillAMDGPUFeatureMap(), find_if(), FindFirstMatchingPrefix(), llvm::sampleprof::FunctionSamples::findFunctionSamplesAt(), llvm::finishBuildOpDecorate(), flattenCommandLine(), llvm::format_provider< std::chrono::duration< Rep, Period > >::format(), llvm::JITSymbolFlags::fromGlobalValue(), llvm::Attribute::get(), llvm::get_threadpool_strategy(), llvm::AMDGPU::getArchFamilyNameAMDGCN(), llvm::ARM::getARMCPUForArch(), llvm::DINode::getCanonicalMDString(), llvm::DIMacroNode::getCanonicalMDString(), llvm::objcopy::elf::IHexRecord::getChecksum(), llvm::dwarf_linker::classic::DeclContextTree::getChildDeclContext(), llvm::objcopy::ConfigManager::getCOFFConfig(), llvm::MCContext::getCOFFSection(), getCommonClassOptions(), llvm::getCPU(), llvm::dwarf_linker::parallel::CompileUnit::getDirAndFilenameFromLineTable(), llvm::MCContext::getELFSection(), llvm::json::Path::Root::getError(), llvm::object::COFFImportFile::getExportName(), getExtensionVersion(), getFeatures(), llvm::DWARFDebugLine::Prologue::getFileNameByIndex(), llvm::coverage::CovMapFunctionRecordV1< IntPtrT >::getFuncName(), llvm::getFuncNameWithoutPrefix(), llvm::InstrProfSymtab::getFuncOrVarNameIfDefined(), llvm::gsym::GsymReader::getFunctionInfoDataAtIndex(), llvm::object::AbstractArchiveMemberHeader::getGID(), llvm::GlobalValue::getGlobalIdentifier(), getGPUOrDefault(), llvm::AMDGPU::getIntegerVecAttribute(), llvm::X86TargetLowering::getIRStackGuard(), getItineraryLatency(), llvm::TargetLibraryInfoImpl::getLibFunc(), llvm::object::MachOObjectFile::getLibraryShortNameByIndex(), llvm::objcopy::ConfigManager::getMachOConfig(), getOpEnabled(), getOpRefinementSteps(), llvm::DwarfCompileUnit::getOrCreateCommonBlock(), llvm::DwarfCompileUnit::getOrCreateGlobalVariableDIE(), llvm::symbolize::LLVMSymbolizer::getOrCreateModuleInfo(), llvm::getOrCreateSanitizerCtorAndInitFunctions(), llvm::MCContext::getOrCreateSymbol(), getPassNameAndInstanceNum(), llvm::getPGOFuncName(), getPrettyScopeName(), llvm::MCObjectFileInfo::getPseudoProbeDescSection(), getQualifiedNameIndex(), llvm::InstrProfReaderItaniumRemapper< HashTableImpl >::getRecords(), llvm::SparcTargetLowering::getRegForInlineAsmConstraint(), getSearchPaths(), getStackGuard(), llvm::getSubDirectoryPath(), llvm::M68kMCInstLower::GetSymbolFromOperand(), llvm::TargetLoweringObjectFile::getSymbolWithGlobalValueBase(), llvm::lto::getThinLTOOutputFile(), getUnicodeEncoding(), llvm::MCSymbolXCOFF::getUnqualifiedName(), getUUID(), llvm::VecDesc::getVectorFunctionABIVariantString(), llvm::VFABI::getVectorVariantNames(), llvm::yaml::Node::getVerbatimTag(), llvm::objcopy::ConfigManager::getWasmConfig(), llvm::TargetLibraryInfoImpl::getWidestVF(), llvm::objcopy::ConfigManager::getXCOFFConfig(), llvm::DWARFVerifier::handleDebugAbbrev(), HandlePrefixedOrGroupedOption(), 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(), llvm::IntelExpr::hasBaseReg(), llvm::SubtargetFeatures::hasFlag(), llvm::IntelExpr::hasIndexReg(), llvm::MCAsmInfo::hasLinkerPrivateGlobalPrefix(), llvm::IntelExpr::hasOffset(), llvm::GlobalValue::hasSection(), llvm::X86TargetLowering::hasStackProbeSymbol(), llvm::object::Archive::hasSymbolTable(), llvm::CSKYSubtarget::initializeSubtargetDependencies(), llvm::MSP430Subtarget::initializeSubtargetDependencies(), llvm::NVPTXSubtarget::initializeSubtargetDependencies(), llvm::SparcSubtarget::initializeSubtargetDependencies(), llvm::MCSubtargetInfo::InitMCProcessorInfo(), llvm::X86TargetLowering::insertSSPDeclarations(), llvm::gsym::GsymCreator::insertString(), llvm::AMDGPU::insertWaveSizeFeature(), llvm::SampleProfileProber::instrumentOneFunc(), llvm::ELFAttributeParser::integerAttribute(), isCanonical(), llvm::object::ViewArray< T >::isEmpty(), llvm::SubtargetFeatures::isEnabled(), llvm::TargetLibraryInfoImpl::isFunctionVectorizable(), llvm::TargetMachine::isLargeGlobalValue(), llvm::RISCVISAInfo::isSupportedExtensionWithVersion(), llvm::GlobPattern::isTrivialMatchAll(), llvm::sys::unicode::Node::isValid(), llvm::AMDGPU::MTBUFFormat::isValidNfmt(), llvm::AMDGPU::isValidOpr(), llvm::object::Lexer::lex(), llvm::LoadAndStorePromoter::LoadAndStorePromoter(), loadBinaryFormat(), llvm::OpenMPIRBuilder::loadOffloadInfoMetadata(), LookupNearestOption(), llvm::TargetRegistry::lookupTarget(), llvm::codeview::CodeViewRecordIO::mapStringZVectorZ(), llvm::Pattern::match(), llvm::GlobPattern::match(), matchAsm(), llvm::logicalview::LVPatterns::matchPattern(), llvm::symbolize::MarkupParser::nextNode(), llvm::Triple::normalize(), llvm::sys::path::reverse_iterator::operator++(), llvm::gsym::operator<<(), optimizeDoubleFP(), llvm::DWARFDebugFrame::parse(), llvm::AMDGPULibFunc::parse(), llvm::PassBuilder::parseAAPipeline(), llvm::RISCVISAInfo::parseArchString(), parseARMArch(), llvm::ARM_MC::ParseARMTriple(), parseCC(), llvm::parseDenormalFPAttribute(), llvm::remarks::ParsedStringTable::ParsedStringTable(), llvm::formatv_object_base::parseFormatString(), parseInt(), llvm::RISCVISAInfo::parseNormalizedArchString(), llvm::Pattern::parseNumericSubstitutionBlock(), llvm::Pattern::parsePattern(), llvm::remarks::YAMLRemarkParser::parseRemark(), llvm::formatv_object_base::parseReplacementItem(), llvm::MCSectionMachO::ParseSectionSpecifier(), parseSubArch(), parseV2DirFileTables(), llvm::DiagnosticInfoSampleProfile::print(), llvm::DWARFExpression::Operation::print(), llvm::MCInstPrinter::printAnnotation(), llvm::ELFAttributeParser::printAttribute(), printCFI(), PrintCFIEscape(), printExtendedName(), PrintExtension(), printFile(), llvm::AMDGPUInstPrinter::printHwreg(), llvm::cl::generic_parser_base::printOptionInfo(), llvm::AMDGPUInstPrinter::printSendMsg(), llvm::MCSectionMachO::printSwitchToSection(), printSymbolizedStackTrace(), processLoadCommands(), llvm::AttributeImpl::Profile(), llvm::irsymtab::readBitcode(), llvm::FileCheck::readCheckFile(), llvm::GCOVFile::readGCNO(), llvm::TextInstrProfReader::readNextRecord(), llvm::coverage::RawCoverageReader::readULEB128(), llvm::LessRecordRegister::RecordParts::RecordParts(), llvm::sys::path::remove_dots(), llvm::sys::path::replace_path_prefix(), llvm::ThinLTOCodeGenerator::run(), runOnFunction(), llvm::sampleprof::SampleContext::SampleContext(), sanitizeFunctionName(), llvm::dwarf_linker::parallel::AcceleratorRecordsSaver::save(), llvm::StringSaver::save(), llvm::Hexagon_MC::selectHexagonCPU(), selectM68kCPU(), llvm::MIPS_MC::selectMipsCPU(), llvm::EngineBuilder::selectTarget(), llvm::orc::shared::SPSSerializationTraits< SPSString, StringRef >::serialize(), llvm::MachO::InterfaceFile::setFromBinaryAttrs(), llvm::codegen::setFunctionAttributes(), llvm::MCContext::setGenDwarfRootFile(), llvm::GlobalValue::setPartition(), llvm::GlobalObject::setSection(), llvm::lto::setupStatsFile(), llvm::VFABI::setVectorVariantNames(), shouldAlwaysEmitCompleteClassType(), shouldPrintOption(), llvm::MachO::shouldSkipSymLink(), llvm::SIMachineFunctionInfo::SIMachineFunctionInfo(), llvm::SIModeRegisterDefaults::SIModeRegisterDefaults(), split(), splitExtsByUnderscore(), llvm::formatv_object_base::splitLiteralAndReplacement(), llvm::sys::unicode::startsWith(), llvm::ELFAttributeParser::stringAttribute(), llvm::Regex::sub(), llvm::BTFParser::symbolize(), llvm::symbolize::toJSON(), llvm::InlineAdvisorAnalysis::Result::tryCreate(), llvm::VFABI::tryDemangleForVFABI(), llvm::MCDwarfLineTableHeader::tryGetFile(), llvm::VersionTuple::tryParse(), llvm::UpgradeAttributes(), llvm::InlineAsm::verify(), llvm::write(), writeDWARFExpression(), llvm::ThinLTOCodeGenerator::writeGeneratedObject(), and llvm::writeStringsAndOffsets().

◆ end()

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

Definition at line 113 of file StringRef.h.

References llvm::Length.

Referenced by llvm::sys::path::append(), llvm::object::BigArchiveMemberHeader::BigArchiveMemberHeader(), llvm::yaml::BlockScalarNode::BlockScalarNode(), llvm::FileCheckString::CheckNext(), llvm::FileCheckString::CheckSame(), chopOneUTF32(), llvm::dwarf_linker::parallel::CompileUnit::cloneDieAttrExpression(), llvm::convertUTF8ToUTF16String(), llvm::MDString::end(), llvm::object::ViewArray< T >::end(), ends_with_insensitive(), llvm::yaml::escape(), llvm::MemoryBufferRef::getBufferEnd(), llvm::sys::detail::getHostCPUNameForPowerPC(), getHostID(), getLoadCommandInfo(), llvm::InstrProfReaderItaniumRemapper< HashTableImpl >::getRecords(), llvm::TargetLowering::getRegForInlineAsmConstraint(), llvm::object::COFFObjectFile::getRelocationTypeName(), llvm::object::MachOObjectFile::getRelocationTypeName(), llvm::object::WasmObjectFile::getRelocationTypeName(), llvm::object::XCOFFObjectFile::getRelocationTypeName(), llvm::TargetLoweringObjectFile::getSymbolWithGlobalValueBase(), llvm::hash_value(), llvm::Timer::init(), llvm::AsmLexer::LexToken(), llvm::AsmLexer::LexUntilEndOfStatement(), llvm::pdb::NamedStreamMap::load(), lower(), llvm::sys::fs::make_absolute(), llvm::symbolize::MarkupParser::nextNode(), llvm::object::ViewArray< T >::iterator::operator*(), llvm::object::ViewArray< T >::iterator::operator++(), llvm::InlineAsm::ParseConstraints(), parseMaybeMangledName(), parseRD(), parseRegisterNumber(), readInteger(), readStruct(), llvm::InstrProfReaderItaniumRemapper< HashTableImpl >::reconstituteName(), llvm::Regex::Regex(), llvm::sys::path::replace_extension(), llvm::yaml::ScalarNode::ScalarNode(), llvm::EngineBuilder::setMArch(), llvm::EngineBuilder::setMCPU(), llvm::TimerGroup::setName(), llvm::stable_hash_combine_string(), llvm::sys::unicode::startsWith(), updateLoadCommandPayloadString(), and upper().

◆ ends_with()

bool llvm::StringRef::ends_with ( StringRef  Suffix) const
inline

◆ ends_with_insensitive()

bool StringRef::ends_with_insensitive ( StringRef  Suffix) const

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

Definition at line 50 of file StringRef.cpp.

References ascii_strncasecmp(), and end().

Referenced by llvm::orc::LoadAndLinkDynLibrary::operator()().

◆ equals()

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

◆ equals_insensitive()

bool llvm::StringRef::equals_insensitive ( StringRef  RHS) const
inline

◆ find() [1/2]

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

◆ 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 130 of file StringRef.cpp.

References From, llvm::Last, LLVM_UNLIKELY, N, npos, Ptr, and 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 251 of file StringRef.cpp.

References llvm::CallingConv::C, and From.

Referenced by llvm::SmallString< InternalLen >::find_first_not_of(), matchAsm(), llvm::dwarf_linker::parseDebugTableName(), ParseLine(), llvm::FileCheck::readCheckFile(), llvm::sampleprof::SampleProfileReaderText::readImpl(), and llvm::Regex::sub().

◆ 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 259 of file StringRef.cpp.

References llvm::CallingConv::C, From, and npos.

◆ find_first_of() [1/2]

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 237 of file StringRef.cpp.

References llvm::CallingConv::C, From, and npos.

◆ find_if()

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 307 of file StringRef.h.

References drop_front(), empty(), F, From, front(), npos, size(), and llvm::size().

Referenced by find_insensitive().

◆ find_if_not()

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 322 of file StringRef.h.

References F, llvm::find_if(), and From.

◆ find_insensitive() [1/2]

size_t StringRef::find_insensitive ( 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 55 of file StringRef.cpp.

References llvm::CallingConv::C, D, find_if(), and From.

Referenced by llvm::Pattern::match().

◆ find_insensitive() [2/2]

size_t StringRef::find_insensitive ( 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 191 of file StringRef.cpp.

References From, npos, and substr().

◆ 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 289 of file StringRef.cpp.

References llvm::CallingConv::C, From, and npos.

Referenced by parseScalarValue().

◆ 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 300 of file StringRef.cpp.

References llvm::CallingConv::C, From, and npos.

◆ find_last_of() [1/2]

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

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

Definition at line 396 of file StringRef.h.

References C, and From.

Referenced by llvm::sys::path::extension(), llvm::SmallString< InternalLen >::find_last_of(), llvm::SourceMgr::getLineAndColumn(), llvm::yaml::Node::getVerbatimTag(), ParseLine(), and llvm::sys::path::stem().

◆ 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 275 of file StringRef.cpp.

References llvm::CallingConv::C, From, and npos.

◆ front()

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, or an invalid floating point representation.

Definition at line 597 of file StringRef.cpp.

References llvm::errorToBool(), F, llvm::APFloatBase::opInexact, llvm::APFloatBase::opOK, and llvm::APFloatBase::rmNearestTiesToEven.

◆ getAsInteger() [1/2]

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 587 of file StringRef.cpp.

◆ getAsInteger() [2/2]

template<typename T >
bool 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 466 of file StringRef.h.

References llvm::getAsSignedInteger(), and llvm::getAsUnsignedInteger().

Referenced by adjustCallerStackProbeSize(), adjustMinLegalVectorWidth(), llvm::object::BigArchive::BigArchive(), checkedGetHex(), llvm::object::Archive::Child::Child(), llvm::get_threadpool_strategy(), getArchiveMemberDecField(), getArchiveMemberOctField(), getExtensionVersion(), getGlobalSymtabLocAndSize(), llvm::SPIRVGlobalRegistry::getOrCreateSPIRVTypeByName(), getPassNameAndInstanceNum(), llvm::getStringFnAttrAsInt(), llvm::X86TargetMachine::getSubtargetImpl(), llvm::AMDGPU::Exp::getTgtId(), llvm::remarks::Argument::getValAsInt(), llvm::yaml::isInteger(), llvm::vfs::RedirectingFileSystemParser::parse(), llvm::SPIRV::parseBuiltinCallArgumentBaseType(), llvm::parseCachePruningPolicy(), parseDuration(), ParseHead(), llvm::remarks::parseHotnessThresholdOption(), ParseLine(), parseMetadata(), llvm::RISCVISAInfo::parseNormalizedArchString(), parseRegisterNumber(), parseSectionFlags(), llvm::MCSectionMachO::ParseSectionSpecifier(), llvm::parseStatepointDirectivesFromAttrs(), llvm::AttributeFuncs::updateMinLegalVectorWidthAttr(), and llvm::writeArchiveToStream().

◆ LLVM_DEPRECATED() [1/2]

llvm::StringRef::LLVM_DEPRECATED ( "Use ends_with instead"  ,
"ends_with"   
) const
inline

Definition at line 276 of file StringRef.h.

◆ LLVM_DEPRECATED() [2/2]

llvm::StringRef::LLVM_DEPRECATED ( "Use starts_with instead"  ,
"starts_with"   
) const
inline

Definition at line 261 of file StringRef.h.

References starts_with().

◆ lower()

std::string StringRef::lower ( ) const

◆ ltrim() [1/2]

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

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

Definition at line 787 of file StringRef.h.

References llvm::Length.

Referenced by llvm::RuntimeDyldCheckerExprEval::evaluate(), FindCheckType(), llvm::Pattern::parseNumericSubstitutionBlock(), parseScalarValue(), and llvm::VFABI::tryDemangleForVFABI().

◆ ltrim() [2/2]

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 793 of file StringRef.h.

References llvm::Length.

◆ operator std::string_view()

constexpr llvm::StringRef::operator std::string_view ( ) const
inlineconstexpr

Definition at line 248 of file StringRef.h.

References llvm::size().

◆ operator=()

template<typename T >
std::enable_if_t< std::is_same< T, std::string >::value, StringRef > & 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.

◆ operator[]()

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

Definition at line 231 of file StringRef.h.

References assert(), Index, and llvm::Length.

◆ rfind() [1/2]

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

Search for the last character C in the string.

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

Definition at line 343 of file StringRef.h.

References C, From, I, llvm::Length, and npos.

Referenced by llvm::ELFYAML::dropUniqueSuffix(), llvm::sampleprof::FunctionSamples::getCanonicalFnName(), getStringIndex(), llvm::object::MachOObjectFile::guessLibraryShortName(), ParseHead(), and llvm::SmallString< InternalLen >::rfind().

◆ 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 217 of file StringRef.cpp.

◆ rfind_insensitive() [1/2]

size_t StringRef::rfind_insensitive ( 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 202 of file StringRef.cpp.

References llvm::CallingConv::C, From, and npos.

◆ rfind_insensitive() [2/2]

size_t StringRef::rfind_insensitive ( 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 221 of file StringRef.cpp.

References equals_insensitive(), N, npos, and substr().

◆ rsplit() [1/2]

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 781 of file StringRef.h.

◆ rsplit() [2/2]

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

Split into two substrings around the last 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 minimal. 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 729 of file StringRef.h.

References Idx, npos, and size().

◆ rtrim() [1/2]

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

◆ rtrim() [2/2]

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 805 of file StringRef.h.

References llvm::Length.

◆ size()

constexpr size_t llvm::StringRef::size ( ) const
inlineconstexpr

size - Get the string size.

Definition at line 137 of file StringRef.h.

References llvm::Length.

Referenced by llvm::AArch64FunctionInfo::AArch64FunctionInfo(), llvm::Hexagon_MC::addArchSubtarget(), addSection(), llvm::msgpack::Document::addString(), llvm::BTFStringTable::addString(), angleBracketString(), llvm::objcopy::elf::OwnedDataSection::appendHexData(), llvm::DWARFTypePrinter::appendTypeTagName(), argPlusPrefixesSize(), argPrefix(), llvm::CachedHashString::CachedHashString(), llvm::CachedHashStringRef::CachedHashStringRef(), callBufferedPrintfStart(), charTailAt(), llvm::RuntimeDyldCheckerImpl::checkAllRulesInBuffer(), checkArchVersion(), llvm::SITargetLowering::checkAsmConstraintVal(), checkDyldInfoCommand(), checkDysymtabCommand(), checkEncryptCommand(), checkLinkeditDataCommand(), checkNoteCommand(), checkSymtabCommand(), checkTwoLevelHintsCommand(), llvm::object::Archive::Child::Child(), llvm::ComputeCrossModuleImport(), computeStringTable(), constructSegment(), constructSymbolEntry(), consume_back(), consume_back_insensitive(), consumeInteger(), llvm::consumeUnsignedInteger(), llvm::detail::IEEEFloat::convertFromString(), llvm::convertUTF8ToUTF16String(), llvm::coverage::BinaryCoverageReader::create(), llvm::StringMapEntry< ValueTy >::create(), llvm::sampleprof::SampleContext::createCtxVectorFromStr(), llvm::objcopy::coff::createGnuDebugLinkSectionContents(), llvm::jitlink::createLinkGraphFromELFObject(), llvm::decodeBase64(), llvm::DWARFUnit::determineStringOffsetsTableContributionDWO(), llvm::DWARFListTableBase< DWARFListType >::dump(), dumpStringOffsetsSection(), llvm::object::Archive::ec_symbols(), edit_distance(), edit_distance_insensitive(), llvm::BitstreamWriter::emitBlob(), llvm::dwarf_linker::classic::DwarfStreamer::emitCIE(), llvm::DWARFYAML::emitDebugAbbrev(), llvm::DWARFYAML::emitDebugLine(), llvm::dwarf_linker::classic::DwarfStreamer::emitFDE(), llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::emitFDE(), emitPPA1Name(), llvm::emitSourceFileHeader(), llvm::dwarf_linker::parallel::DWARFLinkerImpl::emitStringSections(), llvm::CodeViewContext::encodeDefRange(), llvm::DWARFExpression::end(), expand(), ExpandBasePaths(), llvm::sys::path::extension(), find_if(), FindCheckType(), FindFirstMatchingPrefix(), llvm::sys::unicode::findSyllable(), fixupIndexV4(), fixupIndexV5(), llvm::json::fixUTF8(), llvm::TernOpInit::Fold(), for(), formatPax(), llvm::ErrorDiagnostic::get(), llvm::DWARFUnit::getAddrOffsetSectionItem(), llvm::APInt::getBitsNeeded(), llvm::MemoryBufferRef::getBufferSize(), llvm::object::ELFFile< ELFT >::getBufSize(), llvm::sampleprof::FunctionSamples::getCanonicalFnName(), llvm::objcopy::elf::IHexRecord::getChecksum(), llvm::TargetLowering::getConstraintType(), llvm::SITargetLowering::getConstraintType(), llvm::ARMTargetLowering::getConstraintType(), llvm::AVRTargetLowering::getConstraintType(), llvm::BPFTargetLowering::getConstraintType(), llvm::HexagonTargetLowering::getConstraintType(), llvm::MSP430TargetLowering::getConstraintType(), llvm::NVPTXTargetLowering::getConstraintType(), llvm::PPCTargetLowering::getConstraintType(), llvm::RISCVTargetLowering::getConstraintType(), llvm::SparcTargetLowering::getConstraintType(), llvm::SystemZTargetLowering::getConstraintType(), llvm::VETargetLowering::getConstraintType(), llvm::X86TargetLowering::getConstraintType(), llvm::M68kTargetLowering::getConstraintType(), llvm::LTOModule::getDependentLibrary(), llvm::AsmToken::getEndLoc(), llvm::NonRelocatableStringpool::getEntry(), getExtensionVersion(), llvm::getFuncNameWithoutPrefix(), llvm::objcopy::elf::SRecord::getHeader(), llvm::HexagonInstrInfo::getInlineAsmLength(), llvm::ARMTargetLowering::getInlineAsmMemConstraint(), llvm::RISCVTargetLowering::getInlineAsmMemConstraint(), llvm::SystemZTargetLowering::getInlineAsmMemConstraint(), llvm::MDString::getLength(), getMemBufferCopyImpl(), llvm::object::Elf_Sym_Impl< ELFT >::getName(), llvm::object::ArchiveMemberHeader::getName(), llvm::WritableMemoryBuffer::getNewUninitMemBuffer(), llvm::object::Archive::getNumberOfECSymbols(), llvm::getObjCNamesIfSelector(), getOptionPrefixesSize(), llvm::cl::generic_parser_base::getOptionWidth(), llvm::cl::basic_parser_impl::getOptionWidth(), llvm::OpenMPIRBuilder::getOrCreateSrcLocStr(), llvm::opt::ArgList::GetOrMakeJoinedArgString(), llvm::Triple::getOSVersion(), getQualifiedNameIndex(), llvm::object::BigArchiveMemberHeader::getRawName(), llvm::TargetLowering::getRegForInlineAsmConstraint(), llvm::SITargetLowering::getRegForInlineAsmConstraint(), llvm::ARMTargetLowering::getRegForInlineAsmConstraint(), llvm::AVRTargetLowering::getRegForInlineAsmConstraint(), llvm::BPFTargetLowering::getRegForInlineAsmConstraint(), llvm::HexagonTargetLowering::getRegForInlineAsmConstraint(), llvm::LanaiTargetLowering::getRegForInlineAsmConstraint(), llvm::M68kTargetLowering::getRegForInlineAsmConstraint(), llvm::MSP430TargetLowering::getRegForInlineAsmConstraint(), llvm::NVPTXTargetLowering::getRegForInlineAsmConstraint(), llvm::PPCTargetLowering::getRegForInlineAsmConstraint(), llvm::RISCVTargetLowering::getRegForInlineAsmConstraint(), llvm::SparcTargetLowering::getRegForInlineAsmConstraint(), llvm::SystemZTargetLowering::getRegForInlineAsmConstraint(), llvm::VETargetLowering::getRegForInlineAsmConstraint(), llvm::X86TargetLowering::getRegForInlineAsmConstraint(), llvm::logicalview::getScopedName(), llvm::object::ELFFile< ELFT >::getSectionContentsAsArray(), llvm::object::ELFFile< ELFT >::getSectionName(), llvm::object::MachOObjectFile::getSectionSize(), llvm::object::ELFFile< ELFT >::getSegmentContents(), llvm::gsym::StringTable::getString(), llvm::DWARFUnit::getStringOffsetSectionItem(), llvm::AMDGPU::Exp::getTgtId(), getUnicodeEncoding(), getUUID(), getVarName(), llvm::object::ELFFile< ELFT >::getVersionDependencies(), llvm::CodeViewYAML::GlobalHash::GlobalHash(), gsiRecordCmp(), llvm::object::MachOObjectFile::guessLibraryShortName(), HandlePrefixedOrGroupedOption(), llvm::handleSection(), llvm::jitlink::identifyELFSectionStartAndEndSymbols(), llvm::object::DirectX::Signature::initialize(), llvm::codeview::DebugStringTableSubsection::insert(), isAsmComment(), isImmConstraint(), llvm::json::isUTF8(), LLVMGetDebugLocDirectory(), LLVMGetDebugLocFilename(), LLVMGetNamedMetadataName(), llvm::gsym::FunctionInfo::lookup(), llvm::Intrinsic::lookupLLVMIntrinsicByName(), llvm::TargetLowering::LowerAsmOperandForConstraint(), llvm::ARMTargetLowering::LowerAsmOperandForConstraint(), llvm::AVRTargetLowering::LowerAsmOperandForConstraint(), llvm::LanaiTargetLowering::LowerAsmOperandForConstraint(), llvm::M68kTargetLowering::LowerAsmOperandForConstraint(), llvm::NVPTXTargetLowering::LowerAsmOperandForConstraint(), llvm::PPCTargetLowering::LowerAsmOperandForConstraint(), llvm::RISCVTargetLowering::LowerAsmOperandForConstraint(), llvm::SparcTargetLowering::LowerAsmOperandForConstraint(), llvm::SystemZTargetLowering::LowerAsmOperandForConstraint(), llvm::InlineAsmLowering::lowerAsmOperandForConstraint(), llvm::object::MachOUniversalBinary::MachOUniversalBinary(), llvm::opt::DerivedArgList::MakeJoinedArg(), mapNameAndUniqueName(), PrefixMatcher::match(), llvm::Pattern::match(), matchOption(), maybeLexIndex(), maybeLexIndexAndName(), maybeLexIRBlock(), maybeLexIRValue(), maybeLexMCSymbol(), maybeLexSubRegisterIndex(), llvm::symbolize::MarkupParser::nextNode(), operator new(), llvm::jitlink::CompactUnwindSplitter::operator()(), llvm::DWARFExpression::iterator::operator++(), llvm::sys::path::const_iterator::operator++(), llvm::sys::path::reverse_iterator::operator++(), llvm::gsym::operator<<(), llvm::remarks::ParsedStringTable::operator[](), optimizeDoubleFP(), optimizeMemCmpVarSize(), llvm::DWARFDebugFrame::parse(), llvm::object::DirectX::PSVRuntimeInfo::parse(), llvm::parseAnalysisUtilityPasses(), llvm::RISCVISAInfo::parseArchString(), llvm::yaml::parseBool(), parseBraceExpansions(), llvm::RISCVISAInfo::parseFeatures(), parseHeader(), ParseLine(), parseMagic(), parseMaybeMangledName(), llvm::Pattern::parsePattern(), parseRefinementStep(), parseRegisterNumber(), parseScalarValue(), parseSegmentLoadCommand(), parseStrTab(), parseStrTabSize(), llvm::MachO::parseSymbol(), parseVersion(), printCFI(), PrintCFIEscape(), llvm::cl::Option::printEnumValHelpStr(), llvm::Pattern::printFuzzyMatch(), llvm::cl::generic_parser_base::printGenericOptionDiff(), printLine(), printNoMatch(), llvm::cl::generic_parser_base::printOptionInfo(), printSourceLine(), promoteToConstantPool(), llvm::irsymtab::readBitcode(), llvm::FileCheck::readCheckFile(), readCoverageMappingData(), llvm::coverage::RawCoverageReader::readSize(), llvm::coverage::RawCoverageReader::readULEB128(), llvm::InstrProfReaderItaniumRemapper< HashTableImpl >::reconstituteName(), llvm::LessRecordRegister::RecordParts::RecordParts(), llvm::sys::path::relative_path(), llvm::sys::path::remove_dots(), llvm::sys::path::replace_extension(), llvm::sys::path::replace_path_prefix(), llvm::report_fatal_error(), llvm::logicalview::LVElement::resolveFullname(), rsplit(), llvm::StringSaver::save(), llvm::orc::MachOBuilder< MachOTraits >::Section::Section(), llvm::object::ELFFile< ELFT >::sections(), llvm::orc::MachOBuilder< MachOTraits >::Segment::Segment(), llvm::orc::shared::SPSSerializationTraits< SPSString, StringRef >::serialize(), llvm::cl::Option::setArgStr(), singleLetterExtensionRank(), llvm::object::ViewArray< T >::size(), llvm::orc::shared::SPSSerializationTraits< SPSString, StringRef >::size(), llvm::DIEInlineString::sizeOf(), split(), llvm::formatv_object_base::splitLiteralAndReplacement(), llvm::sys::unicode::startsWith(), llvm::sys::path::stem(), llvm::Regex::sub(), llvm::BTFParser::symbolize(), llvm::StringAttributeImpl::totalSizeToAlloc(), llvm::codeview::TypeServer2Record::TypeServer2Record(), updateLoadCommandPayloadString(), updateSection(), upgradeLoopTag(), llvm::orc::ELFDebugObjectSection< ELFT >::validateInBounds(), llvm::DWARFVerifier::verifyDebugStrOffsets(), llvm::logicalview::LVLogicalVisitor::visitKnownMember(), llvm::object::WasmObjectFile::WasmObjectFile(), wordsOfString(), llvm::objcopy::wasm::Writer::write(), llvm::coverage::TestingFormatWriter::write(), llvm::msgpack::Writer::write(), llvm::writeStringsAndOffsets(), llvm::xxh3_64bits(), and llvm::yaml::yaml2archive().

◆ slice()

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 680 of file StringRef.h.

References End, and llvm::Length.

Referenced by llvm::FileCheckString::CheckDag(), llvm::dwarf_linker::parallel::CompileUnit::cloneDieAttrExpression(), llvm::object::ObjectFile::createMachOObjectFile(), llvm::BTFParser::findString(), llvm::objcopy::elf::SRecord::getHeader(), llvm::object::ArchiveMemberHeader::getName(), llvm::object::MachOObjectFile::guessLibraryShortName(), llvm::lookupBuiltin(), llvm::sys::path::const_iterator::operator++(), llvm::sys::path::reverse_iterator::operator++(), llvm::SPIRV::parseBuiltinCallArgumentBaseType(), parseRegisterNumber(), printSourceLine(), llvm::SmallString< InternalLen >::slice(), split(), llvm::formatv_object_base::splitLiteralAndReplacement(), and llvm::Regex::sub().

◆ split() [1/4]

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 696 of file StringRef.h.

References split().

Referenced by addSection(), llvm::InlineAsm::collectAsmStrs(), llvm::MachO::Target::create(), llvm::sampleprof::SampleContext::createCtxVectorFromStr(), llvm::sampleprof::SampleContext::decodeContextString(), llvm::FileCheckPatternContext::defineCmdlineVariables(), llvm::VPlanPrinter::dump(), llvm::AMDGPU::HSAMD::MetadataStreamerMsgPackV4::emitKernelArg(), findSection(), llvm::findVCToolChainViaEnvironment(), forceAttributes(), llvm::Triple::getArchName(), llvm::codeview::getBytesAsCString(), llvm::sampleprof::FunctionSamples::getCanonicalFnName(), llvm::object::COFFObjectFile::getDebugPDBInfo(), llvm::getDefaultDebuginfodUrls(), llvm::Triple::getEnvironmentName(), llvm::object::COFFImportFile::getExportName(), llvm::sys::detail::getHostCPUNameForARM(), llvm::sys::detail::getHostCPUNameForRISCV(), llvm::sys::detail::getHostCPUNameForS390x(), llvm::AMDGPU::getIntegerVecAttribute(), getIntOperandFromRegisterString(), getIntOperandsFromRegisterString(), getOpEnabled(), getOpRefinementSteps(), llvm::Triple::getOSAndEnvironmentName(), llvm::Triple::getOSName(), llvm::getParsedIRPGOName(), llvm::LoongArchTargetLowering::getRegisterByName(), getSearchPaths(), llvm::object::COFFObjectFile::getSectionName(), llvm::GCOVBuffer::getString(), llvm::VFABI::getVectorVariantNames(), llvm::Triple::getVendorName(), llvm::handleExecNameEncodedBEOpts(), llvm::handleExecNameEncodedOptimizerOpts(), llvm::isHeader(), isThumbFunction(), llvm::object::Lexer::lex(), llvm::lookupBuiltin(), LookupNearestOption(), llvm::PassBuilder::parseAAPipeline(), llvm::SPIRV::parseBuiltinCallArgumentBaseType(), parseCHRFilterFiles(), llvm::remarks::ParsedStringTable::ParsedStringTable(), parseNamePrefix(), llvm::RISCVISAInfo::parseNormalizedArchString(), llvm::cl::Option::printEnumValHelpStr(), llvm::cl::Option::printHelpStr(), printSymbolizedStackTrace(), llvm::DebugCounter::push_back(), llvm::readAndDecodeStrings(), llvm::GCOVBuffer::readString(), llvm::OpenMPIRBuilder::readThreadBoundsForKernel(), llvm::ForceFunctionAttrsPass::run(), llvm::Hexagon_MC::selectHexagonCPU(), llvm::AMDGPU::IsaInfo::AMDGPUTargetID::setTargetIDFromTargetIDStream(), llvm::SubtargetFeatures::Split(), splitExtsByUnderscore(), llvm::Regex::sub(), llvm::opt::OptTable::suggestValueCompletions(), and llvm::Triple::Triple().

◆ split() [2/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 339 of file StringRef.cpp.

References A, empty(), find(), Idx, npos, and slice().

◆ 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 312 of file StringRef.cpp.

References A, empty(), find(), Idx, npos, size(), and slice().

◆ split() [4/4]

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 711 of file StringRef.h.

References llvm::find(), Idx, npos, and size().

◆ starts_with()

bool llvm::StringRef::starts_with ( StringRef  Prefix) const
inline

Check if this string starts with the given Prefix.

Definition at line 257 of file StringRef.h.

References llvm::Length.

Referenced by llvm::DWARFTypePrinter::appendTypeTagName(), llvm::object::Archive::Archive(), llvm::AsmLexer::AsmLexer(), llvm::ELFAttrs::attrTypeFromString(), llvm::objcopy::elf::Object::compressOrDecompressSections(), llvm::RISCVABI::computeTargetABI(), computeTargetABI(), llvm::object::Archive::create(), llvm::remarks::createYAMLParserFromMeta(), doesIgnoreDataTypeSuffix(), llvm::Attributor::emitRemark(), llvm::ARMTargetStreamer::emitTargetAttributes(), llvm::opt::OptTable::findByPrefix(), FindCheckType(), flattenCommandLine(), llvm::JITSymbolFlags::fromGlobalValue(), llvm::generateGroupInst(), llvm::AArch64::getArchExtFeature(), llvm::getFuncNameWithoutPrefix(), llvm::GCOVFunction::getName(), llvm::object::getNameType(), llvm::SPIRVGlobalRegistry::getOrCreateSPIRVTypeByName(), llvm::opt::ArgList::GetOrMakeJoinedArgString(), llvm::Triple::getOSVersion(), llvm::TargetLowering::getRegForInlineAsmConstraint(), llvm::SITargetLowering::getRegForInlineAsmConstraint(), llvm::SystemZTargetLowering::getRegForInlineAsmConstraint(), llvm::TargetLoweringObjectFileELF::getSectionForMachineBasicBlock(), llvm::yaml::Node::getVerbatimTag(), llvm::MVT::getVT(), hasAnyUnrollPragma(), llvm::HexagonSubtarget::initializeSubtargetDependencies(), llvm::RISCV::CPUInfo::is64Bit(), llvm::LTOModule::isBitcodeForTarget(), llvm::orc::isCOFFInitializerSection(), llvm::objcopy::coff::isDebugSection(), llvm::objcopy::wasm::isDebugSection(), isDebugSection(), llvm::MCSectionCOFF::isImplicitlyDiscardable(), llvm::objcopy::wasm::isLinkerSection(), llvm::MachO::isPrivateLibrary(), llvm::objcopy::macho::SymbolEntry::isSwiftSymbol(), llvm::makeFollowupLoopID(), matchAsm(), matchOption(), llvm::Triple::normalize(), optimizeDoubleFP(), llvm::SpecialCaseList::parse(), llvm::parseAnalysisUtilityPasses(), parseArch(), llvm::ARM::parseArchEndian(), llvm::RISCVISAInfo::parseArchString(), parseARMArch(), llvm::SPIRV::parseBuiltinTypeNameToTargetExtType(), parseMaybeMangledName(), parseMetadata(), llvm::AArch64::ExtensionSet::parseModifier(), llvm::RISCVISAInfo::parseNormalizedArchString(), llvm::Pattern::parsePattern(), parseSubArch(), llvm::MachO::parseSymbol(), printSymbolizedStackTrace(), processGlobal(), llvm::RuntimeDyldCOFFAArch64::processRelocationRef(), llvm::RuntimeDyldCOFFI386::processRelocationRef(), llvm::RuntimeDyldCOFFThumb::processRelocationRef(), llvm::RuntimeDyldCOFFX86_64::processRelocationRef(), llvm::pruneCache(), llvm::TextInstrProfReader::readHeader(), llvm::TextInstrProfReader::readNextRecord(), llvm::object::replace(), replaceAndRemoveSections(), llvm::ThunkInserter< Derived, InsertedThunksTy >::run(), llvm::runFuzzerOnInputs(), llvm::sampleprof::SampleContext::SampleContext(), llvm::pdb::NativeSession::searchForPdb(), llvm::HexagonTargetObjectFile::SelectSectionForGlobal(), llvm::cl::Option::setArgStr(), llvm::SmallString< InternalLen >::starts_with(), llvm::orc::DLLImportDefinitionGenerator::tryToGenerate(), updateAndRemoveSymbols(), and upgradeLoopTag().

◆ starts_with_insensitive()

bool StringRef::starts_with_insensitive ( StringRef  Prefix) const

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

Definition at line 45 of file StringRef.cpp.

References ascii_strncasecmp().

Referenced by matchOption().

◆ str()

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

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

Definition at line 222 of file StringRef.h.

References llvm::Length.

Referenced by llvm::DwarfCompileUnit::addGlobalType(), llvm::DwarfCompileUnit::addGlobalTypeUnitType(), llvm::vfs::InMemoryFileSystem::addHardLink(), llvm::DCData::addSuccessorLabel(), buildFrameDebugInfo(), llvm::cacheAnnotationFromMD(), checkOperandCount(), llvm::dwarf_linker::parallel::CompileUnit::CompileUnit(), constructSymbolEntry(), llvm::sys::path::convert_to_slash(), llvm::Hexagon_MC::createHexagonMCSubtargetInfo(), llvm::logicalview::LVDWARFReader::createScopes(), llvm::ListeningSocket::createUnix(), llvm::MachO::Symbol::dump(), dumpSectionToFile(), llvm::objcopy::wasm::dumpSectionToFile(), llvm::emitAMDGPUPrintfCall(), llvm::MCObjectStreamer::emitFileDirective(), llvm::AMDGPUAsmPrinter::emitFunctionEntryLabel(), llvm::MCJIT::finalizeLoadedModules(), llvm::object::MachOObjectFile::findDsymObjectMembers(), findSection(), llvm::generateSampleImageInst(), llvm::DiagnosticLocation::getAbsolutePath(), llvm::DWARFFormValue::getAsCString(), llvm::FieldInit::getAsString(), llvm::Attribute::getAsString(), llvm::bfi_detail::getBlockName(), llvm::pdb::NativeSourceFile::getChecksum(), getExtensionVersion(), llvm::DOTGraphTraits< DOTFuncInfo * >::getGraphName(), llvm::DOTGraphTraits< DOTFuncMSSAInfo * >::getGraphName(), llvm::DOTGraphTraits< DOTMachineFuncInfo * >::getGraphName(), getHighestNumericTupleInDirectory(), llvm::vfs::File::getName(), llvm::DOTGraphTraits< AttributorCallGraph * >::getNodeLabel(), llvm::SDNode::getOperationName(), llvm::SPIRVGlobalRegistry::getOrCreateSPIRVTypeByName(), llvm::getPGOFuncName(), getQualifiedNameIndex(), llvm::pdb::DbiModuleDescriptor::getRecordLength(), GetSocketFD(), llvm::pdb::PDBSymbolCompiland::getSourceFileName(), llvm::SystemZTargetMachine::getSubtargetImpl(), llvm::ARMBaseTargetMachine::getSubtargetImpl(), llvm::CSKYTargetMachine::getSubtargetImpl(), llvm::HexagonTargetMachine::getSubtargetImpl(), llvm::LoongArchTargetMachine::getSubtargetImpl(), llvm::M68kTargetMachine::getSubtargetImpl(), llvm::MipsTargetMachine::getSubtargetImpl(), llvm::PPCTargetMachine::getSubtargetImpl(), llvm::RISCVTargetMachine::getSubtargetImpl(), llvm::SparcTargetMachine::getSubtargetImpl(), llvm::WebAssemblyTargetMachine::getSubtargetImpl(), llvm::XtensaTargetMachine::getSubtargetImpl(), llvm::getSymbolicOperandMnemonic(), llvm::dwarf_linker::classic::CompileUnit::getSysRoot(), llvm::Record::getValueAsBitOrUnset(), llvm::objcopy::coff::handleArgs(), INITIALIZE_PASS(), llvm::M68kSubtarget::initializeSubtargetDependencies(), LiveDebugValues::MLocTracker::LocIdxToName(), llvm::lookupBuiltin(), llvm::lookupPGONameFromMetadata(), llvm::SPIRV::lowerBuiltinType(), mangleCoveragePath(), llvm::yaml::MappingTraits< const InterfaceFile * >::NormalizedTBD::NormalizedTBD(), llvm::vfs::RedirectingFileSystem::openFileForRead(), llvm::orc::LoadAndLinkDynLibrary::operator()(), llvm::objcopy::elf::OwnedDataSection::OwnedDataSection(), llvm::cl::parser< std::string >::parse(), llvm::RISCVISAInfo::parseArchString(), parseBraceExpansions(), llvm::SPIRV::parseBuiltinCallArgumentBaseType(), llvm::RISCVISAInfo::parseFeatures(), parseIRConstant(), llvm::dxil::ResourceBase::print(), llvm::MCDecodedPseudoProbe::print(), llvm::dxil::ResourceBase::printKind(), processConstantStringArg(), processLoadCommands(), replaceWithCallToVeclib(), llvm::logicalview::LVScopeArray::resolveExtra(), llvm::PseudoProbeVerifier::runAfterPass(), runImpl(), llvm::IRSimilarity::IRInstructionData::setCalleeName(), llvm::MCContext::setCompilationDir(), llvm::vfs::YAMLVFSWriter::setOverlayDir(), llvm::vfs::RedirectingFileSystem::setOverlayFileDir(), smallData(), llvm::OutlinableRegion::splitCandidate(), llvm::Twine::str(), llvm::json::ObjectKey::str(), suffixed_name_or(), llvm::timeTraceProfilerWrite(), llvm::symbolize::toJSON(), llvm::AMDGPU::IsaInfo::AMDGPUTargetID::toString(), writeListEntryAddress(), and writeTimestampFile().

◆ substr()

constexpr StringRef llvm::StringRef::substr ( size_t  Start,
size_t  N = npos 
) const
inlineconstexpr

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 567 of file StringRef.h.

References llvm::Length, and N.

Referenced by llvm::Hexagon_MC::addArchSubtarget(), llvm::DWARFTypePrinter::appendTypeTagName(), llvm::FileCheckString::Check(), llvm::FileCheckString::CheckDag(), llvm::FileCheck::checkInput(), llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::cloneAndEmitDebugFrame(), CommaSeparateAndAddOccurrence(), llvm::consumeUnsignedInteger(), llvm::GlobPattern::create(), llvm::sampleprof::SampleContext::createCtxVectorFromStr(), llvm::FileCheckPatternContext::defineCmdlineVariables(), llvm::ELFYAML::dropUniqueSuffix(), emitComments(), llvm::AsmPrinter::emitPCSections(), emitPPA1Name(), llvm::RuntimeDyldCheckerExprEval::evaluate(), expand(), ExpandBasePaths(), llvm::sys::path::extension(), find_insensitive(), FindFirstMatchingPrefix(), llvm::MCJIT::findModuleForSymbol(), llvm::TernOpInit::Fold(), for(), llvm::format_provider< T, std::enable_if_t< detail::use_string_formatter< T >::value > >::format(), llvm::JITSymbolFlags::fromGlobalValue(), llvm::object::MachOUniversalBinary::ObjectForArch::getAsArchive(), llvm::object::MachOUniversalBinary::ObjectForArch::getAsIRObject(), llvm::object::MachOUniversalBinary::ObjectForArch::getAsObjectFile(), llvm::DataExtractor::getBytes(), llvm::sampleprof::FunctionSamples::getCanonicalFnName(), llvm::TargetLowering::getConstraintType(), llvm::object::COFFImportFile::getExportName(), getHexUint(), getOpEnabled(), getOpRefinementSteps(), llvm::SPIRVGlobalRegistry::getOrCreateSPIRVTypeByName(), llvm::Triple::getOSVersion(), getQualifiedNameIndex(), llvm::gsym::StringTable::getString(), getStringIndex(), llvm::object::MachOObjectFile::getStringTableData(), llvm::AArch64::ArchInfo::getSubArch(), llvm::ARM::ArchNames::getSubArch(), getVarName(), llvm::yaml::Node::getVerbatimTag(), HandlePrefixedOrGroupedOption(), llvm::object::DirectX::Signature::initialize(), llvm::isSpecialPass(), llvm::object::Lexer::lex(), llvm::lookupBuiltin(), PrefixMatcher::match(), matchAsm(), llvm::sys::path::const_iterator::operator++(), llvm::sys::path::reverse_iterator::operator++(), llvm::sys::path::parent_path(), llvm::parseAnalysisUtilityPasses(), llvm::RISCVISAInfo::parseArchString(), llvm::yaml::Document::parseBlockNode(), parseBraceExpansions(), llvm::SPIRV::parseBuiltinCallArgumentBaseType(), llvm::SPIRV::parseBuiltinTypeNameToTargetExtType(), llvm::dwarf_linker::parseDebugTableName(), ParseHead(), parseInt(), ParseLine(), parseMetadata(), llvm::RISCVISAInfo::parseNormalizedArchString(), llvm::Pattern::parseNumericSubstitutionBlock(), llvm::Pattern::parsePattern(), parseScalarValue(), llvm::Pattern::printFuzzyMatch(), processMultiLetterExtension(), processSingleLetterExtension(), llvm::coverage::RawCoverageFilenamesReader::read(), llvm::FileCheck::readCheckFile(), llvm::GCOVBuffer::readGCDAFormat(), llvm::GCOVBuffer::readGCNOFormat(), llvm::TextInstrProfReader::readHeader(), llvm::coverage::RawCoverageReader::readString(), llvm::coverage::RawCoverageReader::readULEB128(), llvm::sys::path::relative_path(), llvm::object::replace(), llvm::sys::path::replace_path_prefix(), rfind_insensitive(), llvm::sys::path::root_path(), llvm::DWARFDebugNames::NameTableEntry::sameNameAs(), llvm::formatv_object_base::splitLiteralAndReplacement(), llvm::sys::path::stem(), llvm::stripDirPrefix(), llvm::SubtargetFeatures::StripFlag(), llvm::Regex::sub(), llvm::SmallString< InternalLen >::substr(), llvm::BTFParser::symbolize(), llvm::VersionTuple::tryParse(), and llvm::object::WasmObjectFile::WasmObjectFile().

◆ take_back()

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 585 of file StringRef.h.

References N, and llvm::size().

Referenced by llvm::dwarf_linker::classic::DWARFLinker::link(), and llvm::dwarf_linker::parallel::DWARFLinkerImpl::printStatistic().

◆ take_front()

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

◆ take_until()

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 599 of file StringRef.h.

References F, llvm::find_if(), and substr().

◆ take_while()

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 593 of file StringRef.h.

References F, llvm::find_if_not(), and substr().

Referenced by llvm::formatv_object_base::splitLiteralAndReplacement(), and llvm::VFABI::tryDemangleForVFABI().

◆ trim() [1/2]

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

◆ trim() [2/2]

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 817 of file StringRef.h.

References rtrim().

◆ upper()

std::string StringRef::upper ( ) const

Convert the given ASCII string to uppercase.

Definition at line 116 of file StringRef.cpp.

References begin(), end(), and llvm::map_iterator().

Member Data Documentation

◆ npos

constexpr size_t StringRef::npos = ~size_t(0)
staticconstexpr

Definition at line 52 of file StringRef.h.

Referenced by llvm::X86FrameLowering::adjustForHiPEPrologue(), llvm::DWARFTypePrinter::appendUnqualifiedNameBefore(), llvm::buildEnqueueKernel(), buildFixItLine(), llvm::FileCheckString::Check(), llvm::FileCheckString::CheckDag(), checkIfSupported(), llvm::FileCheck::checkInput(), CommaSeparateAndAddOccurrence(), count(), llvm::sys::fs::createTemporaryFile(), llvm::X86_MC::createX86MCSubtargetInfo(), llvm::FileCheckPatternContext::defineCmdlineVariables(), llvm::ELFYAML::dropUniqueSuffix(), llvm::object::Archive::ec_symbols(), ExpandBasePaths(), llvm::sys::path::extension(), find(), find_first_not_of(), find_first_of(), find_insensitive(), find_last_not_of(), find_last_of(), llvm::SourceMgr::FindLocForLineAndColumn(), llvm::format_provider< T, std::enable_if_t< detail::use_string_formatter< T >::value > >::format(), llvm::symbolize::SourceCode::format(), llvm::ARM::getCanonicalArchName(), llvm::sampleprof::FunctionSamples::getCanonicalFnName(), llvm::DataExtractor::getCStrRef(), llvm::sys::detail::getHostCPUNameForS390x(), getInstrStrFromOpNo(), llvm::SourceMgr::getLineAndColumn(), llvm::object::ArchiveMemberHeader::getName(), llvm::getObjCNamesIfSelector(), llvm::object::ArchiveMemberHeader::getRawName(), llvm::getTypeName(), getTypeNamePrefix(), llvm::object::MachOObjectFile::guessLibraryShortName(), llvm::Regex::isLiteralERE(), llvm::isSpecialPass(), llvm::object::Lexer::lex(), locateCStrings(), llvm::Intrinsic::lookupLLVMIntrinsicByName(), PrefixMatcher::match(), llvm::Pattern::match(), llvm::sys::path::reverse_iterator::operator++(), llvm::sys::path::parent_path(), ParseLine(), llvm::Pattern::parseNumericSubstitutionBlock(), llvm::Pattern::parsePattern(), parseRefinementStep(), parseScalarValue(), llvm::Pattern::parseVariable(), llvm::sys::printArg(), llvm::Pattern::printFuzzyMatch(), printSourceLine(), llvm::BinaryStreamReader::readCString(), llvm::sampleprof::SampleProfileReaderText::readImpl(), llvm::sys::path::remove_dots(), llvm::sys::path::remove_filename(), llvm::object::replace(), llvm::sys::path::replace_extension(), rfind_insensitive(), singleLetterExtensionRank(), split(), llvm::formatv_object_base::splitLiteralAndReplacement(), splitUstar(), llvm::sys::path::stem(), llvm::Regex::sub(), llvm::ifs::terminatedSubstr(), and llvm::UpgradeDataLayoutString().


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