LLVM API Documentation
#include <StringRef.h>

Public Types | |
| typedef const char * | iterator |
| typedef const char * | const_iterator |
| typedef size_t | size_type |
Public Member Functions | |
Constructors | |
| StringRef () | |
| Construct an empty string ref. | |
| StringRef (const char *Str) | |
| Construct a string ref from a cstring. | |
| 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. | |
Iterators | |
| iterator | begin () const |
| iterator | end () const |
String Operations | |
| const char * | data () const |
| bool | empty () const |
| empty - Check if the string is empty. | |
| 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. | |
| bool | equals (StringRef RHS) const |
| bool | equals_lower (StringRef RHS) const |
| equals_lower - Check for string equality, ignoring case. | |
| int | compare (StringRef RHS) const |
| int | compare_lower (StringRef RHS) const |
| compare_lower - Compare two strings, ignoring case. | |
| int | compare_numeric (StringRef RHS) const |
| compare_numeric - Compare strings, handle embedded numbers. | |
| unsigned | edit_distance (StringRef Other, bool AllowReplacements=true, unsigned MaxEditDistance=0) |
| Determine the edit distance between this string and another string. | |
| 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 |
Type Conversions | |
| operator std::string () const | |
String Predicates | |
| bool | startswith (StringRef Prefix) const |
Check if this string starts with the given Prefix. | |
| bool | endswith (StringRef Suffix) const |
Check if this string ends with the given Suffix. | |
String Searching | |
| size_t | find (char C, size_t From=0) const |
| size_t | find (StringRef Str, size_t From=0) const |
| size_t | rfind (char C, size_t From=npos) const |
| size_t | rfind (StringRef Str) const |
| size_t | find_first_of (char C, size_t From=0) const |
| size_t | find_first_of (StringRef Chars, size_t From=0) const |
| size_t | find_first_not_of (char C, size_t From=0) const |
| size_t | find_first_not_of (StringRef Chars, size_t From=0) const |
| size_t | find_last_of (char C, size_t From=npos) const |
| size_t | find_last_of (StringRef Chars, size_t From=npos) const |
| size_t | find_last_not_of (char C, size_t From=npos) const |
| size_t | find_last_not_of (StringRef Chars, size_t From=npos) const |
Helpful Algorithms | |
| size_t | count (char C) const |
Return the number of occurrences of C in the string. | |
| size_t | count (StringRef Str) const |
| template<typename T > | |
| enable_if_c < std::numeric_limits< T > ::is_signed, bool >::type | getAsInteger (unsigned Radix, T &Result) const |
| template<typename T > | |
| enable_if_c <!std::numeric_limits< T > ::is_signed, bool >::type | getAsInteger (unsigned Radix, T &Result) const |
| bool | getAsInteger (unsigned Radix, APInt &Result) const |
Substring Operations | |
| StringRef | substr (size_t Start, size_t N=npos) const |
| StringRef | drop_front (size_t N=1) const |
| StringRef | drop_back (size_t N=1) const |
| StringRef | slice (size_t Start, size_t End) const |
| std::pair< StringRef, StringRef > | split (char Separator) const |
| std::pair< StringRef, StringRef > | split (StringRef Separator) const |
| void | split (SmallVectorImpl< StringRef > &A, StringRef Separator, int MaxSplit=-1, bool KeepEmpty=true) const |
| std::pair< StringRef, StringRef > | rsplit (char Separator) const |
| StringRef | ltrim (StringRef Chars=" \t\n\v\f\r") const |
| StringRef | rtrim (StringRef Chars=" \t\n\v\f\r") const |
| StringRef | trim (StringRef Chars=" \t\n\v\f\r") const |
Static Public Attributes | |
| static const size_t | npos = ~size_t(0) |
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 41 of file StringRef.h.
| typedef const char* llvm::StringRef::const_iterator |
Definition at line 44 of file StringRef.h.
| typedef const char* llvm::StringRef::iterator |
Definition at line 43 of file StringRef.h.
| typedef size_t llvm::StringRef::size_type |
Definition at line 46 of file StringRef.h.
| llvm::StringRef::StringRef | ( | ) | [inline] |
| llvm::StringRef::StringRef | ( | const char * | Str | ) | [inline] |
Construct a string ref from a cstring.
Definition at line 76 of file StringRef.h.
References llvm::LibFunc::strlen.
| llvm::StringRef::StringRef | ( | const char * | data, |
| size_t | length | ||
| ) | [inline] |
Construct a string ref from a pointer and length.
Definition at line 83 of file StringRef.h.
| llvm::StringRef::StringRef | ( | const std::string & | Str | ) | [inline] |
Construct a string ref from an std::string.
Definition at line 90 of file StringRef.h.
| char llvm::StringRef::back | ( | ) | const [inline] |
back - Get the last character in the string.
Definition at line 122 of file StringRef.h.
References empty().
Referenced by llvm::ConstantDataSequential::isCString(), and StripSpaces().
| iterator llvm::StringRef::begin | ( | ) | const [inline] |
Definition at line 97 of file StringRef.h.
Referenced by llvm::SmallString< 256 >::append(), llvm::sys::path::append(), llvm::SmallString< 256 >::assign(), llvm::MDString::begin(), llvm::APFloat::convertFromString(), llvm::ConvertUTF8toWide(), decodeUTF8(), llvm::MCObjectStreamer::EmitBytes(), llvm::TargetLoweringObjectFileELF::emitPersonalityValue(), llvm::yaml::escape(), llvm::APInt::getBitsNeeded(), llvm::TargetLoweringObjectFileCOFF::getExplicitSectionGlobal(), llvm::MemoryBuffer::getFile(), llvm::Mangler::getNameWithPrefix(), llvm::StringMap< SymbolLoc >::GetOrCreateValue(), llvm::object::MachOObjectFile::getRelocationTypeName(), llvm::object::COFFObjectFile::getRelocationTypeName(), llvm::object::ELFObjectFile< ELFT >::getRelocationTypeName(), llvm::object::COFFObjectFile::getRelocationValueString(), llvm::object::ELFObjectFile< ELFT >::getRelocationValueString(), llvm::ConstantDataArray::getString(), llvm::AsmPrinter::GetSymbolWithGlobalValueBase(), llvm::yaml::ScalarNode::getValue(), llvm::hash_value(), llvm::Timer::init(), llvm::StringPool::intern(), isAllZeros(), isValidName(), llvm::RuntimeDyldImpl::loadObject(), llvm::sys::fs::make_absolute(), llvm::sys::path::native(), llvm::SmallString< 256 >::operator+=(), llvm::object::Archive::Child::operator<(), llvm::sys::path::const_iterator::operator==(), llvm::object::Archive::Child::operator==(), llvm::opt::OptTable::OptTable(), llvm::InlineAsm::ConstraintInfo::Parse(), llvm::InlineAsm::ParseConstraints(), parseDouble(), llvm::MCSectionELF::PrintSwitchToSection(), llvm::sys::path::replace_extension(), llvm::yaml::ScalarNode::ScalarNode(), llvm::TargetLoweringObjectFileELF::SelectSectionForGlobal(), llvm::TargetLoweringObjectFileCOFF::SelectSectionForGlobal(), llvm::EngineBuilder::setMArch(), llvm::EngineBuilder::setMCPU(), llvm::Value::setName(), llvm::TimerGroup::setName(), SimplifyCondBranchToCondBranch(), llvm::Regex::sub(), WriteAttributeGroupTable(), and WriteModuleMetadataStore().
| 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 141 of file StringRef.h.
Referenced by llvm::SmallString< 256 >::compare(), llvm::operator<(), llvm::operator<=(), llvm::operator>(), llvm::operator>=(), and SortSymbolPair().
| int StringRef::compare_lower | ( | StringRef | RHS | ) | const |
compare_lower - Compare two strings, ignoring case.
compare_lower - Compare strings, ignoring case.
Definition at line 41 of file StringRef.cpp.
References ascii_tolower(), and I.
Referenced by llvm::SmallString< 256 >::compare_lower(), and equals_lower().
| int StringRef::compare_numeric | ( | StringRef | RHS | ) | const |
compare_numeric - Compare strings, handle embedded numbers.
compare_numeric - Compare two strings, treating sequences of digits as numbers.
Definition at line 55 of file StringRef.cpp.
References ascii_isdigit(), and I.
Referenced by llvm::SmallString< 256 >::compare_numeric().
| size_t llvm::StringRef::count | ( | char | C | ) | const [inline] |
Return the number of occurrences of C in the string.
Definition at line 310 of file StringRef.h.
Referenced by llvm::FileInfo::addLineCount(), llvm::SmallString< 256 >::count(), and llvm::InlineAsm::ConstraintInfo::Parse().
| size_t StringRef::count | ( | StringRef | Str | ) | const |
| 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 107 of file StringRef.h.
Referenced by llvm::FoldingSetNodeID::AddString(), llvm::StringSwitch< T, R >::Case(), llvm::object::Archive::Child::Child(), llvm::ConvertUTF8toWide(), CopyStringRef(), llvm::dumpBlock(), edit_distance(), llvm::RuntimeDyldImpl::emitCommonSymbols(), llvm::RuntimeDyldImpl::emitSection(), llvm::StringSwitch< T, R >::EndsWith(), llvm::cl::Option::error(), llvm::DWARFFormValue::extractValue(), Find(), llvm::object::Archive::Child::getBuffer(), llvm::DataExtractor::getCStr(), llvm::MCContext::GetDwarfFile(), llvm::AsmToken::getEndLoc(), llvm::getInst(), llvm::AsmToken::getLoc(), llvm::MemoryBuffer::getMemBufferCopy(), llvm::object::Archive::Child::getName(), llvm::object::Archive::Child::getNext(), llvm::opt::ArgList::GetOrMakeJoinedArgString(), llvm::object::getPtr(), llvm::MCSubtargetInfo::getSchedModelForCPU(), llvm::ConstantDataVector::getSplatValue(), llvm::ConstantDataArray::getString(), llvm::object::MachOObjectFile::getSymbolName(), llvm::DataExtractor::getU16(), llvm::DataExtractor::getU32(), llvm::DataExtractor::getU64(), llvm::DataExtractor::getU8(), llvm::sys::fs::identify_magic(), llvm::ExecutionEngine::InitializeMemory(), LLVMGetSectionContents(), LLVMGetSectionName(), LLVMGetStructName(), LLVMGetSymbolName(), llvm::RuntimeDyldImpl::loadObject(), llvm::Regex::match(), llvm::raw_ostream::operator<<(), ParseCStringVector(), llvm::opt::OptTable::ParseOneArg(), llvm::RuntimeDyldMachO::processRelocationRef(), ProvideOption(), llvm::StringRefMemoryObject::readBytes(), llvm::GCOVBuffer::readInt(), llvm::Regex::Regex(), llvm::RTDyldMemoryManager::registerEHFrames(), replaceSubString(), llvm::report_fatal_error(), llvm::RuntimeDyldImpl::resolveExternalSymbols(), RewriteIntelBracExpression(), llvm::yaml::Output::scalarString(), split(), and llvm::StringSwitch< T, R >::StartsWith().
| StringRef llvm::StringRef::drop_back | ( | size_t | N = 1 | ) | const [inline] |
Return a StringRef equal to 'this' but with the last N elements dropped.
Definition at line 400 of file StringRef.h.
References N, size(), and substr().
Referenced by llvm::ConstantDataSequential::isCString(), and rtrim().
| StringRef llvm::StringRef::drop_front | ( | size_t | N = 1 | ) | const [inline] |
| unsigned StringRef::edit_distance | ( | llvm::StringRef | Other, |
| bool | AllowReplacements = true, |
||
| unsigned | MaxEditDistance = 0 |
||
| ) |
Determine the edit distance between this string and another string.
| Other | the string to compare this string against. |
| AllowReplacements | whether to allow character replacements (change one character into another) as a single operation, rather than as two operations (an insertion and a removal). |
| MaxEditDistance | If non-zero, the maximum edit distance that this routine is allowed to compute. If the edit distance will exceed that maximum, returns MaxEditDistance+1. |
AllowReplacements is true) replacements needed to transform one of the given strings into the other. If zero, the strings are identical. Definition at line 86 of file StringRef.cpp.
References llvm::ComputeEditDistance(), data(), and size().
Referenced by LookupNearestOption().
| bool llvm::StringRef::empty | ( | ) | const [inline] |
empty - Check if the string is empty.
Definition at line 110 of file StringRef.h.
Referenced by llvm::SubtargetFeatures::AddFeature(), llvm::CompileUnit::addGlobalType(), llvm::sys::Path::appendSuffix(), back(), llvm::BlackList::BlackList(), llvm::object::Archive::Child::Child(), llvm::ConstantFoldLoadFromConstPtr(), llvm::CompileUnit::constructTypeDIE(), llvm::APFloat::convertFromString(), llvm::StructType::create(), llvm::sys::fs::create_directories(), llvm::ARM_MC::createARMMCSubtargetInfo(), llvm::DIBuilder::createBasicType(), llvm::DIBuilder::createCompileUnit(), llvm::DIBuilder::createEnumerator(), createFilePathPair(), llvm::CompileUnit::createGlobalVariableDIE(), createImportedModule(), createMipsMCSubtargetInfo(), llvm::DIBuilder::createNullPtrType(), llvm::X86_MC::createX86MCSubtargetInfo(), llvm::DISubprogram::describes(), EatNumber(), EmitGenDwarfAbbrev(), EmitGenDwarfInfo(), llvm::TargetLoweringObjectFileMachO::emitModuleFlags(), llvm::cl::Option::error(), llvm::DWARFFormValue::extractValue(), llvm::MCJIT::finalizeObject(), front(), llvm::Attribute::get(), getAsInteger(), llvm::getAsSignedInteger(), llvm::Attribute::getAsString(), llvm::getAsUnsignedInteger(), llvm::APInt::getBitsNeeded(), llvm::DOTGraphTraits< const Function * >::getCompleteNodeLabel(), getDirnameCharSep(), llvm::MCContext::GetDwarfFile(), getELFKindForNamedSection(), llvm::MCContext::getELFSection(), llvm::Module::getEndianness(), llvm::SubtargetFeatures::getFeatureBits(), getFunctionName(), llvm::TargetLibraryInfo::getLibFunc(), getMemcpyLoadsAndStores(), getMemsetStringVal(), llvm::Mangler::getNameWithPrefix(), llvm::CompileUnit::getOrCreateNameSpace(), llvm::DwarfDebug::getOrCreateSourceID(), llvm::CompileUnit::getOrCreateSubprogramDIE(), llvm::MCContext::GetOrCreateSymbol(), llvm::CompileUnit::getOrCreateTemplateValueParameterDIE(), llvm::CompileUnit::getOrCreateTypeDIE(), llvm::Triple::getOSVersion(), llvm::Module::getPointerSize(), llvm::DOTGraphTraits< const Function * >::getSimpleNodeLabel(), llvm::DataExtractor::getSLEB128(), llvm::DataExtractor::getULEB128(), 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(), hasFlag(), llvm::TypePrinting::incorporateTypes(), llvm::MCSubtargetInfo::InitMCProcessorInfo(), llvm::StringSet< AllocatorTy >::insert(), isEnabled(), isRepeatedByteSequence(), isValidName(), llvm::LoadAndStorePromoter::LoadAndStorePromoter(), LookupNearestOption(), LookupOption(), NameNeedsEscaping(), NameNeedsQuoting(), llvm::Triple::normalize(), llvm::ARM_MC::ParseARMTriple(), llvm::cl::ParseCommandLineOptions(), ParseCStringVector(), ParseMipsTriple(), llvm::MCSectionMachO::ParseSectionSpecifier(), PrependFlag(), llvm::TypePrinting::print(), llvm::MCInstPrinter::printAnnotation(), llvm::DIVariable::printExtendedName(), llvm::DIType::printInternal(), PrintLLVMName(), llvm::AssemblyWriter::printNamedMDNode(), llvm::AttributeImpl::Profile(), llvm::GCOVBuffer::readArcTag(), llvm::GCOVBuffer::readBlockTag(), llvm::GCOVBuffer::readEdgeTag(), llvm::GCOVBuffer::readFunctionTag(), llvm::GCOVBuffer::readInt(), llvm::GCOVBuffer::readLineTag(), llvm::EngineBuilder::selectTarget(), llvm::Value::setName(), llvm::StructType::setName(), Split(), split(), StripSpaces(), StripTypeNames(), llvm::Regex::sub(), llvm::MCObjectSymbolizer::tryAddingSymbolicOperand(), llvm::InlineAsm::Verify(), llvm::DICompileUnit::Verify(), WriteAttributeGroupTable(), and WriteTypeTable().
| iterator llvm::StringRef::end | ( | ) | const [inline] |
Definition at line 99 of file StringRef.h.
Referenced by llvm::SmallString< 256 >::append(), llvm::sys::path::append(), llvm::SmallString< 256 >::assign(), llvm::ConvertUTF8toWide(), decodeUTF8(), llvm::MCObjectStreamer::EmitBytes(), llvm::TargetLoweringObjectFileELF::emitPersonalityValue(), llvm::MDString::end(), endswith(), llvm::yaml::escape(), llvm::TargetLoweringObjectFileCOFF::getExplicitSectionGlobal(), llvm::MemoryBuffer::getFile(), llvm::Mangler::getNameWithPrefix(), llvm::StringMap< SymbolLoc >::GetOrCreateValue(), llvm::object::MachOObjectFile::getRelocationTypeName(), llvm::object::COFFObjectFile::getRelocationTypeName(), llvm::object::ELFObjectFile< ELFT >::getRelocationTypeName(), llvm::object::COFFObjectFile::getRelocationValueString(), llvm::object::ELFObjectFile< ELFT >::getRelocationValueString(), llvm::ConstantDataArray::getString(), llvm::AsmPrinter::GetSymbolWithGlobalValueBase(), llvm::yaml::ScalarNode::getValue(), llvm::hash_value(), llvm::Timer::init(), llvm::StringPool::intern(), isAllZeros(), isValidName(), llvm::sys::fs::make_absolute(), llvm::sys::path::native(), llvm::SmallString< 256 >::operator+=(), llvm::opt::OptTable::OptTable(), llvm::InlineAsm::ConstraintInfo::Parse(), llvm::InlineAsm::ParseConstraints(), parseDouble(), llvm::MCSectionELF::PrintSwitchToSection(), llvm::X86AsmPrinter::printSymbolOperand(), llvm::Regex::Regex(), llvm::sys::path::replace_extension(), llvm::yaml::ScalarNode::ScalarNode(), llvm::TargetLoweringObjectFileELF::SelectSectionForGlobal(), llvm::TargetLoweringObjectFileCOFF::SelectSectionForGlobal(), llvm::EngineBuilder::setMArch(), llvm::EngineBuilder::setMCPU(), llvm::Value::setName(), llvm::TimerGroup::setName(), llvm::Regex::sub(), WriteAttributeGroupTable(), and WriteModuleMetadataStore().
Check if this string ends with the given Suffix.
Definition at line 214 of file StringRef.h.
References end().
Referenced by llvm::SmallString< 256 >::endswith(), llvm::opt::ArgList::GetOrMakeJoinedArgString(), llvm::LibCallSimplifierImpl::lookupOptimization(), llvm::sys::path::const_iterator::operator++(), and llvm::UpgradeIntrinsicCall().
equals - Check for string equality, this is more efficient than compare() when the relative ordering of inequal strings isn't needed.
Definition at line 129 of file StringRef.h.
Referenced by count(), llvm::SmallString< 256 >::equals(), find(), GenerateARCAnnotation(), GenerateARCBBEntranceAnnotation(), GenerateARCBBTerminatorAnnotation(), llvm::yaml::Input::MapHNode::StrMappingInfo::isEqual(), llvm::operator==(), and rfind().
equals_lower - Check for string equality, ignoring case.
Definition at line 135 of file StringRef.h.
References compare_lower().
Referenced by llvm::SmallString< 256 >::equals_lower(), llvm::X86TargetLowering::getRegForInlineAsmConstraint(), and llvm::StrInStrNoCase().
| size_t llvm::StringRef::find | ( | char | C, |
| size_t | From = 0 |
||
| ) | const [inline] |
Search for the first character C in the string.
C, or npos if not found. Definition at line 227 of file StringRef.h.
References npos.
Referenced by llvm::X86FrameLowering::adjustForHiPEPrologue(), CommaSeparateAndAddOccurence(), llvm::SmallString< 256 >::find(), find_first_of(), llvm::getConstantStringInfo(), llvm::DataExtractor::getCStr(), llvm::TargetLibraryInfo::getLibFunc(), llvm::object::ArchiveMemberHeader::getName(), llvm::object::Archive::Child::getName(), getObjCClassCategory(), getObjCMethodName(), llvm::MCWin64EHUnwindEmitter::GetSectionSuffix(), llvm::object::ELFObjectFile< ELFT >::getSymbolVersion(), llvm::yaml::ScalarNode::getValue(), GlobalWasGeneratedByAsan(), hasObjCCategory(), llvm::ConstantDataSequential::isCString(), LookupOption(), ParseCStringVector(), ParseMipsTriple(), llvm::yaml::Output::scalarString(), Split(), and split().
| size_t StringRef::find | ( | StringRef | Str, |
| size_t | From = 0 |
||
| ) | const |
Search for the first string Str in the string.
Str, or npos if not found.find - Search for the first string
Definition at line 124 of file StringRef.cpp.
References equals(), llvm::LibFunc::memset, N, npos, size(), and substr().
| 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
Definition at line 194 of file StringRef.cpp.
References npos.
Referenced by llvm::DWARFContextInMemory::DWARFContextInMemory(), llvm::SmallString< 256 >::find_first_not_of(), llvm::getToken(), ltrim(), ParseCStringVector(), llvm::MCSectionELF::PrintSwitchToSection(), and llvm::Regex::sub().
| 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.
Complexity: O(size() + Chars.size())
find_first_not_of - Find the first character in the string that is not in the string
Note: O(size() + Chars.size())
Definition at line 205 of file StringRef.cpp.
| size_t llvm::StringRef::find_first_of | ( | char | C, |
| size_t | From = 0 |
||
| ) | const [inline] |
Find the first character in the string that is C, or npos if not found. Same as find.
Definition at line 263 of file StringRef.h.
References find().
Referenced by llvm::X86FrameLowering::adjustForHiPEPrologue(), llvm::SmallString< 256 >::find_first_of(), llvm::Mangler::getNameWithPrefix(), llvm::getToken(), llvm::yaml::ScalarNode::getValue(), and ParseCStringVector().
| 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.
Complexity: O(size() + Chars.size())
find_first_of - Find the first character in the string that is in
Note: O(size() + Chars.size())
Definition at line 180 of file StringRef.cpp.
| 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
Definition at line 235 of file StringRef.cpp.
References npos.
Referenced by rtrim().
| 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.
Complexity: O(size() + Chars.size())
find_last_not_of - Find the last character in the string that is not in
Note: O(size() + Chars.size())
Definition at line 246 of file StringRef.cpp.
| 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 285 of file StringRef.h.
References rfind().
Referenced by llvm::sys::path::extension(), llvm::SmallString< 256 >::find_last_of(), llvm::SourceMgr::getLineAndColumn(), llvm::sys::path::replace_extension(), and llvm::sys::path::stem().
| 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.
Complexity: O(size() + Chars.size())
find_last_of - Find the last character in the string that is in
Note: O(size() + Chars.size())
Definition at line 221 of file StringRef.cpp.
| char llvm::StringRef::front | ( | ) | const [inline] |
front - Get the first character in the string.
Definition at line 116 of file StringRef.h.
References empty().
Referenced by getAsInteger(), llvm::getAsSignedInteger(), and llvm::TargetLibraryInfo::getLibFunc().
| enable_if_c<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 331 of file StringRef.h.
References llvm::getAsSignedInteger().
Referenced by llvm::AMDGPUMachineFunction::AMDGPUMachineFunction(), llvm::object::Archive::Child::Child(), EmitGCCInlineAsmStr(), getInt(), llvm::object::Archive::Child::getName(), llvm::object::COFFObjectFile::getSectionName(), MatchFslRegister(), llvm::MCSectionMachO::ParseSectionSpecifier(), and llvm::Regex::sub().
| enable_if_c<!std::numeric_limits<T>::is_signed, bool>::type llvm::StringRef::getAsInteger | ( | unsigned | Radix, |
| T & | Result | ||
| ) | const [inline] |
Definition at line 342 of file StringRef.h.
References llvm::getAsUnsignedInteger().
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.
APInt::fromString is superficially similar but assumes the string is well-formed in the given radix.
Definition at line 388 of file StringRef.cpp.
References empty(), front(), GetAutoSenseRadix(), llvm::APInt::getBitWidth(), size(), substr(), and llvm::APInt::zext().
| std::string StringRef::lower | ( | ) | const |
Definition at line 99 of file StringRef.cpp.
References ascii_tolower(), and size().
Referenced by llvm::A64StringToCondCode(), llvm::SubtargetFeatures::AddFeature(), llvm::NamedImmMapper::fromString(), llvm::A64SysReg::SysRegMapper::fromString(), llvm::MipsAsmPrinter::PrintAsmOperand(), llvm::MipsAsmPrinter::printOperand(), llvm::XCoreInstPrinter::printRegName(), and llvm::MipsInstPrinter::printRegName().
Return string with consecutive characters in Chars starting from the left removed.
Definition at line 492 of file StringRef.h.
References drop_front(), and find_first_not_of().
Referenced by llvm::opt::OptTable::ParseOneArg(), and trim().
| llvm::StringRef::operator std::string | ( | ) | const [inline] |
Definition at line 199 of file StringRef.h.
References str().
| char llvm::StringRef::operator[] | ( | size_t | Index | ) | const [inline] |
Definition at line 190 of file StringRef.h.
| size_t llvm::StringRef::rfind | ( | char | C, |
| size_t | From = npos |
||
| ) | const [inline] |
Search for the last character C in the string.
C, or npos if not found. Definition at line 244 of file StringRef.h.
References npos.
Referenced by find_last_of(), llvm::SmallString< 256 >::rfind(), and rsplit().
| size_t StringRef::rfind | ( | StringRef | Str | ) | const |
Search for the last string Str in the string.
Str, or npos if not found.rfind - Search for the last string
Definition at line 164 of file StringRef.cpp.
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 == "").
| Separator | - The character to split on. |
Definition at line 483 of file StringRef.h.
References npos, rfind(), slice(), and StringRef().
Return string with consecutive characters in Chars starting from the right removed.
Definition at line 498 of file StringRef.h.
References drop_back(), and find_last_not_of().
Referenced by llvm::object::Archive::Child::Child(), llvm::object::Archive::Child::getName(), and trim().
| size_t llvm::StringRef::size | ( | ) | const [inline] |
size - Get the string size.
Definition at line 113 of file StringRef.h.
Referenced by llvm::FoldingSetNodeID::AddString(), appendMangledName(), appendMangledQuotedName(), llvm::StringSwitch< T, R >::Case(), compareBySuffix(), llvm::ConstantFoldLoadFromConstPtr(), llvm::APFloat::convertFromString(), llvm::ConvertUTF8toWide(), CopyStringRef(), count(), drop_back(), drop_front(), llvm::DWARFFormValue::dump(), edit_distance(), llvm::object::elf_hash(), llvm::emitSourceFileHeader(), llvm::sys::path::end(), llvm::StringSwitch< T, R >::EndsWith(), llvm::sys::path::extension(), find(), find_first_not_of(), find_first_of(), find_last_not_of(), find_last_of(), fixupObjcLikeName(), llvm::ConstantDataSequential::getAsCString(), getAsInteger(), llvm::APInt::getBitsNeeded(), getDirnameCharSep(), llvm::MCContext::GetDwarfFile(), llvm::AsmToken::getEndLoc(), llvm::StringRefMemoryObject::getExtent(), GetLazyPtr(), llvm::MDString::getLength(), llvm::MemoryBuffer::getMemBufferCopy(), getMemsetStringVal(), llvm::object::Archive::Child::getName(), llvm::MemoryBuffer::getNewUninitMemBuffer(), llvm::object::Archive::Child::getNext(), getOptionPred(), llvm::opt::ArgList::GetOrMakeJoinedArgString(), llvm::Triple::getOSVersion(), llvm::object::Archive::Child::getSize(), llvm::ConstantDataArray::getString(), llvm::AsmToken::getStringContents(), GetStringLengthH(), llvm::object::ELFObjectFile< ELFT >::getSymbolVersion(), getUnicodeEncoding(), llvm::yaml::ScalarNode::getValue(), HandlePrefixedOrGroupedOption(), llvm::sys::fs::has_magic(), llvm::HashString(), llvm::sys::fs::identify_magic(), llvm::ExecutionEngine::InitializeMemory(), isRepeatedByteSequence(), llvm::DataExtractor::isValidOffset(), lower(), llvm::MCGenDwarfLabelEntry::Make(), llvm::opt::DerivedArgList::MakeJoinedArg(), llvm::Regex::match(), MatchCoprocessorOperandName(), matchOption(), NameNeedsEscaping(), NameNeedsQuoting(), llvm::sys::path::native(), llvm::sys::path::const_iterator::operator++(), llvm::raw_ostream::operator<<(), llvm::ARM_MC::ParseARMTriple(), ParseCStringVector(), parseSectionFlags(), llvm::MCSectionMachO::ParseSectionSpecifier(), PrintEscapedString(), PrintHelpOptionList(), printLine(), PrintLLVMName(), llvm::AssemblyWriter::printNamedMDNode(), PrintQuotedString(), PrintRegName(), printSourceLine(), llvm::RTDyldMemoryManager::registerEHFrames(), llvm::sys::path::relative_path(), llvm::sys::path::replace_extension(), replaceSubString(), llvm::report_fatal_error(), llvm::RuntimeDyldImpl::resolveExternalSymbols(), RewriteIntelBracExpression(), rfind(), llvm::yaml::Output::scalarString(), llvm::StructType::setName(), split(), llvm::StringSwitch< T, R >::StartsWith(), llvm::sys::path::stem(), llvm::StrInStrNoCase(), StripSpaces(), llvm::Regex::sub(), UpgradeIntrinsicFunction1(), upper(), llvm::raw_ostream::write_escaped(), llvm::MCObjectWriter::WriteBytes(), WriteModuleMetadata(), and WriteStringRecord().
| StringRef llvm::StringRef::slice | ( | size_t | Start, |
| size_t | End | ||
| ) | const [inline] |
Return a reference to the substring from [Start, End).
| Start | The 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. |
| End | The index following the last character to include in the substring. If this is npos, or less than Start, or exceeds the number of characters remaining in the string, the string suffix (starting with Start) will be returned. |
Definition at line 415 of file StringRef.h.
References StringRef().
Referenced by llvm::object::ObjectFile::createMachOObjectFile(), llvm::emitSourceFileHeader(), getObjCClassCategory(), getObjCMethodName(), llvm::AsmToken::getStringContents(), llvm::getToken(), llvm::GCOVBuffer::readArcTag(), llvm::GCOVBuffer::readBlockTag(), llvm::GCOVBuffer::readEdgeTag(), llvm::GCOVBuffer::readFunctionTag(), llvm::GCOVBuffer::readGCOVFormat(), llvm::GCOVBuffer::readInt(), llvm::GCOVBuffer::readLineTag(), llvm::GCOVBuffer::readString(), rsplit(), llvm::SmallString< 256 >::slice(), split(), and llvm::Regex::sub().
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 == "").
| Separator | The character to split on. |
Definition at line 431 of file StringRef.h.
References find(), npos, slice(), and StringRef().
Referenced by llvm::Triple::getArchName(), llvm::Triple::getEnvironmentName(), llvm::Triple::getOSAndEnvironmentName(), llvm::Triple::getOSName(), llvm::Triple::getVendorName(), LookupNearestOption(), llvm::Triple::normalize(), llvm::MCSectionMachO::ParseSectionSpecifier(), llvm::FileInfo::print(), printHelpStr(), split(), split(), and llvm::Regex::sub().
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 == "").
| Separator | - The string to split on. |
Definition at line 448 of file StringRef.h.
References find(), npos, size(), slice(), and StringRef().
| 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 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
| 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 258 of file StringRef.cpp.
References data(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), size(), and split().
Check if this string starts with the given Prefix.
Definition at line 208 of file StringRef.h.
Referenced by llvm::object::Archive::Child::Child(), consumeCompressedDebugSectionHeader(), doesIgnoreDataTypeSuffix(), llvm::DWARFContextInMemory::DWARFContextInMemory(), GetAutoSenseRadix(), getELFKindForNamedSection(), llvm::getFnSpecificMDNode(), llvm::object::Archive::Child::getName(), llvm::getOrInsertFnSpecificMDNode(), llvm::opt::ArgList::GetOrMakeJoinedArgString(), llvm::Triple::getOSVersion(), getRealLinkageName(), INITIALIZE_PASS(), isInput(), llvm::Function::isIntrinsic(), isObjCClass(), llvm::objcarc::IsObjCIdentifiedObject(), llvm::MCGenDwarfLabelEntry::Make(), MatchFslRegister(), matchOption(), llvm::MCStreamer::RecordProcStart(), llvm::SmallString< 256 >::startswith(), StripDebugInfo(), StripSymtab(), StripTypeNames(), llvm::UpgradeIntrinsicCall(), and UpgradeIntrinsicFunction1().
| std::string llvm::StringRef::str | ( | ) | const [inline] |
str - Get the contents as an std::string.
Definition at line 181 of file StringRef.h.
Referenced by llvm::Record::addTemplateArg(), cacheAnnotationFromMD(), llvm::ARM_MC::createARMMCSubtargetInfo(), createMipsMCSubtargetInfo(), llvm::X86_MC::createX86MCSubtargetInfo(), llvm::Attribute::getAsString(), llvm::DOTGraphTraits< const Function * >::getGraphName(), llvm::DOTGraphTraits< const MachineFunction * >::getGraphName(), llvm::MCSectionCOFF::getLabelBeginName(), llvm::MCSectionELF::getLabelBeginName(), llvm::MCSectionCOFF::getLabelEndName(), llvm::MCSectionELF::getLabelEndName(), llvm::DOTGraphTraits< const Function * >::getSimpleNodeLabel(), llvm::Record::getValueAsBit(), llvm::Record::getValueAsBitOrUnset(), llvm::Record::getValueAsBitsInit(), llvm::Record::getValueAsDag(), llvm::Record::getValueAsDef(), llvm::Record::getValueAsInt(), llvm::Record::getValueAsListInit(), llvm::Record::getValueAsListOfDefs(), llvm::Record::getValueAsListOfInts(), llvm::Record::getValueAsListOfStrings(), llvm::Record::getValueAsString(), llvm::Record::getValueInit(), INITIALIZE_PASS(), llvm::Record::isTemplateArg(), llvm::LockFileManager::LockFileManager(), lookupFunction(), LookupNearestOption(), llvm::opt::DerivedArgList::MakeJoinedArg(), operator std::string(), llvm::cl::parser< std::string >::parse(), llvm::X86AsmPrinter::printSymbolOperand(), llvm::Record::removeValue(), llvm::DOTGraphTraitsViewer< Analysis, Simple >::runOnFunction(), llvm::DOTGraphTraitsPrinter< Analysis, Simple >::runOnFunction(), llvm::MCContext::setCompilationDir(), llvm::MCParsedAsmOperand::setConstraint(), llvm::MCContext::setMainFileName(), llvm::MCAtom::setName(), llvm::Twine::str(), llvm::Regex::sub(), llvm::UpgradeIntrinsicCall(), usedInGlobalVarDef(), llvm::LockFileManager::waitForUnlock(), and llvm::LockFileManager::~LockFileManager().
Return a reference to the substring from [Start, Start + N).
| Start | The 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. |
| N | The 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 386 of file StringRef.h.
References N, and StringRef().
Referenced by appendMangledName(), llvm::object::Archive::Child::Child(), CommaSeparateAndAddOccurence(), consumeCompressedDebugSectionHeader(), count(), drop_back(), drop_front(), llvm::DWARFContextInMemory::DWARFContextInMemory(), EatNumber(), llvm::sys::path::extension(), llvm::DWARFFormValue::extractValue(), find(), llvm::SimplifyFortifiedLibCalls::fold(), llvm::ConstantDataSequential::getAsCString(), getAsInteger(), llvm::getAsSignedInteger(), llvm::getAsUnsignedInteger(), GetAutoSenseRadix(), llvm::getConstantStringInfo(), getDirnameCharSep(), llvm::getFnSpecificMDNode(), GetLazyPtr(), llvm::TargetLibraryInfo::getLibFunc(), getMemcpyLoadsAndStores(), llvm::object::Archive::Child::getName(), llvm::Mangler::getNameWithPrefix(), getOptionPred(), llvm::getOrInsertFnSpecificMDNode(), llvm::Triple::getOSVersion(), llvm::MCJIT::getPointerToFunction(), llvm::object::getPtr(), getRealLinkageName(), llvm::object::MachOObjectFile::getSectionContents(), llvm::object::COFFObjectFile::getSectionName(), llvm::MCWin64EHUnwindEmitter::GetSectionSuffix(), llvm::object::MachOObjectFile::getStringTableData(), llvm::object::ELFObjectFile< ELFT >::getSymbolVersion(), llvm::getToken(), llvm::yaml::ScalarNode::getValue(), HandlePrefixedOrGroupedOption(), LookupOption(), llvm::MCGenDwarfLabelEntry::Make(), MatchFslRegister(), matchOption(), llvm::sys::path::parent_path(), llvm::ARM_MC::ParseARMTriple(), llvm::yaml::Document::parseBlockNode(), llvm::cl::ParseCommandLineOptions(), ParseCStringVector(), ParseMipsTriple(), llvm::sys::path::relative_path(), rfind(), llvm::sys::path::root_path(), Split(), llvm::sys::path::stem(), llvm::StrInStrNoCase(), StripFlag(), StripSpaces(), llvm::Regex::sub(), llvm::SmallString< 256 >::substr(), llvm::UpgradeIntrinsicCall(), and UpgradeIntrinsicFunction1().
Return string with consecutive characters in Chars starting from the left and right removed.
Definition at line 504 of file StringRef.h.
| std::string StringRef::upper | ( | ) | const |
Convert the given ASCII string to uppercase.
Definition at line 107 of file StringRef.cpp.
References ascii_toupper(), and size().
const size_t StringRef::npos = ~size_t(0) [static] |
Definition at line 45 of file StringRef.h.
Referenced by llvm::X86FrameLowering::adjustForHiPEPrologue(), buildFixItLine(), CommaSeparateAndAddOccurence(), llvm::TargetLoweringObjectFileCOFF::emitModuleFlags(), llvm::sys::path::extension(), find(), find_first_not_of(), find_first_of(), find_last_not_of(), find_last_of(), llvm::DataExtractor::getCStr(), llvm::TargetLibraryInfo::getLibFunc(), llvm::SourceMgr::getLineAndColumn(), llvm::object::ArchiveMemberHeader::getName(), llvm::Mangler::getNameWithPrefix(), llvm::MCWin64EHUnwindEmitter::GetSectionSuffix(), llvm::object::ELFObjectFile< ELFT >::getSymbolVersion(), llvm::yaml::ScalarNode::getValue(), llvm::ConstantDataSequential::isCString(), LookupOption(), llvm::sys::path::parent_path(), ParseCStringVector(), ParseMipsTriple(), llvm::MCSectionELF::PrintSwitchToSection(), llvm::sys::path::remove_filename(), llvm::sys::path::replace_extension(), rfind(), rsplit(), llvm::yaml::Output::scalarString(), split(), llvm::sys::path::stem(), and llvm::StrInStrNoCase().