[SystemZ][z/OS] Set files in FileRemapper.cpp are text
authorAbhina Sreeskantharajan <Abhina.Sreeskantharajan@ibm.com>
Mon, 19 Apr 2021 11:59:23 +0000 (07:59 -0400)
committerAbhina Sreeskantharajan <Abhina.Sreeskantharajan@ibm.com>
Mon, 19 Apr 2021 11:59:42 +0000 (07:59 -0400)
This patch sets files in FileRemapper to open as text.

Reviewed By: Jonathan.Crowther

Differential Revision: https://reviews.llvm.org/D100056

clang/lib/ARCMigrate/FileRemapper.cpp

index f536af1..92027fe 100644 (file)
@@ -63,7 +63,7 @@ bool FileRemapper::initFromFile(StringRef filePath, DiagnosticsEngine &Diag,
   std::vector<std::pair<const FileEntry *, const FileEntry *> > pairs;
 
   llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> fileBuf =
-      llvm::MemoryBuffer::getFile(infoFile);
+      llvm::MemoryBuffer::getFile(infoFile, /*IsText=*/true);
   if (!fileBuf)
     return report("Error opening file: " + infoFile, Diag);
 
@@ -121,7 +121,7 @@ bool FileRemapper::flushToFile(StringRef outputPath, DiagnosticsEngine &Diag) {
 
   std::error_code EC;
   std::string infoFile = std::string(outputPath);
-  llvm::raw_fd_ostream infoOut(infoFile, EC, llvm::sys::fs::OF_None);
+  llvm::raw_fd_ostream infoOut(infoFile, EC, llvm::sys::fs::OF_Text);
   if (EC)
     return report(EC.message(), Diag);
 
@@ -142,9 +142,10 @@ bool FileRemapper::flushToFile(StringRef outputPath, DiagnosticsEngine &Diag) {
 
       SmallString<64> tempPath;
       int fd;
-      if (fs::createTemporaryFile(path::filename(origFE->getName()),
-                                  path::extension(origFE->getName()).drop_front(), fd,
-                                  tempPath))
+      if (fs::createTemporaryFile(
+              path::filename(origFE->getName()),
+              path::extension(origFE->getName()).drop_front(), fd, tempPath,
+              llvm::sys::fs::OF_Text))
         return report("Could not create file: " + tempPath.str(), Diag);
 
       llvm::raw_fd_ostream newOut(fd, /*shouldClose=*/true);