|
LLVM 24.0.0git
|
Remap path prefixes. More...
#include "llvm/Support/PrefixMapper.h"
Public Member Functions | |
| virtual | ~PrefixMapper ()=default |
| bool | map (StringRef Path, SmallVectorImpl< char > &NewPath) const |
Map Path, and saving the new (or existing) path in NewPath. | |
| bool | map (StringRef Path, std::string &NewPath) const |
Map Path, and saving the new (or existing) path in NewPath. | |
| std::string | mapToString (StringRef Path) const |
Map Path, returning std::string. | |
| bool | mapInPlace (SmallVectorImpl< char > &Path) const |
Map Path in place. | |
| bool | mapInPlace (std::string &Path) const |
Map Path in place. | |
| virtual void | add (const MappedPrefix &MP) |
| void | sort () |
| A path-based reverse lexicographic sort, putting deeper paths first so that deeper paths are prioritized over their parent paths. | |
| template<class RangeT> | |
| void | addRange (const RangeT &Mappings) |
| template<class RangeT> | |
| void | addInverseRange (const RangeT &Mappings) |
| bool | empty () const |
| ArrayRef< MappedPrefix > | getMappings () const |
| sys::path::Style | getPathStyle () const |
| PrefixMapper (sys::path::Style PathStyle=sys::path::Style::native) | |
Protected Member Functions | |
| virtual std::optional< StringRef > | mapImpl (StringRef Path, SmallVectorImpl< char > &Storage) const |
Map (or unmap) Path. | |
Remap path prefixes.
Mappings are tried in order and the first match wins. A mapping only matches whole path components: Old must be followed by a separator or the end of the path, unless Old itself ends with a separator. For example, "/old=/new" remaps "/old" and "/old/a" but not "/old-a", and "/=/new" remaps every absolute path. With a Windows path style, matching is case- and separator-insensitive.
The rest of the path is joined to New with sys::path::append(): a separator is added if neither side has one, and leading separators are dropped from the rest if New ends with one. For example, "/old/a" maps to "/new/a" with either "/old=/new" or "/old/=/new/".
Paths are not canonicalized, so "/old/../a" maps to "/new/../a", "/old//a" maps to "/new//a", and "//old" is not matched by "/old".
Definition at line 76 of file PrefixMapper.h.
|
virtualdefault |
References map(), mapImpl(), mapInPlace(), and mapToString().
|
inlineexplicit |
Definition at line 141 of file PrefixMapper.h.
References llvm::sys::path::native.
|
inlinevirtual |
Definition at line 111 of file PrefixMapper.h.
Referenced by addInverseRange(), and addRange().
|
inline |
Definition at line 130 of file PrefixMapper.h.
References add().
|
inline |
Definition at line 125 of file PrefixMapper.h.
References add().
|
inline |
Definition at line 135 of file PrefixMapper.h.
References getMappings().
|
inline |
Definition at line 137 of file PrefixMapper.h.
Referenced by empty().
|
inline |
Definition at line 139 of file PrefixMapper.h.
| bool PrefixMapper::map | ( | StringRef | Path, |
| SmallVectorImpl< char > & | NewPath ) const |
Map Path, and saving the new (or existing) path in NewPath.
Path is not a reference into NewPath. NewPath was mapped. Definition at line 136 of file PrefixMapper.cpp.
References llvm::SmallVectorImpl< T >::assign(), llvm::SmallVectorImpl< T >::clear(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), mapImpl(), and Modified.
Referenced by ~PrefixMapper().
Map Path, and saving the new (or existing) path in NewPath.
Path is not a reference into NewPath. NewPath was mapped. Definition at line 148 of file PrefixMapper.cpp.
References mapImpl().
|
protectedvirtual |
Map (or unmap) Path.
On a match, fills Storage with the mapped path unless it's an exact match.
Path is not a reference into Storage. Definition at line 112 of file PrefixMapper.cpp.
References llvm::sys::path::append(), llvm::SmallVectorImpl< T >::assign(), llvm::StringRef::back(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::StringRef::empty(), llvm::StringRef::front(), llvm::sys::path::is_separator(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::StringRef::size(), and startsWith().
Referenced by map(), map(), mapInPlace(), mapInPlace(), mapToString(), and ~PrefixMapper().
| bool PrefixMapper::mapInPlace | ( | SmallVectorImpl< char > & | Path | ) | const |
Map Path in place.
Definition at line 161 of file PrefixMapper.cpp.
References llvm::SmallVectorTemplateCommon< T, typename >::empty(), mapImpl(), and llvm::SmallVectorImpl< T >::swap().
Referenced by ~PrefixMapper().
| bool PrefixMapper::mapInPlace | ( | std::string & | Path | ) | const |
Map Path in place.
Definition at line 174 of file PrefixMapper.cpp.
References mapImpl().
| std::string PrefixMapper::mapToString | ( | StringRef | Path | ) | const |
Map Path, returning std::string.
Definition at line 155 of file PrefixMapper.cpp.
References mapImpl().
Referenced by ~PrefixMapper().
| void PrefixMapper::sort | ( | ) |
A path-based reverse lexicographic sort, putting deeper paths first so that deeper paths are prioritized over their parent paths.
For example, if both the source and build directories are remapped and one is nested inside the other, the nested one will come first.
FIXME: The comparison is case- and separator-sensitive, unlike matching with a Windows path style.
FIXME: Should probably be done implicitly, maybe by moving to a std::set or std::map.
Definition at line 183 of file PrefixMapper.cpp.