diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2020-10-19 14:29:59 -0700 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2020-10-19 21:37:20 -0700 |
commit | f44fb130253aa5486380604101ce50a62a8d668b (patch) | |
tree | bffa5b0996f0c1f8ccf56fc42f8486f3959c05bc /llvm/lib/Support/FileCollector.cpp | |
parent | a10a64e7e334dc878d281aba9a46f751fe606567 (diff) | |
download | llvm-f44fb130253aa5486380604101ce50a62a8d668b.zip llvm-f44fb130253aa5486380604101ce50a62a8d668b.tar.gz llvm-f44fb130253aa5486380604101ce50a62a8d668b.tar.bz2 |
[FileCollector] Move interface into FileCollectorBase (NFC)
For the reproducers in LLDB we want to switch to an "immediate mode"
FileCollector that writes every file encountered straight to disk so we
can generate the actual mapping out-of-process. This patch moves the
interface into a separate base class.
Differential revision: https://reviews.llvm.org/D89742
Diffstat (limited to 'llvm/lib/Support/FileCollector.cpp')
-rw-r--r-- | llvm/lib/Support/FileCollector.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/llvm/lib/Support/FileCollector.cpp b/llvm/lib/Support/FileCollector.cpp index 4c72f2b..d0471ac 100644 --- a/llvm/lib/Support/FileCollector.cpp +++ b/llvm/lib/Support/FileCollector.cpp @@ -15,6 +15,22 @@ using namespace llvm; +FileCollectorBase::FileCollectorBase() = default; +FileCollectorBase::~FileCollectorBase() = default; + +void FileCollectorBase::addFile(const Twine &File) { + std::lock_guard<std::mutex> lock(Mutex); + std::string FileStr = File.str(); + if (markAsSeen(FileStr)) + addFileImpl(FileStr); +} + +void FileCollectorBase::addDirectory(const Twine &Dir) { + assert(sys::fs::is_directory(Dir)); + std::error_code EC; + addDirectoryImpl(Dir, vfs::getRealFileSystem(), EC); +} + static bool isCaseSensitivePath(StringRef Path) { SmallString<256> TmpDest = Path, UpperDest, RealDest; @@ -61,19 +77,6 @@ bool FileCollector::getRealPath(StringRef SrcPath, return true; } -void FileCollector::addFile(const Twine &File) { - std::lock_guard<std::mutex> lock(Mutex); - std::string FileStr = File.str(); - if (markAsSeen(FileStr)) - addFileImpl(FileStr); -} - -void FileCollector::addDirectory(const Twine &Dir) { - assert(sys::fs::is_directory(Dir)); - std::error_code EC; - addDirectoryImpl(Dir, vfs::getRealFileSystem(), EC); -} - void FileCollector::addFileImpl(StringRef SrcPath) { // We need an absolute src path to append to the root. SmallString<256> AbsoluteSrc = SrcPath; |