[clang] 05b4bab - [SystemZ][z/OS] Set more text files as text

Abhina Sreeskantharajan via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 19 06:31:55 PDT 2021


Author: Abhina Sreeskantharajan
Date: 2021-04-19T09:31:46-04:00
New Revision: 05b4babc9d85a6669a39a58351fd8b1ebca2ab96

URL: https://github.com/llvm/llvm-project/commit/05b4babc9d85a6669a39a58351fd8b1ebca2ab96
DIFF: https://github.com/llvm/llvm-project/commit/05b4babc9d85a6669a39a58351fd8b1ebca2ab96.diff

LOG: [SystemZ][z/OS] Set more text files as text

This patch corrects more instances of text files being opened as text.

Reviewed By: Jonathan.Crowther

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/tools/driver/cc1gen_reproducer_main.cpp b/clang/tools/driver/cc1gen_reproducer_main.cpp
index 472055ee21708..89b7227fdb17a 100644
--- a/clang/tools/driver/cc1gen_reproducer_main.cpp
+++ b/clang/tools/driver/cc1gen_reproducer_main.cpp
@@ -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";

diff  --git a/clang/tools/libclang/CIndexer.cpp b/clang/tools/libclang/CIndexer.cpp
index 3d8c00cf21154..c7baab3a2c470 100644
--- a/clang/tools/libclang/CIndexer.cpp
+++ b/clang/tools/libclang/CIndexer.cpp
@@ -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);

diff  --git a/llvm/include/llvm/Support/GraphWriter.h b/llvm/include/llvm/Support/GraphWriter.h
index 4bb410d99f3f5..b886bf45f474b 100644
--- a/llvm/include/llvm/Support/GraphWriter.h
+++ b/llvm/include/llvm/Support/GraphWriter.h
@@ -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) {


        


More information about the cfe-commits mailing list