[llvm] 4c53f42 - [FileCollector] move Root creation
Jan Korous via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 29 11:47:46 PDT 2020
Author: Jan Korous
Date: 2020-04-29T11:47:23-07:00
New Revision: 4c53f4202a45266ac89ae240c05e2bdcbfc3308f
URL: https://github.com/llvm/llvm-project/commit/4c53f4202a45266ac89ae240c05e2bdcbfc3308f
DIFF: https://github.com/llvm/llvm-project/commit/4c53f4202a45266ac89ae240c05e2bdcbfc3308f.diff
LOG: [FileCollector] move Root creation
If we don't handle the errors we can't rely on the directory being created early anyway.
Differential Revision: https://reviews.llvm.org/D78959
Added:
Modified:
llvm/include/llvm/Support/FileCollector.h
llvm/lib/Support/FileCollector.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/FileCollector.h b/llvm/include/llvm/Support/FileCollector.h
index 3a8741c88633..30e3470ece3c 100644
--- a/llvm/include/llvm/Support/FileCollector.h
+++ b/llvm/include/llvm/Support/FileCollector.h
@@ -23,6 +23,7 @@ class FileCollectorFileSystem;
/// the VFS.
class FileCollector {
public:
+ /// \p Root directory gets created in copyFiles unless it already exists.
FileCollector(std::string Root, std::string OverlayRoot);
void addFile(const Twine &file);
diff --git a/llvm/lib/Support/FileCollector.cpp b/llvm/lib/Support/FileCollector.cpp
index e13a7b5c233d..cb83d845695e 100644
--- a/llvm/lib/Support/FileCollector.cpp
+++ b/llvm/lib/Support/FileCollector.cpp
@@ -34,7 +34,6 @@ static bool isCaseSensitivePath(StringRef Path) {
FileCollector::FileCollector(std::string Root, std::string OverlayRoot)
: Root(std::move(Root)), OverlayRoot(std::move(OverlayRoot)) {
- sys::fs::create_directories(this->Root, true);
}
bool FileCollector::getRealPath(StringRef SrcPath,
@@ -150,6 +149,11 @@ copyAccessAndModificationTime(StringRef Filename,
}
std::error_code FileCollector::copyFiles(bool StopOnError) {
+ auto Err = sys::fs::create_directories(Root, /*IgnoreExisting=*/true);
+ if (Err) {
+ return Err;
+ }
+
std::lock_guard<std::mutex> lock(Mutex);
for (auto &entry : VFSWriter.getMappings()) {
More information about the llvm-commits
mailing list