diff options
| author | Jonas Devlieghere <jonas@devlieghere.com> | 2022-03-03 11:52:02 -0800 |
|---|---|---|
| committer | Jonas Devlieghere <jonas@devlieghere.com> | 2022-03-03 13:22:38 -0800 |
| commit | 8b3b66ea63d6469e5a3842627d538805173bda05 (patch) | |
| tree | d9f0749151e55c5bc9a9f24d31cf5baa1cccfaea /lldb/source/Utility/Reproducer.cpp | |
| parent | 29fe819ed3bb236f231bde48130b79a0e702f8b2 (diff) | |
| download | llvm-8b3b66ea63d6469e5a3842627d538805173bda05.tar.gz llvm-8b3b66ea63d6469e5a3842627d538805173bda05.tar.bz2 llvm-8b3b66ea63d6469e5a3842627d538805173bda05.zip | |
[lldb] Remove FileSystem::Initialize from FileCollector
This patch removes the ability to instantiate the LLDB FileSystem class
with a FileCollector. It keeps the ability to collect files, but uses
the FileCollectorFileSystem to do that transparently.
Because the two are intertwined, this patch also removes the
finalization logic which copied the files over out of process.
Diffstat (limited to 'lldb/source/Utility/Reproducer.cpp')
| -rw-r--r-- | lldb/source/Utility/Reproducer.cpp | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/lldb/source/Utility/Reproducer.cpp b/lldb/source/Utility/Reproducer.cpp index a2ada12140cf..3641c933c38a 100644 --- a/lldb/source/Utility/Reproducer.cpp +++ b/lldb/source/Utility/Reproducer.cpp @@ -136,7 +136,6 @@ Generator::~Generator() { if (!m_done) { if (m_auto_generate) { Keep(); - llvm::cantFail(Finalize(GetRoot())); } else { Discard(); } @@ -229,58 +228,3 @@ bool Loader::HasFile(StringRef file) { auto it = std::lower_bound(m_files.begin(), m_files.end(), file.str()); return (it != m_files.end()) && (*it == file); } - -static llvm::Error addPaths(StringRef path, - function_ref<void(StringRef)> callback) { - auto buffer = llvm::MemoryBuffer::getFile(path); - if (!buffer) - return errorCodeToError(buffer.getError()); - - SmallVector<StringRef, 0> paths; - (*buffer)->getBuffer().split(paths, '\0'); - for (StringRef p : paths) { - if (!p.empty() && llvm::sys::fs::exists(p)) - callback(p); - } - - return errorCodeToError(llvm::sys::fs::remove(path)); -} - -llvm::Error repro::Finalize(Loader *loader) { - if (!loader) - return make_error<StringError>("invalid loader", - llvm::inconvertibleErrorCode()); - - FileSpec reproducer_root = loader->GetRoot(); - std::string files_path = - reproducer_root.CopyByAppendingPathComponent("files.txt").GetPath(); - std::string dirs_path = - reproducer_root.CopyByAppendingPathComponent("dirs.txt").GetPath(); - - FileCollector collector( - reproducer_root.CopyByAppendingPathComponent("root").GetPath(), - reproducer_root.GetPath()); - - if (Error e = - addPaths(files_path, [&](StringRef p) { collector.addFile(p); })) - return e; - - if (Error e = - addPaths(dirs_path, [&](StringRef p) { collector.addDirectory(p); })) - return e; - - FileSpec mapping = - reproducer_root.CopyByAppendingPathComponent(FileProvider::Info::file); - if (auto ec = collector.copyFiles(/*StopOnError=*/false)) - return errorCodeToError(ec); - collector.writeMapping(mapping.GetPath()); - - return llvm::Error::success(); -} - -llvm::Error repro::Finalize(const FileSpec &root) { - Loader loader(root); - if (Error e = loader.LoadIndex()) - return e; - return Finalize(&loader); -} |
