22 std::lock_guard<std::mutex> lock(
Mutex);
23 std::string FileStr = File.str();
46 UpperDest = Path.upper();
53 : Root(Root), OverlayRoot(OverlayRoot) {
58void FileCollector::PathCanonicalizer::updateWithRealPath(
60 StringRef SrcPath(Path.begin(), Path.size());
68 auto DirWithSymlink = CachedDirs.
find(Directory);
69 if (DirWithSymlink == CachedDirs.
end()) {
74 CachedDirs[Directory] = std::string(RealPath);
76 RealPath = DirWithSymlink->second;
139 std::error_code &EC) {
140 auto It = FS->dir_begin(Dir, EC);
154 return FS->dir_begin(Dir, EC);
159static std::error_code
169 FD, Stat.getLastAccessedTime(), Stat.getLastModificationTime()))
184 std::lock_guard<std::mutex> lock(
Mutex);
200 if (std::error_code EC =
209 if (std::error_code EC =
239 std::lock_guard<std::mutex> lock(
Mutex);
260 std::shared_ptr<FileCollector>
Collector)
264 auto Result = FS->status(Path);
265 if (Result && Result->exists())
272 auto Result = FS->openFileForRead(Path);
273 if (Result && *Result)
279 std::error_code &EC)
override {
280 return Collector->addDirectoryImpl(Dir, FS, EC);
285 auto EC = FS->getRealPath(Path, Output);
288 if (Output.
size() > 0)
295 return FS->isLocal(Path, Result);
299 return FS->getCurrentWorkingDirectory();
303 return FS->setCurrentWorkingDirectory(Path);
308 std::shared_ptr<FileCollector>
Collector;
315 std::shared_ptr<FileCollector>
Collector) {
static std::error_code copyAccessAndModificationTime(StringRef Filename, const sys::fs::file_status &Stat)
Set the access and modification time for the given file from the given status object.
static void makeAbsolute(SmallVectorImpl< char > &Path)
Make Path absolute.
static bool isCaseSensitivePath(StringRef Path)
Provides a library for accessing information about this process and other processes on the operating ...
Register Usage Information Collector
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
Represents either an error or a value T.
void addDirectory(const Twine &Dir)
virtual ~FileCollectorBase()
void addFile(const Twine &file)
virtual llvm::vfs::directory_iterator addDirectoryImpl(const llvm::Twine &Dir, IntrusiveRefCntPtr< vfs::FileSystem > FS, std::error_code &EC)=0
bool markAsSeen(StringRef Path)
virtual void addFileImpl(StringRef SrcPath)=0
FileCollectorFileSystem(IntrusiveRefCntPtr< vfs::FileSystem > FS, std::shared_ptr< FileCollector > Collector)
std::error_code getRealPath(const Twine &Path, SmallVectorImpl< char > &Output) override
Gets real path of Path e.g.
std::error_code setCurrentWorkingDirectory(const llvm::Twine &Path) override
Set the working directory.
std::error_code isLocal(const Twine &Path, bool &Result) override
Is the file mounted on a local filesystem?
llvm::ErrorOr< llvm::vfs::Status > status(const Twine &Path) override
Get the status of the entry at Path, if one exists.
llvm::ErrorOr< std::unique_ptr< llvm::vfs::File > > openFileForRead(const Twine &Path) override
Get a File object for the text file at Path, if one exists.
llvm::vfs::directory_iterator dir_begin(const llvm::Twine &Dir, std::error_code &EC) override
Get a directory_iterator for Dir.
llvm::ErrorOr< std::string > getCurrentWorkingDirectory() const override
Get the working directory of this file system.
PathStorage canonicalize(StringRef SrcPath)
Canonicalize a pair of virtual and real paths.
llvm::vfs::directory_iterator addDirectoryImpl(const llvm::Twine &Dir, IntrusiveRefCntPtr< vfs::FileSystem > FS, std::error_code &EC) override
std::error_code writeMapping(StringRef MappingFile)
Write the yaml mapping (for the VFS) to the given file.
FileCollector(std::string Root, std::string OverlayRoot)
Root is the directory where collected files are will be stored.
std::error_code copyFiles(bool StopOnError=true)
Copy the files into the root directory.
const std::string OverlayRoot
The root directory where the VFS overlay lives.
PathCanonicalizer Canonicalizer
Helper utility for canonicalizing paths.
const std::string Root
The directory where collected files are copied to in copyFiles().
vfs::YAMLVFSWriter VFSWriter
The yaml mapping writer.
void addFileImpl(StringRef SrcPath) override
static IntrusiveRefCntPtr< vfs::FileSystem > createCollectorVFS(IntrusiveRefCntPtr< vfs::FileSystem > BaseFS, std::shared_ptr< FileCollector > Collector)
Create a VFS that uses Collector to collect files accessed via BaseFS.
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
iterator find(StringRef Key)
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
A raw_ostream that writes to a file descriptor.
static std::error_code SafelyCloseFileDescriptor(int FD)
Represents the result of a call to sys::fs::status().
The virtual file system interface.
void setCaseSensitivity(bool CaseSensitive)
void setOverlayDir(StringRef OverlayDirectory)
const std::vector< YAMLVFSEntry > & getMappings() const
void write(llvm::raw_ostream &OS)
void setUseExternalNames(bool UseExtNames)
An input iterator over the entries in a virtual path, similar to llvm::sys::fs::directory_iterator.
void make_absolute(const Twine ¤t_directory, SmallVectorImpl< char > &path)
Make path an absolute path.
std::error_code real_path(const Twine &path, SmallVectorImpl< char > &output, bool expand_tilde=false)
Collapse all .
ErrorOr< perms > getPermissions(const Twine &Path)
Get file permissions.
std::error_code setLastAccessAndModificationTime(int FD, TimePoint<> AccessTime, TimePoint<> ModificationTime)
Set the file modification and access time.
std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
@ OF_TextWithCRLF
The file should be opened in text mode and use a carriage linefeed '\r '.
@ CD_OpenExisting
CD_OpenExisting - When opening a file:
std::error_code openFileForWrite(const Twine &Name, int &ResultFD, CreationDisposition Disp=CD_CreateAlways, OpenFlags Flags=OF_None, unsigned Mode=0666)
Opens the file with the given name in a write-only or read-write mode, returning its open file descri...
std::error_code create_directories(const Twine &path, bool IgnoreExisting=true, perms Perms=owner_all|group_all)
Create all the non-existent directories in path.
std::error_code copy_file(const Twine &From, const Twine &To)
Copy the contents of From to To.
std::error_code setPermissions(const Twine &Path, perms Permissions)
Set file permissions.
bool is_directory(const basic_file_status &status)
Does status represent a directory?
bool remove_dots(SmallVectorImpl< char > &path, bool remove_dot_dot=false, Style style=Style::native)
In-place remove any '.
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
StringRef parent_path(StringRef path, Style style=Style::native)
Get parent path.
bool is_absolute(const Twine &path, Style style=Style::native)
Is path absolute?
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
StringRef relative_path(StringRef path, Style style=Style::native)
Get relative path.
StringRef remove_leading_dotslash(StringRef path, Style style=Style::native)
Remove redundant leading "./" pieces and consecutive separators.
IntrusiveRefCntPtr< FileSystem > getRealFileSystem()
Gets an vfs::FileSystem for the 'real' file system, as seen by the operating system.
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
SmallString< 256 > VirtualPath
SmallString< 256 > CopyFrom