[SystemZ][z/OS] Set more text files as text
authorAbhina Sreeskantharajan <Abhina.Sreeskantharajan@ibm.com>
Mon, 19 Apr 2021 13:31:13 +0000 (09:31 -0400)
committerAbhina Sreeskantharajan <Abhina.Sreeskantharajan@ibm.com>
Mon, 19 Apr 2021 13:31:46 +0000 (09:31 -0400)
This patch corrects more instances of text files being opened as text.

Reviewed By: Jonathan.Crowther

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

clang/tools/driver/cc1gen_reproducer_main.cpp
clang/tools/libclang/CIndexer.cpp
llvm/include/llvm/Support/GraphWriter.h

index 472055e..89b7227 100644 (file)
@@ -162,7 +162,7 @@ int cc1gen_reproducer_main(ArrayRef<const char *> Argv, const char *Argv0,
   // Parse the invocation descriptor.
   StringRef Input = Argv[0];
   llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buffer =
-      llvm::MemoryBuffer::getFile(Input);
+      llvm::MemoryBuffer::getFile(Input, /*IsText=*/true);
   if (!Buffer) {
     llvm::errs() << "error: failed to read " << Input << ": "
                  << Buffer.getError().message() << "\n";
index 3d8c00c..c7baab3 100644 (file)
@@ -163,7 +163,8 @@ LibclangInvocationReporter::LibclangInvocationReporter(
   TempPath = Path;
   llvm::sys::path::append(TempPath, "libclang-%%%%%%%%%%%%");
   int FD;
-  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath))
+  if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath,
+                                      llvm::sys::fs::OF_Text))
     return;
   File = std::string(TempPath.begin(), TempPath.end());
   llvm::raw_fd_ostream OS(FD, /*ShouldClose=*/true);
index 4bb410d..b886bf4 100644 (file)
@@ -331,7 +331,8 @@ std::string WriteGraph(const GraphType &G, const Twine &Name,
   if (Filename.empty()) {
     Filename = createGraphFilename(Name.str(), FD);
   } else {
-    std::error_code EC = sys::fs::openFileForWrite(Filename, FD);
+    std::error_code EC = sys::fs::openFileForWrite(
+        Filename, FD, sys::fs::CD_CreateAlways, sys::fs::OF_Text);
 
     // Writing over an existing file is not considered an error.
     if (EC == std::errc::file_exists) {