aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/FileCollector.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2020-08-17 11:13:11 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2020-08-17 11:21:39 -0700
commit295eb54deb8784e448b73eec5eb1517b27d89541 (patch)
tree094ae9d65aae98262a1b586a30978cc14ee2fd67 /llvm/lib/Support/FileCollector.cpp
parent5ca7c6386f471121b8a82fdd18d43113073f2d18 (diff)
downloadllvm-295eb54deb8784e448b73eec5eb1517b27d89541.zip
llvm-295eb54deb8784e448b73eec5eb1517b27d89541.tar.gz
llvm-295eb54deb8784e448b73eec5eb1517b27d89541.tar.bz2
[llvm] Don't create the directory hierarchy in the FileCollector...
... if the collected file doesn't exists. This fixes the situation where LLDB can't create a file when capturing a reproducer because the parent path doesn't exist, but can during replay because the file collector created the directory hierarchy even though the file doesn't exist. This is covered by the lldb reproducer test suite.
Diffstat (limited to 'llvm/lib/Support/FileCollector.cpp')
-rw-r--r--llvm/lib/Support/FileCollector.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/llvm/lib/Support/FileCollector.cpp b/llvm/lib/Support/FileCollector.cpp
index 5975555..4c72f2b 100644
--- a/llvm/lib/Support/FileCollector.cpp
+++ b/llvm/lib/Support/FileCollector.cpp
@@ -158,14 +158,6 @@ std::error_code FileCollector::copyFiles(bool StopOnError) {
std::lock_guard<std::mutex> lock(Mutex);
for (auto &entry : VFSWriter.getMappings()) {
- // Create directory tree.
- if (std::error_code EC =
- sys::fs::create_directories(sys::path::parent_path(entry.RPath),
- /*IgnoreExisting=*/true)) {
- if (StopOnError)
- return EC;
- }
-
// Get the status of the original file/directory.
sys::fs::file_status Stat;
if (std::error_code EC = sys::fs::status(entry.VPath, Stat)) {
@@ -174,6 +166,18 @@ std::error_code FileCollector::copyFiles(bool StopOnError) {
continue;
}
+ // Continue if the file doesn't exist.
+ if (Stat.type() == sys::fs::file_type::file_not_found)
+ continue;
+
+ // Create directory tree.
+ if (std::error_code EC =
+ sys::fs::create_directories(sys::path::parent_path(entry.RPath),
+ /*IgnoreExisting=*/true)) {
+ if (StopOnError)
+ return EC;
+ }
+
if (Stat.type() == sys::fs::file_type::directory_file) {
// Construct a directory when it's just a directory entry.
if (std::error_code EC =