LLVM  13.0.0git
Classes | Enumerations | Functions
llvm::sys::path Namespace Reference

Classes

class  const_iterator
 Path iterator. More...
 
class  reverse_iterator
 Reverse path iterator. More...
 

Enumerations

enum  Style { Style::windows, Style::posix, Style::native }
 

Functions

static bool starts_with (StringRef Path, StringRef Prefix, Style style=Style::native)
 

Lexical Observers

StringRef root_name (StringRef path, Style style=Style::native)
 Get root name. More...
 
StringRef root_directory (StringRef path, Style style=Style::native)
 Get root directory. More...
 
StringRef root_path (StringRef path, Style style=Style::native)
 Get root path. More...
 
StringRef relative_path (StringRef path, Style style=Style::native)
 Get relative path. More...
 
StringRef parent_path (StringRef path, Style style=Style::native)
 Get parent path. More...
 
StringRef filename (StringRef path, Style style=Style::native)
 Get filename. More...
 
StringRef stem (StringRef path, Style style=Style::native)
 Get stem. More...
 
StringRef extension (StringRef path, Style style=Style::native)
 Get extension. More...
 
bool is_separator (char value, Style style=Style::native)
 Check whether the given char is a path separator on the host OS. More...
 
StringRef get_separator (Style style=Style::native)
 Return the preferred separator for this platform. More...
 
void system_temp_directory (bool erasedOnReboot, SmallVectorImpl< char > &result)
 Get the typical temporary directory for the system, e.g., "/var/tmp" or "C:/TEMP". More...
 
bool home_directory (SmallVectorImpl< char > &result)
 Get the user's home directory. More...
 
bool user_config_directory (SmallVectorImpl< char > &result)
 Get the directory where packages should read user-specific configurations. More...
 
bool cache_directory (SmallVectorImpl< char > &result)
 Get the directory where installed packages should put their machine-local cache, e.g. More...
 
bool has_root_name (const Twine &path, Style style=Style::native)
 Has root name? More...
 
bool has_root_directory (const Twine &path, Style style=Style::native)
 Has root directory? More...
 
bool has_root_path (const Twine &path, Style style=Style::native)
 Has root path? More...
 
bool has_relative_path (const Twine &path, Style style=Style::native)
 Has relative path? More...
 
bool has_parent_path (const Twine &path, Style style=Style::native)
 Has parent path? More...
 
bool has_filename (const Twine &path, Style style=Style::native)
 Has filename? More...
 
bool has_stem (const Twine &path, Style style=Style::native)
 Has stem? More...
 
bool has_extension (const Twine &path, Style style=Style::native)
 Has extension? More...
 
bool is_absolute (const Twine &path, Style style=Style::native)
 Is path absolute? More...
 
bool is_absolute_gnu (const Twine &path, Style style=Style::native)
 Is path absolute using GNU rules? More...
 
bool is_relative (const Twine &path, Style style=Style::native)
 Is path relative? More...
 
StringRef remove_leading_dotslash (StringRef path, Style style=Style::native)
 Remove redundant leading "./" pieces and consecutive separators. More...
 
bool remove_dots (SmallVectorImpl< char > &path, bool remove_dot_dot=false, Style style=Style::native)
 In-place remove any '. More...
 

Enumeration Type Documentation

◆ Style

Enumerator
windows 
posix 
native 

Definition at line 28 of file Path.h.

Function Documentation

◆ append() [1/3]

void llvm::sys::path::append ( SmallVectorImpl< char > &  path,
const Twine a,
const Twine b = "",
const Twine c = "",
const Twine d = "" 
)

◆ append() [2/3]

void llvm::sys::path::append ( SmallVectorImpl< char > &  path,
const_iterator  begin,
const_iterator  end,
Style  style = Style::native 
)

Append to path.

/foo + [bar,f] => /foo/bar/f
/foo/ + [bar,f] => /foo/bar/f
foo + [bar,f] => foo/bar/f
Parameters
pathSet to path + [begin, end).
beginStart of components to append.
endOne past the end of components to append.

Definition at line 459 of file Path.cpp.

References append(), begin(), and end().

◆ append() [3/3]

void llvm::sys::path::append ( SmallVectorImpl< char > &  path,
Style  style,
const Twine a,
const Twine b = "",
const Twine c = "",
const Twine d = "" 
)

Definition at line 416 of file Path.cpp.

References llvm::SmallVectorImpl< T >::append(), b, c, d, has_root_name(), and is_separator().

◆ begin()

const_iterator llvm::sys::path::begin ( StringRef  path,
Style  style = Style::native 
)

Get begin iterator over path.

Parameters
pathInput path.
Returns
Iterator initialized with the first component of path.

Definition at line 224 of file Path.cpp.

References i.

Referenced by llvm::GEPOperator::accumulateConstantOffset(), llvm::DWARFUnitVector::addUnit(), llvm::adl_detail::adl_begin(), allocateVGPR32Input(), append(), llvm::MemoryDepChecker::areDepsSafe(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::assign(), llvm::detail::enumerator< R >::begin(), llvm::DICompositeType::buildODRType(), llvm::StringRef::bytes_begin(), CC_X86_64_VectorCallGetGPRs(), CC_X86_VectorCallGetSSEs(), llvm::LoopBodyTraits::child_begin(), llvm::iplist_impl< simple_ilist< MachineInstr, Options... >, ilist_traits< MachineInstr > >::clear(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::clear(), llvm::computeArchiveRelativePath(), llvm::ArrayRef< BitWord >::copy(), llvm::StringRef::copy(), llvm::OpenMPIRBuilder::createCritical(), llvm::OpenMPIRBuilder::createParallel(), llvm::DomTreeUpdater::dump(), EmitUnwindCode(), llvm::ArrayRef< BitWord >::equals(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::erase(), llvm::SetTheory::evaluate(), foldConstantInsEltIntoShuffle(), get64BitArgumentGPRs(), get64BitArgumentXMMs(), llvm::SIRegisterInfo::getAllSGPR128(), llvm::SIRegisterInfo::getAllSGPR32(), llvm::SIRegisterInfo::getAllSGPR64(), llvm::MCObjectStreamer::getCurrentFragment(), getFirstReloc(), llvm::MachineInstr::getNumDebugOperands(), llvm::iplist_impl< simple_ilist< MachineInstr, Options... >, ilist_traits< MachineInstr > >::getPrevNode(), llvm::R600RegisterInfo::getReservedRegs(), llvm::PPCRegisterInfo::getReservedRegs(), llvm::DWARFUnitVector::getUnitForIndexEntry(), llvm::DWARFUnitVector::getUnitForOffset(), llvm::codeview::LocallyHashedType::hashTypes(), llvm::hasNItems(), llvm::hasNItemsOrLess(), llvm::hasNItemsOrMore(), llvm::hasSingleElement(), llvm::TargetLoweringBase::initActions(), llvm::PriorityWorklist< llvm::LazyCallGraph::SCC *, SmallVector< llvm::LazyCallGraph::SCC *, N >, SmallDenseMap< llvm::LazyCallGraph::SCC *, ptrdiff_t > >::insert(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::insert(), llvm::iplist_impl< simple_ilist< MachineInstr, Options... >, ilist_traits< MachineInstr > >::insertAfter(), llvm::interleave(), llvm::interpretDecimal(), isF128SoftLibCall(), isIntrinsicInline(), llvm::HexagonMCInstrInfo::isOrderedDuplexPair(), LLVMGetFirstTarget(), lookupFoldTableImpl(), llvm::vfs::lookupInMemoryNode(), llvm::TargetRegistry::lookupTarget(), lowerV8I16GeneralSingleInputShuffle(), llvm::MachineTraceMetrics::MachineTraceMetrics(), llvm::make_early_inc_range(), llvm::make_filter_range(), llvm::make_first_range(), llvm::make_pointee_range(), llvm::make_pointer_range(), llvm::make_second_range(), llvm::makeArrayRef(), AbstractManglingParser< ManglingParser< Alloc >, Alloc >::makeNodeArray(), llvm::simple_ilist< IRInstructionData >::merge(), llvm::SmallVectorTemplateBase< T, bool >::moveElementsForGrow(), llvm::GraphTraits< MachineRegionInfo * >::nodes_begin(), llvm::GraphTraits< RegionInfo * >::nodes_begin(), llvm::GraphTraits< VPRegionBlock * >::nodes_begin(), llvm::GraphTraits< const VPRegionBlock * >::nodes_begin(), llvm::GraphTraits< Inverse< VPRegionBlock * > >::nodes_begin(), llvm::CallBase::operandBundleFromBundleOpInfo(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::operator<(), llvm::TargetLibraryInfoImpl::operator=(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::operator=(), llvm::FeatureBitset::operator==(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::operator==(), llvm::parallelForEach(), llvm::parallelForEachError(), llvm::parallelSort(), llvm::parallelTransformReduce(), llvm::vfs::RedirectingFileSystemParser::parse(), llvm::MCSectionMachO::ParseSectionSpecifier(), llvm::RegisterBankInfo::ValueMapping::partsAllUniform(), pathHasTraversal(), llvm::iplist_impl< simple_ilist< MachineInstr, Options... >, ilist_traits< MachineInstr > >::pop_front(), llvm::DominanceFrontierBase< BasicBlock, false >::print(), llvm::LoopBase< BasicBlock, Loop >::print(), llvm::DWARFExpression::printCompact(), llvm::iplist_impl< simple_ilist< MachineInstr, Options... >, ilist_traits< MachineInstr > >::push_front(), llvm::readExponent(), llvm::DominanceFrontierBase< BasicBlock, false >::removeBlock(), llvm::LoopInfoBase< BasicBlock, Loop >::removeLoop(), llvm::RegionBase< RegionTraits< Function > >::removeSubRegion(), llvm::ArrayRef< BitWord >::rend(), llvm::MutableArrayRef< BitWord >::rend(), llvm::Thumb1FrameLowering::restoreCalleeSavedRegisters(), llvm::reverse(), root_directory(), root_name(), root_path(), llvm::object::COFFObjectFile::section_rel_begin(), llvm::FeatureBitset::set(), llvm::skipLeadingZeroesAndAnyDot(), llvm::simple_ilist< IRInstructionData >::sort(), llvm::Thumb1FrameLowering::spillCalleeSavedRegisters(), llvm::HexagonBlockRanges::RangeList::subtract(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::swap(), llvm::ArrayRef< BitWord >::take_until(), llvm::MutableArrayRef< BitWord >::take_until(), llvm::ArrayRef< BitWord >::take_while(), llvm::MutableArrayRef< BitWord >::take_while(), llvm::SmallVectorTemplateBase< T, bool >::takeAllocationForGrow(), llvm::TargetLibraryInfoImpl::TargetLibraryInfoImpl(), llvm::TargetLoweringBase::TargetLoweringBase(), llvm::to_vector(), llvm::HexagonBlockRanges::RangeList::unionize(), llvm::UnrollAndJamLoop(), llvm::MemorySSAUpdater::updateExitBlocksForClonedLoop(), llvm::X86::updateImpliedFeatures(), llvm::Hexagon::ValidArch(), llvm::TargetLoweringBase::ValueTypeActionImpl::ValueTypeActionImpl(), llvm::LoopInfoBase< BasicBlock, Loop >::verify(), llvm::verifyIntrinsicTables(), llvm::LoopBase< BasicBlock, Loop >::verifyLoop(), llvm::LoopBase< BasicBlock, Loop >::verifyLoopNest(), llvm::InstCombinerImpl::visitStoreInst(), llvm::SmallVector< llvm::cl::parser::OptionInfo, 8 >::~SmallVector(), and llvm::SmallVectorImpl< llvm::VectorizationFactor >::~SmallVectorImpl().

◆ cache_directory()

bool llvm::sys::path::cache_directory ( SmallVectorImpl< char > &  result)

Get the directory where installed packages should put their machine-local cache, e.g.

$XDG_CACHE_HOME.

Parameters
resultHolds the resulting path name.
Returns
True if the appropriate path was determined, it need not exist.

◆ convert_to_slash()

std::string llvm::sys::path::convert_to_slash ( StringRef  path,
Style  style = Style::native 
)

Replaces backslashes with slashes if Windows.

Parameters
pathprocessed path
Returns
The result of replacing backslashes with forward slashes if Windows. On Unix, this function is a no-op because backslashes are valid path chracters.

Definition at line 566 of file Path.cpp.

References replace(), s, and llvm::StringRef::str().

Referenced by llvm::TarWriter::append(), and llvm::computeArchiveRelativePath().

◆ end()

const_iterator llvm::sys::path::end ( StringRef  path)

Get end iterator over path.

Parameters
pathInput path.
Returns
Iterator initialized to the end of path.

Definition at line 233 of file Path.cpp.

References i, and llvm::StringRef::size().

Referenced by llvm::GEPOperator::accumulateConstantOffset(), llvm::DominanceFrontierBase< BasicBlock, false >::addToFrontier(), llvm::DWARFUnitVector::addUnit(), llvm::adl_detail::adl_end(), llvm::SmallString< 256 >::append(), append(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::append(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::assign(), llvm::object::Elf_GnuHash_Impl< ELFT >::buckets(), llvm::DICompositeType::buildODRType(), llvm::StringRef::bytes_end(), canBeFeederToNewValueJump(), canCompareBeNewValueJump(), CC_X86_64_VectorCallGetGPRs(), CC_X86_VectorCallGetSSEs(), llvm::LiveIntervals::checkRegMaskInterference(), checkThreadCommand(), llvm::LoopBodyTraits::child_end(), llvm::iplist_impl< simple_ilist< MachineInstr, Options... >, ilist_traits< MachineInstr > >::clear(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::clear(), llvm::DominanceFrontierBase< BasicBlock, false >::compare(), llvm::computeArchiveRelativePath(), llvm::HexagonBlockRanges::IndexRange::contains(), llvm::ArrayRef< BitWord >::copy(), llvm::StringRef::copy(), llvm::OpenMPIRBuilder::createCritical(), llvm::OpenMPIRBuilder::createParallel(), llvm::decodeSLEB128(), llvm::decodeULEB128(), dominatesAllUsesOf(), llvm::ArrayRef< BitWord >::drop_until(), llvm::MutableArrayRef< BitWord >::drop_until(), llvm::ArrayRef< BitWord >::drop_while(), llvm::MutableArrayRef< BitWord >::drop_while(), llvm::DomTreeUpdater::dump(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::emplace_back(), llvm::detail::enumerator< R >::end(), llvm::StringRef::endswith(), llvm::ArrayRef< BitWord >::equals(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::erase(), llvm::SetTheory::evaluate(), llvm::UnwindOpcodeAssembler::Finalize(), llvm::findAllNVVMAnnotation(), llvm::findOneNVVMAnnotation(), format_to_buffer(), get64BitArgumentGPRs(), get64BitArgumentXMMs(), getAllocationDataForFunction(), llvm::X86::getFeaturesForCPU(), llvm::getIntrinsicWithChain(), llvm::getIntrinsicWithoutChain(), llvm::AVRMCExpr::getKindByName(), llvm::AVRMCExpr::getName(), llvm::iplist_impl< simple_ilist< MachineInstr, Options... >, ilist_traits< MachineInstr > >::getNextNode(), llvm::MachineInstr::getNumDebugOperands(), llvm::AllocationOrder::getOrderLimitEnd(), llvm::object::ArchiveMemberHeader::getRawName(), llvm::R600RegisterInfo::getReservedRegs(), llvm::PPCRegisterInfo::getReservedRegs(), llvm::DWARFUnitVector::getUnitForIndexEntry(), llvm::DWARFUnitVector::getUnitForOffset(), llvm::hashing::detail::hash_combine_range_impl(), llvm::codeview::LocallyHashedType::hashTypes(), llvm::hasNItems(), llvm::hasNItemsOrLess(), llvm::hasNItemsOrMore(), llvm::hasSingleElement(), llvm::MachineInstr::implicit_operands(), llvm::TargetLoweringBase::initActions(), llvm::PriorityWorklist< llvm::LazyCallGraph::SCC *, SmallVector< llvm::LazyCallGraph::SCC *, N >, SmallDenseMap< llvm::LazyCallGraph::SCC *, ptrdiff_t > >::insert(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::insert(), llvm::interleave(), llvm::interpretDecimal(), isF128SoftLibCall(), isIntrinsicInline(), llvm::HexagonMCInstrInfo::isOrderedDuplexPair(), llvm::SplitAnalysis::isOriginalEndpoint(), LLVMGetFirstTarget(), lookupFoldTableImpl(), llvm::vfs::lookupInMemoryNode(), LookupNEONLdSt(), llvm::TargetRegistry::lookupTarget(), llvm::MachineTraceMetrics::MachineTraceMetrics(), llvm::make_early_inc_range(), llvm::make_filter_range(), llvm::make_pointee_range(), llvm::make_pointer_range(), llvm::makeArrayRef(), AbstractManglingParser< ManglingParser< Alloc >, Alloc >::makeNodeArray(), llvm::HexagonBlockRanges::IndexRange::merge(), llvm::simple_ilist< IRInstructionData >::merge(), llvm::SmallVectorTemplateBase< T, bool >::moveElementsForGrow(), llvm::GraphTraits< MachineRegionInfo * >::nodes_end(), llvm::GraphTraits< RegionInfo * >::nodes_end(), llvm::GraphTraits< VPRegionBlock * >::nodes_end(), llvm::GraphTraits< const VPRegionBlock * >::nodes_end(), llvm::GraphTraits< Inverse< VPRegionBlock * > >::nodes_end(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::operator<(), llvm::TargetLibraryInfoImpl::operator=(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::operator=(), llvm::FeatureBitset::operator==(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::operator==(), llvm::parallelForEach(), llvm::parallelForEachError(), llvm::parallelSort(), llvm::parallelTransformReduce(), llvm::vfs::RedirectingFileSystemParser::parse(), llvm::ELFAttributeParser::parseAttributeList(), llvm::MCSectionMachO::ParseSectionSpecifier(), llvm::ELFAttributeParser::parseSubsection(), llvm::RegisterBankInfo::ValueMapping::partsAllUniform(), pathHasTraversal(), llvm::iplist_impl< simple_ilist< MachineInstr, Options... >, ilist_traits< MachineInstr > >::pop_back(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::pop_back_n(), llvm::DominanceFrontierBase< BasicBlock, false >::print(), llvm::LoopBase< BasicBlock, Loop >::print(), llvm::DWARFExpression::printCompact(), llvm::iplist_impl< simple_ilist< MachineInstr, Options... >, ilist_traits< MachineInstr > >::push_back(), llvm::ArrayRef< BitWord >::rbegin(), llvm::MutableArrayRef< BitWord >::rbegin(), llvm::readExponent(), llvm::DominanceFrontierBase< BasicBlock, false >::removeBlock(), llvm::DominanceFrontierBase< BasicBlock, false >::removeFromFrontier(), llvm::LoopInfoBase< BasicBlock, Loop >::removeLoop(), llvm::Thumb1FrameLowering::restoreCalleeSavedRegisters(), llvm::reverse(), root_directory(), root_name(), root_path(), llvm::EngineBuilder::selectTarget(), llvm::FeatureBitset::set(), llvm::skipLeadingZeroesAndAnyDot(), llvm::simple_ilist< IRInstructionData >::sort(), llvm::Thumb1FrameLowering::spillCalleeSavedRegisters(), llvm::Regex::sub(), llvm::HexagonBlockRanges::RangeList::subtract(), llvm::SmallVectorImpl< llvm::VectorizationFactor >::swap(), llvm::TargetLibraryInfoImpl::TargetLibraryInfoImpl(), llvm::TargetLoweringBase::TargetLoweringBase(), llvm::to_vector(), llvm::APInt::toString(), llvm::totalExponent(), llvm::trailingHexadecimalFraction(), llvm::HexagonBlockRanges::RangeList::unionize(), llvm::MemorySSAUpdater::updateExitBlocksForClonedLoop(), llvm::X86::updateImpliedFeatures(), llvm::Hexagon::ValidArch(), llvm::object::Elf_GnuHash_Impl< ELFT >::values(), llvm::TargetLoweringBase::ValueTypeActionImpl::ValueTypeActionImpl(), llvm::LoopInfoBase< BasicBlock, Loop >::verify(), llvm::verifyIntrinsicTables(), llvm::LoopBase< BasicBlock, Loop >::verifyLoop(), llvm::LoopBase< BasicBlock, Loop >::verifyLoopNest(), write_unsigned_impl(), and llvm::SmallVector< llvm::cl::parser::OptionInfo, 8 >::~SmallVector().

◆ extension()

StringRef llvm::sys::path::extension ( StringRef  path,
Style  style = Style::native 
)

Get extension.

If filename contains a dot but not solely one or two dots, result is the substring of filename starting at (and including) the last dot, and ending at the end of path. Otherwise "".

/foo/bar.txt => .txt
/foo/bar => <empty>
/foo/.txt => .txt
Parameters
pathInput path.
Returns
The extension of path.

Definition at line 588 of file Path.cpp.

References filename(), llvm::StringRef::find_last_of(), llvm::StringRef::npos, llvm::StringRef::size(), and llvm::StringRef::substr().

Referenced by llvm::DWARFContext::dump(), llvm::pdb::PDBSymbolCompiland::getSourceFileFullPath(), has_extension(), and replace_extension().

◆ filename()

StringRef llvm::sys::path::filename ( StringRef  path,
Style  style = Style::native 
)

◆ get_separator()

StringRef llvm::sys::path::get_separator ( Style  style = Style::native)

Return the preferred separator for this platform.

Returns
StringRef of the preferred separator, null-terminated.

Definition at line 607 of file Path.cpp.

Referenced by llvm::SourceMgr::AddIncludeFile(), and llvm::vfs::RedirectingFileSystem::makeAbsolute().

◆ has_extension()

bool llvm::sys::path::has_extension ( const Twine path,
Style  style = Style::native 
)

Has extension?

extension != ""

Parameters
pathInput path.
Returns
True if the path has a extension, false otherwise.

Definition at line 662 of file Path.cpp.

References llvm::StringRef::empty(), extension(), p, and llvm::Twine::toStringRef().

◆ has_filename()

bool llvm::sys::path::has_filename ( const Twine path,
Style  style = Style::native 
)

Has filename?

filename != ""

Parameters
pathInput path.
Returns
True if the path has a filename, false otherwise.

Definition at line 641 of file Path.cpp.

References llvm::StringRef::empty(), filename(), p, and llvm::Twine::toStringRef().

◆ has_parent_path()

bool llvm::sys::path::has_parent_path ( const Twine path,
Style  style = Style::native 
)

Has parent path?

parent_path != ""

Parameters
pathInput path.
Returns
True if the path has a parent path, false otherwise.

Definition at line 648 of file Path.cpp.

References llvm::StringRef::empty(), p, parent_path(), and llvm::Twine::toStringRef().

◆ has_relative_path()

bool llvm::sys::path::has_relative_path ( const Twine path,
Style  style = Style::native 
)

Has relative path?

relative_path != ""

Parameters
pathInput path.
Returns
True if the path has a relative path, false otherwise.

Definition at line 634 of file Path.cpp.

References llvm::StringRef::empty(), p, relative_path(), and llvm::Twine::toStringRef().

◆ has_root_directory()

bool llvm::sys::path::has_root_directory ( const Twine path,
Style  style = Style::native 
)

Has root directory?

root_directory != ""

Parameters
pathInput path.
Returns
True if the path has a root directory, false otherwise.

Definition at line 620 of file Path.cpp.

References llvm::StringRef::empty(), p, root_directory(), and llvm::Twine::toStringRef().

Referenced by is_absolute(), and llvm::sys::fs::make_absolute().

◆ has_root_name()

bool llvm::sys::path::has_root_name ( const Twine path,
Style  style = Style::native 
)

Has root name?

root_name != ""

Parameters
pathInput path.
Returns
True if the path has a root name, false otherwise.

Definition at line 613 of file Path.cpp.

References llvm::StringRef::empty(), p, root_name(), and llvm::Twine::toStringRef().

Referenced by append(), is_absolute(), and llvm::sys::fs::make_absolute().

◆ has_root_path()

bool llvm::sys::path::has_root_path ( const Twine path,
Style  style = Style::native 
)

Has root path?

root_path != ""

Parameters
pathInput path.
Returns
True if the path has a root path, false otherwise.

Definition at line 627 of file Path.cpp.

References llvm::StringRef::empty(), p, root_path(), and llvm::Twine::toStringRef().

◆ has_stem()

bool llvm::sys::path::has_stem ( const Twine path,
Style  style = Style::native 
)

Has stem?

stem != ""

Parameters
pathInput path.
Returns
True if the path has a stem, false otherwise.

Definition at line 655 of file Path.cpp.

References llvm::StringRef::empty(), p, stem(), and llvm::Twine::toStringRef().

◆ home_directory()

bool llvm::sys::path::home_directory ( SmallVectorImpl< char > &  result)

Get the user's home directory.

Parameters
resultHolds the resulting path name.
Returns
True if a home directory is set, false otherwise.

Referenced by llvm::LineEditor::getDefaultHistoryPath(), and native().

◆ is_absolute()

bool llvm::sys::path::is_absolute ( const Twine path,
Style  style = Style::native 
)

Is path absolute?

According to cppreference.com, C++17 states: "An absolute path is a path that unambiguously identifies the location of a file without reference to an additional starting location."

In other words, the rules are: 1) POSIX style paths with nonempty root directory are absolute. 2) Windows style paths with nonempty root name and root directory are absolute. 3) No other paths are absolute.

See also
has_root_name
has_root_directory
Parameters
pathInput path.
Returns
True if the path is absolute, false if it is not.

Definition at line 669 of file Path.cpp.

References has_root_directory(), has_root_name(), p, and llvm::Twine::toStringRef().

Referenced by llvm::sys::fs::createUniquePath(), ExpandResponseFile(), llvm::sys::Process::FindInEnvPath(), llvm::DiagnosticLocation::getAbsolutePath(), llvm::object::Archive::Child::getFullName(), llvm::pdb::PDBSymbolCompiland::getSourceFileFullPath(), is_relative(), isPathAbsoluteOnWindowsOrPosix(), llvm::sys::fs::make_absolute(), llvm::vfs::FileSystem::makeAbsolute(), llvm::vfs::RedirectingFileSystem::makeAbsolute(), and printDwarfFileDirective().

◆ is_absolute_gnu()

bool llvm::sys::path::is_absolute_gnu ( const Twine path,
Style  style = Style::native 
)

Is path absolute using GNU rules?

GNU rules are: 1) Paths starting with a path separator are absolute. 2) Windows style paths are also absolute if they start with a character followed by ':'. 3) No other paths are absolute.

On Windows style the path "C:\Users\Default" has "C:" as root name and "\" as root directory.

Hence "C:" on Windows is absolute under GNU rules and not absolute under C++17 because it has no root directory. Likewise "/" and "\" on Windows are absolute under GNU and are not absolute under C++17 due to empty root name.

See also
has_root_name
has_root_directory
Parameters
pathInput path.
styleThe style of path (e.g. Windows or POSIX). "native" style means to derive the style from the host.
Returns
True if the path is absolute following GNU rules, false if it is not.

Definition at line 680 of file Path.cpp.

References is_separator(), p, and llvm::Twine::toStringRef().

◆ is_relative()

bool llvm::sys::path::is_relative ( const Twine path,
Style  style = Style::native 
)

Is path relative?

Parameters
pathInput path.
Returns
True if the path is relative, false if it is not.

Definition at line 698 of file Path.cpp.

References is_absolute().

Referenced by ExpandResponseFile(), and llvm::cl::readConfigFile().

◆ is_separator()

bool llvm::sys::path::is_separator ( char  value,
Style  style = Style::native 
)

Check whether the given char is a path separator on the host OS.

Parameters
valuea character
Returns
true if value is a path separator character on the host OS

Definition at line 599 of file Path.cpp.

Referenced by append(), llvm::orc::DumpObjects::DumpObjects(), is_absolute_gnu(), native(), llvm::sys::path::const_iterator::operator++(), llvm::sys::path::reverse_iterator::operator++(), remove_leading_dotslash(), root_directory(), root_name(), root_path(), llvm::MCContext::setGenDwarfRootFile(), starts_with(), and llvm::stripDirPrefix().

◆ native() [1/2]

void llvm::sys::path::native ( const Twine path,
SmallVectorImpl< char > &  result,
Style  style = Style::native 
)

Convert path to the native form.

This is used to give paths to users and operating system calls in the platform's normal way. For example, on Windows all '/' are converted to '\'.

Parameters
pathA path that is transformed to native format.
resultHolds the result of the transformation.

Definition at line 538 of file Path.cpp.

References assert(), llvm::StringRef::data(), llvm::Twine::getSingleStringRef(), llvm::Twine::isSingleStringRef(), result, and llvm::Twine::toVector().

Referenced by llvm::pdb::PDBFileBuilder::addInjectedSource(), llvm::unittest::getInputFileDirectory(), makeAbsolute(), llvm::unittest::TempDir::path(), and llvm::pruneCache().

◆ native() [2/2]

void llvm::sys::path::native ( SmallVectorImpl< char > &  path,
Style  style = Style::native 
)

Convert path to the native form in place.

This is used to give paths to users and operating system calls in the platform's normal way. For example, on Windows all '/' are converted to '\'.

Parameters
pathA path that is transformed to native format.

Definition at line 548 of file Path.cpp.

References llvm::SmallString< InternalLen >::append(), home_directory(), is_separator(), and replace().

◆ parent_path()

StringRef llvm::sys::path::parent_path ( StringRef  path,
Style  style = Style::native 
)

◆ rbegin()

reverse_iterator llvm::sys::path::rbegin ( StringRef  path,
Style  style = Style::native 
)

Get reverse begin iterator over path.

Parameters
pathInput path.
Returns
Iterator initialized with the first reverse component of path.

Definition at line 295 of file Path.cpp.

References I, and llvm::StringRef::size().

Referenced by filename().

◆ relative_path()

StringRef llvm::sys::path::relative_path ( StringRef  path,
Style  style = Style::native 
)

Get relative path.

C:\hello\world => hello\world
Parameters
pathInput path.
Returns
The path starting after root_path if one exists, otherwise "".

Definition at line 411 of file Path.cpp.

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

Referenced by llvm::FileCollector::addFileImpl(), has_relative_path(), and llvm::sys::fs::make_absolute().

◆ remove_dots()

bool llvm::sys::path::remove_dots ( SmallVectorImpl< char > &  path,
bool  remove_dot_dot = false,
Style  style = Style::native 
)

In-place remove any '.

/' and optionally '../' components from a path.

Parameters
pathprocessed path
remove_dot_dotspecify if '../' (except for leading "../") should be removed
Returns
True if path was changed

Definition at line 714 of file Path.cpp.

References llvm::StringRef::drop_front(), llvm::StringRef::empty(), llvm::StringRef::find_first_of(), llvm::StringRef::front(), llvm::makeArrayRef(), llvm::StringRef::npos, root_path(), llvm::StringRef::size(), llvm::SmallVectorImpl< T >::swap(), and llvm::StringRef::take_front().

Referenced by llvm::FileCollector::PathCanonicalizer::canonicalize(), llvm::vfs::InMemoryFileSystem::getRealPath(), llvm::vfs::lookupInMemoryNode(), and llvm::vfs::InMemoryFileSystem::setCurrentWorkingDirectory().

◆ remove_filename()

void llvm::sys::path::remove_filename ( SmallVectorImpl< char > &  path,
Style  style = Style::native 
)

Remove the last component from path unless it is the root dir.

Similar to the POSIX "dirname" utility.

directory/filename.cpp => directory/
directory/ => directory
filename.cpp => <empty>
/ => /
Parameters
pathA path that is modified to not have a file component.

Definition at line 472 of file Path.cpp.

References llvm::StringRef::npos.

Referenced by llvm::pdb::NativeSession::searchForPdb(), and llvm::MCContext::setGenDwarfRootFile().

◆ remove_leading_dotslash()

StringRef llvm::sys::path::remove_leading_dotslash ( StringRef  path,
Style  style = Style::native 
)

Remove redundant leading "./" pieces and consecutive separators.

Parameters
pathInput path.
Returns
The cleaned-up path.

Definition at line 702 of file Path.cpp.

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

Referenced by llvm::DiagnosticLocation::getAbsolutePath(), and makeAbsolute().

◆ rend()

reverse_iterator llvm::sys::path::rend ( StringRef  path)

Get reverse end iterator over path.

Parameters
pathInput path.
Returns
Iterator initialized to the reverse end of path.

Definition at line 304 of file Path.cpp.

References I, and llvm::StringRef::substr().

◆ replace_extension()

void llvm::sys::path::replace_extension ( SmallVectorImpl< char > &  path,
const Twine extension,
Style  style = Style::native 
)

Replace the file extension of path with extension.

./filename.cpp => ./filename.extension
./filename => ./filename.extension
./ => ./.extension
Parameters
pathA path that has its extension replaced with extension.
extensionThe extension to be added. It may be empty. It may also optionally start with a '.', if it does not, one will be prepended.

Definition at line 478 of file Path.cpp.

References llvm::SmallVectorImpl< T >::append(), llvm::StringRef::begin(), llvm::StringRef::end(), extension(), llvm::StringRef::npos, p, and llvm::StringRef::size().

Referenced by getDefaultOutputPath().

◆ replace_path_prefix()

bool llvm::sys::path::replace_path_prefix ( SmallVectorImpl< char > &  Path,
StringRef  OldPrefix,
StringRef  NewPrefix,
Style  style = Style::native 
)

Replace matching path prefix with another path.

/foo, /old, /new => /foo
/old, /old, /new => /new
/old, /old/, /new => /old
/old/foo, /old, /new => /new/foo
/old/foo, /old/, /new => /new/foo
/old/foo, /old/, /new/ => /new/foo
/oldfoo, /old, /new => /oldfoo
/foo, <empty>, /new => /new/foo
/foo, <empty>, new => new/foo
/old/foo, /old, <empty> => /foo
Parameters
PathIf Path starts with OldPrefix modify to instead start with NewPrefix.
OldPrefixThe path prefix to strip from Path.
NewPrefixThe path prefix to replace NewPrefix with.
styleThe style used to match the prefix. Exact match using Posix style, case/separator insensitive match for Windows style.
Returns
true if Path begins with OldPrefix

Definition at line 516 of file Path.cpp.

References llvm::copy(), llvm::StringRef::empty(), llvm::StringRef::size(), starts_with(), llvm::StringRef::substr(), and llvm::SmallVectorImpl< T >::swap().

Referenced by llvm::lto::getThinLTOOutputFile().

◆ root_directory()

StringRef llvm::sys::path::root_directory ( StringRef  path,
Style  style = Style::native 
)

Get root directory.

/goo/hello => /
c:/hello => /
d/file.txt => <empty>
Parameters
pathInput path.
Returns
The root directory of path if it has one, otherwise "".

Definition at line 388 of file Path.cpp.

References b, begin(), llvm::numbers::e, end(), and is_separator().

Referenced by has_root_directory(), and llvm::sys::fs::make_absolute().

◆ root_name()

StringRef llvm::sys::path::root_name ( StringRef  path,
Style  style = Style::native 
)

Get root name.

//net/hello => //net
c:/hello => c: (on Windows, on other platforms nothing)
/hello => <empty>
Parameters
pathInput path.
Returns
The root name of path if it has one, otherwise "".

Definition at line 371 of file Path.cpp.

References b, begin(), llvm::numbers::e, end(), and is_separator().

Referenced by llvm::computeArchiveRelativePath(), has_root_name(), and llvm::sys::fs::make_absolute().

◆ root_path()

StringRef llvm::sys::path::root_path ( StringRef  path,
Style  style = Style::native 
)

Get root path.

Equivalent to root_name + root_directory.

Parameters
pathInput path.
Returns
The root path of path if it has one, otherwise "".

Definition at line 346 of file Path.cpp.

References b, begin(), llvm::numbers::e, end(), is_separator(), and llvm::StringRef::substr().

Referenced by has_root_path(), relative_path(), and remove_dots().

◆ starts_with()

static bool llvm::sys::path::starts_with ( StringRef  Path,
StringRef  Prefix,
Style  style = Style::native 
)
static

◆ stem()

StringRef llvm::sys::path::stem ( StringRef  path,
Style  style = Style::native 
)

Get stem.

If filename contains a dot but not solely one or two dots, result is the substring of filename ending at (but not including) the last dot. Otherwise it is filename.

/foo/bar.txt => bar
/foo/bar => bar
/foo/.txt => <empty>
/foo/. => .
/foo/.. => ..
Parameters
pathInput path.
Returns
The stem of path.

Definition at line 577 of file Path.cpp.

References filename(), llvm::StringRef::find_last_of(), llvm::StringRef::npos, llvm::StringRef::size(), and llvm::StringRef::substr().

Referenced by has_stem().

◆ system_temp_directory()

void llvm::sys::path::system_temp_directory ( bool  erasedOnReboot,
SmallVectorImpl< char > &  result 
)

Get the typical temporary directory for the system, e.g., "/var/tmp" or "C:/TEMP".

Parameters
erasedOnRebootWhether to favor a path that is erased on reboot rather than one that potentially persists longer. This parameter will be ignored if the user or system has set the typical environment variable (e.g., TEMP on Windows, TMPDIR on *nix) to specify a temporary directory.
resultHolds the resulting path name.

Referenced by llvm::sys::fs::createUniquePath().

◆ user_config_directory()

bool llvm::sys::path::user_config_directory ( SmallVectorImpl< char > &  result)

Get the directory where packages should read user-specific configurations.

e.g. $XDG_CONFIG_HOME.

Parameters
resultHolds the resulting path name.
Returns
True if the appropriate path was determined, it need not exist.
llvm::lltok::bar
@ bar
Definition: LLToken.h:37
f
Itanium Name Demangler i e convert the string _Z1fv into f()". You can also use the CRTP base ManglingParser to perform some simple analysis on the mangled name
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
old
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM ID Predecessors according to mbb< bb27, 0x8b0a7c0 > Note ADDri is not a two address instruction its result reg1037 is an operand of the PHI node in bb76 and its operand reg1039 is the result of the PHI node We should treat it as a two address code and make sure the ADDri is scheduled after any node that reads reg1039 Use info(i.e. register scavenger) to assign it a free register to allow reuse the collector could move the objects and invalidate the derived pointer This is bad enough in the first but safe points can crop up unpredictably **array_addr i32 n old
Definition: README.txt:123
c
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only and the condition codes are not remembered when the same two values are compared twice More LSR enhancements i8 and i32 load store addressing modes are identical int int c
Definition: README.txt:418
foo
< i32 > tmp foo
Definition: README.txt:383
file
dot regions Print regions of function to dot file(with no function bodies)"
llvm::empty
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
Definition: STLExtras.h:263
llvm::sys::path::filename
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
Definition: Path.cpp:575
d
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only and the condition codes are not remembered when the same two values are compared twice More LSR enhancements i8 and i32 load store addressing modes are identical int int int d
Definition: README.txt:418