[PATCH] D78959: [WIP][FileCollector] move Root creation

Jan Korous via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 27 12:57:38 PDT 2020


jkorous created this revision.
jkorous added a reviewer: JDevlieghere.
Herald added subscribers: llvm-commits, dexonsmith, hiraditya.
Herald added a project: LLVM.

I might be missing something be since we aren't checking the return value of `create_directories` in constructor I'd say we can't really rely on that as part of the state.
Maybe we can just create it later and actually propagate the error? Or maybe just remove it completely as it'd get created in `copyFiles` when we iterate `VFSWriter.getMappings()`?


https://reviews.llvm.org/D78959

Files:
  llvm/lib/Support/FileCollector.cpp


Index: llvm/lib/Support/FileCollector.cpp
===================================================================
--- llvm/lib/Support/FileCollector.cpp
+++ llvm/lib/Support/FileCollector.cpp
@@ -35,7 +35,6 @@
 
 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,
@@ -124,6 +123,11 @@
 }
 
 std::error_code FileCollector::copyFiles(bool StopOnError) {
+  auto Err = sys::fs::create_directories(Root, true);
+  if (Err) {
+    return Err;
+  }
+
   // TODO: We're reading from VFSWriter so we should lock the Mutex, right?
   std::lock_guard<std::mutex> lock(Mutex);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78959.260417.patch
Type: text/x-patch
Size: 760 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200427/d0785e3d/attachment.bin>


More information about the llvm-commits mailing list