abhina.sreeskantharajan created this revision. Herald added subscribers: dexonsmith, arphaman. abhina.sreeskantharajan requested review of this revision. Herald added projects: clang, LLVM. Herald added subscribers: llvm-commits, cfe-commits.
This patch corrects more instances of text files being opened as text. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D100654 Files: clang/tools/driver/cc1gen_reproducer_main.cpp clang/tools/libclang/CIndexer.cpp llvm/include/llvm/Support/GraphWriter.h Index: llvm/include/llvm/Support/GraphWriter.h =================================================================== --- llvm/include/llvm/Support/GraphWriter.h +++ llvm/include/llvm/Support/GraphWriter.h @@ -331,7 +331,8 @@ 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) { Index: clang/tools/libclang/CIndexer.cpp =================================================================== --- clang/tools/libclang/CIndexer.cpp +++ clang/tools/libclang/CIndexer.cpp @@ -163,7 +163,8 @@ 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: clang/tools/driver/cc1gen_reproducer_main.cpp =================================================================== --- clang/tools/driver/cc1gen_reproducer_main.cpp +++ clang/tools/driver/cc1gen_reproducer_main.cpp @@ -162,7 +162,7 @@ // 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: llvm/include/llvm/Support/GraphWriter.h =================================================================== --- llvm/include/llvm/Support/GraphWriter.h +++ llvm/include/llvm/Support/GraphWriter.h @@ -331,7 +331,8 @@ 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) { Index: clang/tools/libclang/CIndexer.cpp =================================================================== --- clang/tools/libclang/CIndexer.cpp +++ clang/tools/libclang/CIndexer.cpp @@ -163,7 +163,8 @@ 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: clang/tools/driver/cc1gen_reproducer_main.cpp =================================================================== --- clang/tools/driver/cc1gen_reproducer_main.cpp +++ clang/tools/driver/cc1gen_reproducer_main.cpp @@ -162,7 +162,7 @@ // 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";
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits