LLVM  3.7.0
Classes | Functions | Variables
llvm::sys::path Namespace Reference

Classes

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

Functions

std::error_code widenPath (const Twine &Path8, SmallVectorImpl< wchar_t > &Path16)
 
Lexical Component Iterator
const_iterator begin (StringRef path)
 Get begin iterator over path. More...
 
const_iterator end (StringRef path)
 Get end iterator over path. More...
 
reverse_iterator rbegin (StringRef path)
 Get reverse begin iterator over path. More...
 
reverse_iterator rend (StringRef path)
 Get reverse end iterator over path. More...
 
Lexical Modifiers
void remove_filename (SmallVectorImpl< char > &path)
 Remove the last component from path unless it is the root dir. More...
 
void replace_extension (SmallVectorImpl< char > &path, const Twine &extension)
 Replace the file extension of path with extension. More...
 
void append (SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
 Append to path. More...
 
void append (SmallVectorImpl< char > &path, const_iterator begin, const_iterator end)
 Append to path. More...
 
Transforms (or some other better name)
void native (const Twine &path, SmallVectorImpl< char > &result)
 Convert path to the native form. More...
 
void native (SmallVectorImpl< char > &path)
 Convert path to the native form in place. More...
 
Lexical Observers
StringRef root_name (StringRef path)
 Get root name. More...
 
StringRef root_directory (StringRef path)
 Get root directory. More...
 
StringRef root_path (StringRef path)
 Get root path. More...
 
StringRef relative_path (StringRef path)
 Get relative path. More...
 
StringRef parent_path (StringRef path)
 Get parent path. More...
 
StringRef filename (StringRef path)
 Get filename. More...
 
StringRef stem (StringRef path)
 Get stem. More...
 
StringRef extension (StringRef path)
 Get extension. More...
 
bool is_separator (char value)
 Check whether the given char is a path separator on the host OS. More...
 
StringRef get_separator ()
 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 has_root_name (const Twine &path)
 Has root name? More...
 
bool has_root_directory (const Twine &path)
 Has root directory? More...
 
bool has_root_path (const Twine &path)
 Has root path? More...
 
bool has_relative_path (const Twine &path)
 Has relative path? More...
 
bool has_parent_path (const Twine &path)
 Has parent path? More...
 
bool has_filename (const Twine &path)
 Has filename? More...
 
bool has_stem (const Twine &path)
 Has stem? More...
 
bool has_extension (const Twine &path)
 Has extension? More...
 
bool is_absolute (const Twine &path)
 Is path absolute? More...
 
bool is_relative (const Twine &path)
 Is path relative? More...
 

Variables

static const char preferred_separator_string [] = { preferred_separator, '\0' }
 

Function Documentation

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

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 484 of file Path.cpp.

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

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

Get begin iterator over path.

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

Definition at line 232 of file Path.cpp.

Referenced by llvm::RegionBase< RegionTr >::addSubRegion(), append(), llvm::MemoryDepChecker::areDepsSafe(), llvm::RegionBase< RegionTr >::clearNodeCache(), llvm::CodeExtractor::extractCodeRegion(), llvm::DwarfAccelTable::FinalizeTable(), llvm::DWARFDebugAranges::findAddress(), get64BitArgumentGPRs(), get64BitArgumentXMMs(), llvm::MCObjectStreamer::getCurrentFragment(), getFirstReloc(), llvm::getIntrinsicWithChain(), llvm::getIntrinsicWithoutChain(), llvm::R600RegisterInfo::getReservedRegs(), llvm::MipsRegisterInfo::getReservedRegs(), llvm::PPCRegisterInfo::getReservedRegs(), getStruct(), getStructOrErr(), llvm::object::MachOObjectFile::getSymbolName(), llvm::SmallVectorTemplateBase< T, isPodLike >::grow(), isIntrinsicInline(), LLVMGetFirstTarget(), LLVMGetTargetFromName(), llvm::TargetRegistry::lookupTarget(), llvm::SITargetLowering::LowerFormalArguments(), lowerV16I8VectorShuffle(), lowerV8I16GeneralSingleInputVectorShuffle(), llvm::MachineTraceMetrics::MachineTraceMetrics(), llvm::makeArrayRef(), llvm::GraphTraits< MachineRegionInfo * >::nodes_begin(), llvm::GraphTraits< RegionInfo * >::nodes_begin(), llvm::TargetLibraryInfoImpl::operator=(), llvm::SmallVectorImpl< T >::operator=(), llvm::MCSectionMachO::ParseSectionSpecifier(), llvm::DominanceFrontierBase< BlockT >::print(), llvm::DwarfAccelTable::print(), llvm::LoopBase< N, M >::print(), llvm::RegionBase< RegionTr >::print(), llvm::opt::OptTable::PrintHelp(), readExponent(), llvm::DominanceFrontierBase< BlockT >::removeBlock(), llvm::LoopInfoBase< BasicBlock, Loop >::removeLoop(), llvm::PMDataManager::removeNotPreservedAnalysis(), llvm::RegionBase< RegionTr >::removeSubRegion(), root_directory(), root_name(), root_path(), llvm::scc_begin(), llvm::SchedDFSResult::scheduleTree(), llvm::object::COFFObjectFile::section_rel_begin(), llvm::EngineBuilder::selectTarget(), skipLeadingZeroesAndAnyDot(), llvm::SmallVectorImpl< T >::swap(), llvm::TargetLibraryInfoImpl::TargetLibraryInfoImpl(), llvm::RegionBase< RegionTr >::transferChildrenTo(), llvm::UnrollLoop(), llvm::UnrollRuntimeLoopProlog(), llvm::TargetLoweringBase::ValueTypeActionImpl::ValueTypeActionImpl(), llvm::LoopInfoBase< N, M >::verify(), llvm::verifyIntrinsicTables(), llvm::LoopBase< N, M >::verifyLoop(), and llvm::LoopBase< N, M >::verifyLoopNest().

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 240 of file Path.cpp.

References llvm::StringRef::size().

Referenced by llvm::RegionBase< RegionTr >::addSubRegion(), llvm::DominanceFrontierBase< BlockT >::addToFrontier(), append(), llvm::MemoryDepChecker::areDepsSafe(), canBeFeederToNewValueJump(), canCompareBeNewValueJump(), llvm::LiveIntervals::checkRegMaskInterference(), llvm::RegionBase< RegionTr >::clearNodeCache(), llvm::DominanceFrontierBase< BlockT >::compare(), llvm::UnwindOpcodeAssembler::Finalize(), llvm::DWARFDebugAranges::findAddress(), get64BitArgumentGPRs(), get64BitArgumentXMMs(), llvm::getIntrinsicWithChain(), llvm::getIntrinsicWithoutChain(), llvm::object::ArchiveMemberHeader::getName(), llvm::R600RegisterInfo::getReservedRegs(), llvm::MipsRegisterInfo::getReservedRegs(), llvm::object::MachOObjectFile::getSymbolName(), getUs(), getUses(), llvm::SmallVectorTemplateBase< T, isPodLike >::grow(), llvm::BitTracker::CellMapType::has(), llvm::hashing::detail::hash_combine_range_impl(), interpretDecimal(), isIntrinsicInline(), llvm::SplitAnalysis::isOriginalEndpoint(), LLVMGetFirstTarget(), LLVMGetTargetFromName(), llvm::TargetRegistry::lookupTarget(), lowerV16I8VectorShuffle(), lowerV8I16GeneralSingleInputVectorShuffle(), llvm::MachineTraceMetrics::MachineTraceMetrics(), llvm::makeArrayRef(), llvm::GraphTraits< MachineRegionInfo * >::nodes_end(), llvm::GraphTraits< RegionInfo * >::nodes_end(), llvm::TargetLibraryInfoImpl::operator=(), llvm::SmallVectorImpl< T >::operator=(), llvm::MCSectionMachO::ParseSectionSpecifier(), llvm::DominanceFrontierBase< BlockT >::print(), llvm::LoopBase< N, M >::print(), llvm::RegionBase< RegionTr >::print(), readExponent(), llvm::DominanceFrontierBase< BlockT >::removeBlock(), llvm::DominanceFrontierBase< BlockT >::removeFromFrontier(), llvm::LoopInfoBase< BasicBlock, Loop >::removeLoop(), llvm::PMDataManager::removeNotPreservedAnalysis(), root_directory(), root_name(), root_path(), scanInlinedCode(), llvm::scc_end(), llvm::SchedDFSResult::scheduleTree(), llvm::EngineBuilder::selectTarget(), skipLeadingZeroesAndAnyDot(), llvm::Regex::sub(), llvm::SmallVectorImpl< T >::swap(), llvm::TargetLibraryInfoImpl::TargetLibraryInfoImpl(), totalExponent(), llvm::RegionBase< RegionTr >::transferChildrenTo(), llvm::TargetLoweringBase::ValueTypeActionImpl::ValueTypeActionImpl(), llvm::LoopInfoBase< N, M >::verify(), llvm::verifyIntrinsicTables(), llvm::LoopBase< N, M >::verifyLoop(), and llvm::LoopBase< N, M >::verifyLoopNest().

StringRef llvm::sys::path::extension ( StringRef  path)

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 565 of file Path.cpp.

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

Referenced by has_extension().

StringRef llvm::sys::path::filename ( StringRef  path)

Get filename.

/foo.txt => foo.txt
. => .
.. => ..
/ => /
Parameters
pathInput path.
Returns
The filename part of path. This is defined as the last component of path.

Definition at line 548 of file Path.cpp.

References rbegin().

Referenced by llvm::Module::createRNG(), extension(), llvm::MCDwarfLineTableHeader::getFile(), getFuncNameWithoutPrefix(), has_filename(), llvm::libDriverMain(), llvm::LineReader::LineReader(), mangleCoveragePath(), stem(), and llvm::writeArchive().

StringRef llvm::sys::path::get_separator ( )

Return the preferred separator for this platform.

Returns
StringRef of the preferred separator, null-terminated.

Definition at line 590 of file Path.cpp.

References preferred_separator_string.

Referenced by llvm::SourceMgr::AddIncludeFile(), and EmitGenDwarfInfo().

bool llvm::sys::path::has_extension ( const Twine path)

Has extension?

extension != ""

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

Definition at line 643 of file Path.cpp.

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

bool llvm::sys::path::has_filename ( const Twine path)

Has filename?

filename != ""

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

Definition at line 622 of file Path.cpp.

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

bool llvm::sys::path::has_parent_path ( const Twine path)

Has parent path?

parent_path != ""

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

Definition at line 629 of file Path.cpp.

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

bool llvm::sys::path::has_relative_path ( const Twine path)

Has relative path?

relative_path != ""

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

Definition at line 615 of file Path.cpp.

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

bool llvm::sys::path::has_root_directory ( const Twine path)

Has root directory?

root_directory != ""

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

Definition at line 601 of file Path.cpp.

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

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

bool llvm::sys::path::has_root_name ( const Twine path)

Has root name?

root_name != ""

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

Definition at line 594 of file Path.cpp.

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

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

bool llvm::sys::path::has_root_path ( const Twine path)

Has root path?

root_path != ""

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

Definition at line 608 of file Path.cpp.

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

bool llvm::sys::path::has_stem ( const Twine path)

Has stem?

stem != ""

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

Definition at line 636 of file Path.cpp.

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

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().

bool llvm::sys::path::is_absolute ( const Twine path)

Is path absolute?

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

Definition at line 650 of file Path.cpp.

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

Referenced by createUniqueEntity(), llvm::NVPTXAsmPrinter::emitLineNumberAsDotLoc(), llvm::sys::Process::FindInEnvPath(), llvm::DWARFDebugLine::LineTable::getFileNameByIndex(), and is_relative().

bool llvm::sys::path::is_relative ( const Twine path)

Is path relative?

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

Definition at line 664 of file Path.cpp.

References is_absolute().

Referenced by llvm::DWARFDebugLine::LineTable::getFileNameByIndex().

bool llvm::sys::path::is_separator ( char  value)

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 578 of file Path.cpp.

Referenced by append(), llvm::sys::path::const_iterator::operator++(), llvm::sys::path::reverse_iterator::operator++(), root_directory(), root_name(), and root_path().

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

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 522 of file Path.cpp.

References llvm::SmallVectorImpl< T >::clear(), llvm::StringRef::data(), llvm::SmallVectorTemplateCommon< T, typename >::data(), llvm::Twine::getSingleStringRef(), llvm::Twine::isSingleStringRef(), llvm::support::native, and llvm::Twine::toVector().

void llvm::sys::path::native ( SmallVectorImpl< char > &  path)

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 532 of file Path.cpp.

References llvm::SmallVectorTemplateCommon< T, typename >::begin(), and llvm::SmallVectorTemplateCommon< T, typename >::end().

StringRef llvm::sys::path::parent_path ( StringRef  path)

Get parent path.

/ => <empty>
/foo => /
foo/../bar => foo/..
Parameters
pathInput path.
Returns
The parent path of path if one exists, otherwise "".

Definition at line 490 of file Path.cpp.

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

Referenced by llvm::sys::fs::create_directories(), llvm::MCDwarfLineTableHeader::getFile(), and has_parent_path().

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

Get reverse begin iterator over path.

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

Definition at line 308 of file Path.cpp.

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

Referenced by filename().

StringRef llvm::sys::path::relative_path ( StringRef  path)

Get relative path.

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

Definition at line 438 of file Path.cpp.

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

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

void llvm::sys::path::remove_filename ( SmallVectorImpl< char > &  path)

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

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

Definition at line 498 of file Path.cpp.

References llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::StringRef::npos, llvm::SmallVectorImpl< T >::set_size(), and llvm::SmallVectorTemplateCommon< T, typename >::size().

Referenced by llvm::object::Archive::Child::getBuffer(), and llvm::sys::fs::directory_entry::replace_filename().

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 315 of file Path.cpp.

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

Referenced by computeLiveInValues(), and findLiveSetAtInst().

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

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 504 of file Path.cpp.

References llvm::SmallVectorImpl< T >::append(), llvm::StringRef::begin(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::StringRef::end(), llvm::StringRef::find_last_of(), llvm::StringRef::npos, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::SmallVectorImpl< T >::set_size(), llvm::StringRef::size(), llvm::SmallVectorTemplateCommon< T, typename >::size(), and llvm::Twine::toStringRef().

Referenced by getOutputPath().

StringRef llvm::sys::path::root_directory ( StringRef  path)

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 409 of file Path.cpp.

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

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

StringRef llvm::sys::path::root_name ( StringRef  path)

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 387 of file Path.cpp.

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

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

StringRef llvm::sys::path::root_path ( StringRef  path)

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 355 of file Path.cpp.

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

Referenced by has_root_path(), and relative_path().

StringRef llvm::sys::path::stem ( StringRef  path)

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 552 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().

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 createUniqueEntity().

std::error_code llvm::sys::path::widenPath ( const Twine &  Path8,
SmallVectorImpl< wchar_t > &  Path16 
)

Variable Documentation

const char llvm::sys::path::preferred_separator_string[] = { preferred_separator, '\0' }
static

Definition at line 588 of file Path.cpp.

Referenced by get_separator().