[PATCH] D155651: [SystemZ][z/OS] Add OpenFlags to CreateMissingDirectories path when creating temp files

Tony Tao via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 18 15:26:55 PDT 2023


tltao created this revision.
Herald added a project: All.
tltao requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Additional patch to https://reviews.llvm.org/D103806 to add the same flags in the path where the CreateMissingDirectories booleans is set to true.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155651

Files:
  clang/lib/Frontend/CompilerInstance.cpp


Index: clang/lib/Frontend/CompilerInstance.cpp
===================================================================
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -895,10 +895,12 @@
     TempPath += "-%%%%%%%%";
     TempPath += OutputExtension;
     TempPath += ".tmp";
+    llvm::sys::fs::OpenFlags BinaryFlags =
+        Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text;
     Expected<llvm::sys::fs::TempFile> ExpectedFile =
         llvm::sys::fs::TempFile::create(
             TempPath, llvm::sys::fs::all_read | llvm::sys::fs::all_write,
-            Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text);
+            BinaryFlags);
 
     llvm::Error E = handleErrors(
         ExpectedFile.takeError(), [&](const llvm::ECError &E) -> llvm::Error {
@@ -908,7 +910,9 @@
             StringRef Parent = llvm::sys::path::parent_path(OutputPath);
             EC = llvm::sys::fs::create_directories(Parent);
             if (!EC) {
-              ExpectedFile = llvm::sys::fs::TempFile::create(TempPath);
+              ExpectedFile = llvm::sys::fs::TempFile::create(
+                  TempPath, llvm::sys::fs::all_read | llvm::sys::fs::all_write,
+                  BinaryFlags);
               if (!ExpectedFile)
                 return llvm::errorCodeToError(
                     llvm::errc::no_such_file_or_directory);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155651.541755.patch
Type: text/x-patch
Size: 1384 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230718/d8d8d353/attachment.bin>


More information about the cfe-commits mailing list