[flang-commits] [flang] 82b3e28 - [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text
Abhina Sreeskantharajan via flang-commits
flang-commits at lists.llvm.org
Tue Apr 6 04:23:42 PDT 2021
Author: Abhina Sreeskantharajan
Date: 2021-04-06T07:23:31-04:00
New Revision: 82b3e28e836d2f5c8cfd6e1047b93c088522365a
URL: https://github.com/llvm/llvm-project/commit/82b3e28e836d2f5c8cfd6e1047b93c088522365a
DIFF: https://github.com/llvm/llvm-project/commit/82b3e28e836d2f5c8cfd6e1047b93c088522365a.diff
LOG: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text
Problem:
On SystemZ we need to open text files in text mode. On Windows, files opened in text mode adds a CRLF '\r\n' which may not be desirable.
Solution:
This patch adds two new flags
- OF_CRLF which indicates that CRLF translation is used.
- OF_TextWithCRLF = OF_Text | OF_CRLF indicates that the file is text and uses CRLF translation.
Developers should now use either the OF_Text or OF_TextWithCRLF for text files and OF_None for binary files. If the developer doesn't want carriage returns on Windows, they should use OF_Text, if they do want carriage returns on Windows, they should use OF_TextWithCRLF.
So this is the behaviour per platform with my patch:
z/OS:
OF_None: open in binary mode
OF_Text : open in text mode
OF_TextWithCRLF: open in text mode
Windows:
OF_None: open file with no carriage return
OF_Text: open file with no carriage return
OF_TextWithCRLF: open file with carriage return
The Major change is in llvm/lib/Support/Windows/Path.inc to only set text mode if the OF_CRLF is set.
```
if (Flags & OF_CRLF)
CrtOpenFlags |= _O_TEXT;
```
These following files are the ones that still use OF_Text which I left unchanged. I modified all these except raw_ostream.cpp in recent patches so I know these were previously in Binary mode on Windows.
./llvm/lib/Support/raw_ostream.cpp
./llvm/lib/TableGen/Main.cpp
./llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
./llvm/unittests/Support/Path.cpp
./clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
./clang/lib/Frontend/CompilerInstance.cpp
./clang/lib/Driver/Driver.cpp
./clang/lib/Driver/ToolChains/Clang.cpp
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D99426
Added:
Modified:
clang-tools-extra/clang-move/tool/ClangMove.cpp
clang-tools-extra/modularize/ModuleAssistant.cpp
clang-tools-extra/pp-trace/PPTrace.cpp
clang/lib/ARCMigrate/PlistReporter.cpp
clang/lib/Driver/Compilation.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/DependencyFile.cpp
clang/lib/Frontend/DependencyGraph.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Frontend/HeaderIncludeGen.cpp
clang/lib/Frontend/ModuleDependencyCollector.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
clang/tools/clang-refactor/ClangRefactor.cpp
clang/tools/driver/cc1as_main.cpp
flang/lib/Frontend/CompilerInstance.cpp
lld/COFF/DriverUtils.cpp
lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
lldb/include/lldb/Utility/ReproducerProvider.h
lldb/source/Utility/GDBRemote.cpp
lldb/source/Utility/ReproducerProvider.cpp
lldb/tools/lldb-server/LLDBServerUtilities.cpp
llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
llvm/include/llvm/Support/FileSystem.h
llvm/lib/CodeGen/RegAllocPBQP.cpp
llvm/lib/IR/Core.cpp
llvm/lib/IR/LLVMRemarkStreamer.cpp
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/MC/MCParser/DarwinAsmParser.cpp
llvm/lib/ProfileData/GCOV.cpp
llvm/lib/ProfileData/SampleProfWriter.cpp
llvm/lib/Support/FileCollector.cpp
llvm/lib/Support/MemoryBuffer.cpp
llvm/lib/Support/TimeProfiler.cpp
llvm/lib/Support/Timer.cpp
llvm/lib/Support/Unix/Program.inc
llvm/lib/Support/Windows/Path.inc
llvm/lib/Support/Windows/Program.inc
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/lib/Transforms/Utils/Debugify.cpp
llvm/tools/dsymutil/dsymutil.cpp
llvm/tools/llc/llc.cpp
llvm/tools/lli/lli.cpp
llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
llvm/tools/llvm-dis/llvm-dis.cpp
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
llvm/tools/llvm-link/llvm-link.cpp
llvm/tools/llvm-mc/llvm-mc.cpp
llvm/tools/llvm-mca/llvm-mca.cpp
llvm/tools/llvm-opt-report/OptReport.cpp
llvm/tools/llvm-profdata/llvm-profdata.cpp
llvm/tools/llvm-xray/xray-account.cpp
llvm/tools/llvm-xray/xray-converter.cpp
llvm/tools/llvm-xray/xray-extract.cpp
llvm/tools/llvm-xray/xray-graph-diff.cpp
llvm/tools/llvm-xray/xray-graph.cpp
llvm/tools/opt/opt.cpp
llvm/tools/verify-uselistorder/verify-uselistorder.cpp
llvm/unittests/Support/Path.cpp
polly/lib/Exchange/JSONExporter.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-move/tool/ClangMove.cpp b/clang-tools-extra/clang-move/tool/ClangMove.cpp
index d4bd9a36517d6..a38538768226e 100644
--- a/clang-tools-extra/clang-move/tool/ClangMove.cpp
+++ b/clang-tools-extra/clang-move/tool/ClangMove.cpp
@@ -30,7 +30,8 @@ namespace {
std::error_code CreateNewFile(const llvm::Twine &path) {
int fd = 0;
if (std::error_code ec = llvm::sys::fs::openFileForWrite(
- path, fd, llvm::sys::fs::CD_CreateAlways, llvm::sys::fs::OF_Text))
+ path, fd, llvm::sys::fs::CD_CreateAlways,
+ llvm::sys::fs::OF_TextWithCRLF))
return ec;
return llvm::sys::Process::SafelyCloseFileDescriptor(fd);
diff --git a/clang-tools-extra/modularize/ModuleAssistant.cpp b/clang-tools-extra/modularize/ModuleAssistant.cpp
index 1dba973bd6675..bdce90726e0ab 100644
--- a/clang-tools-extra/modularize/ModuleAssistant.cpp
+++ b/clang-tools-extra/modularize/ModuleAssistant.cpp
@@ -268,7 +268,7 @@ static bool writeModuleMap(llvm::StringRef ModuleMapPath,
// Set up module map output file.
std::error_code EC;
- llvm::ToolOutputFile Out(FilePath, EC, llvm::sys::fs::OF_Text);
+ llvm::ToolOutputFile Out(FilePath, EC, llvm::sys::fs::OF_TextWithCRLF);
if (EC) {
llvm::errs() << Argv0 << ": error opening " << FilePath << ":"
<< EC.message() << "\n";
diff --git a/clang-tools-extra/pp-trace/PPTrace.cpp b/clang-tools-extra/pp-trace/PPTrace.cpp
index f91b01969a7d4..3fa16498fbefc 100644
--- a/clang-tools-extra/pp-trace/PPTrace.cpp
+++ b/clang-tools-extra/pp-trace/PPTrace.cpp
@@ -152,7 +152,7 @@ int main(int argc, const char **argv) {
OptionsParser->getSourcePathList());
std::error_code EC;
- llvm::ToolOutputFile Out(OutputFileName, EC, llvm::sys::fs::OF_Text);
+ llvm::ToolOutputFile Out(OutputFileName, EC, llvm::sys::fs::OF_TextWithCRLF);
if (EC)
error(EC.message());
PPTraceFrontendActionFactory Factory(Filters, Out.os());
diff --git a/clang/lib/ARCMigrate/PlistReporter.cpp b/clang/lib/ARCMigrate/PlistReporter.cpp
index d01563b2974dd..c233d6bd9002a 100644
--- a/clang/lib/ARCMigrate/PlistReporter.cpp
+++ b/clang/lib/ARCMigrate/PlistReporter.cpp
@@ -56,7 +56,7 @@ void arcmt::writeARCDiagsToPlist(const std::string &outPath,
}
std::error_code EC;
- llvm::raw_fd_ostream o(outPath, EC, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream o(outPath, EC, llvm::sys::fs::OF_TextWithCRLF);
if (EC) {
llvm::errs() << "error: could not create file: " << outPath << '\n';
return;
diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp
index f28c23a59940d..0144d808cf124 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -175,7 +175,7 @@ int Compilation::ExecuteCommand(const Command &C,
std::error_code EC;
OwnedStream.reset(new llvm::raw_fd_ostream(
getDriver().CCPrintOptionsFilename.c_str(), EC,
- llvm::sys::fs::OF_Append | llvm::sys::fs::OF_Text));
+ llvm::sys::fs::OF_Append | llvm::sys::fs::OF_TextWithCRLF));
if (EC) {
getDriver().Diag(diag::err_drv_cc_print_options_failure)
<< EC.message();
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 3d5cdb3acd244..96a43656bf996 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2264,8 +2264,8 @@ void Clang::DumpCompilationDatabase(Compilation &C, StringRef Filename,
if (!CompilationDatabase) {
std::error_code EC;
- auto File = std::make_unique<llvm::raw_fd_ostream>(Filename, EC,
- llvm::sys::fs::OF_Text);
+ auto File = std::make_unique<llvm::raw_fd_ostream>(
+ Filename, EC, llvm::sys::fs::OF_TextWithCRLF);
if (EC) {
D.Diag(clang::diag::err_drv_compilationdatabase) << Filename
<< EC.message();
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 284b20cb400a5..b2ec18d122fb4 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -277,7 +277,7 @@ static void SetUpDiagnosticLog(DiagnosticOptions *DiagOpts,
// Create the output stream.
auto FileOS = std::make_unique<llvm::raw_fd_ostream>(
DiagOpts->DiagnosticLogFile, EC,
- llvm::sys::fs::OF_Append | llvm::sys::fs::OF_Text);
+ llvm::sys::fs::OF_Append | llvm::sys::fs::OF_TextWithCRLF);
if (EC) {
Diags.Report(diag::warn_fe_cc_log_diagnostics_failure)
<< DiagOpts->DiagnosticLogFile << EC.message();
@@ -843,7 +843,7 @@ CompilerInstance::createOutputFileImpl(StringRef OutputPath, bool Binary,
std::error_code EC;
OS.reset(new llvm::raw_fd_ostream(
*OSFile, EC,
- (Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text)));
+ (Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_TextWithCRLF)));
if (EC)
return llvm::errorCodeToError(EC);
}
@@ -1001,7 +1001,7 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
if (!StatsFile.empty()) {
std::error_code EC;
auto StatS = std::make_unique<llvm::raw_fd_ostream>(
- StatsFile, EC, llvm::sys::fs::OF_Text);
+ StatsFile, EC, llvm::sys::fs::OF_TextWithCRLF);
if (EC) {
getDiagnostics().Report(diag::warn_fe_unable_to_open_stats_file)
<< StatsFile << EC.message();
diff --git a/clang/lib/Frontend/DependencyFile.cpp b/clang/lib/Frontend/DependencyFile.cpp
index 8bdda0c134c80..ccc7ed9d8d498 100644
--- a/clang/lib/Frontend/DependencyFile.cpp
+++ b/clang/lib/Frontend/DependencyFile.cpp
@@ -307,7 +307,7 @@ void DependencyFileGenerator::outputDependencyFile(DiagnosticsEngine &Diags) {
}
std::error_code EC;
- llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::OF_TextWithCRLF);
if (EC) {
Diags.Report(diag::err_fe_error_opening) << OutputFile << EC.message();
return;
diff --git a/clang/lib/Frontend/DependencyGraph.cpp b/clang/lib/Frontend/DependencyGraph.cpp
index 8a6e491def454..4bed4e2d44039 100644
--- a/clang/lib/Frontend/DependencyGraph.cpp
+++ b/clang/lib/Frontend/DependencyGraph.cpp
@@ -100,7 +100,7 @@ DependencyGraphCallback::writeNodeReference(raw_ostream &OS,
void DependencyGraphCallback::OutputGraphFile() {
std::error_code EC;
- llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::OF_TextWithCRLF);
if (EC) {
PP->getDiagnostics().Report(diag::err_fe_error_opening) << OutputFile
<< EC.message();
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index 0a84971c748cb..0237b8061ba4b 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -722,7 +722,7 @@ void DumpModuleInfoAction::ExecuteAction() {
if (!OutputFileName.empty() && OutputFileName != "-") {
std::error_code EC;
OutFile.reset(new llvm::raw_fd_ostream(OutputFileName.str(), EC,
- llvm::sys::fs::OF_Text));
+ llvm::sys::fs::OF_TextWithCRLF));
}
llvm::raw_ostream &Out = OutFile.get()? *OutFile.get() : llvm::outs();
diff --git a/clang/lib/Frontend/HeaderIncludeGen.cpp b/clang/lib/Frontend/HeaderIncludeGen.cpp
index cc2989a31df8e..df3f5345775a5 100644
--- a/clang/lib/Frontend/HeaderIncludeGen.cpp
+++ b/clang/lib/Frontend/HeaderIncludeGen.cpp
@@ -101,7 +101,7 @@ void clang::AttachHeaderIncludeGen(Preprocessor &PP,
std::error_code EC;
llvm::raw_fd_ostream *OS = new llvm::raw_fd_ostream(
OutputPath.str(), EC,
- llvm::sys::fs::OF_Append | llvm::sys::fs::OF_Text);
+ llvm::sys::fs::OF_Append | llvm::sys::fs::OF_TextWithCRLF);
if (EC) {
PP.getDiagnostics().Report(clang::diag::warn_fe_cc_print_header_failure)
<< EC.message();
diff --git a/clang/lib/Frontend/ModuleDependencyCollector.cpp b/clang/lib/Frontend/ModuleDependencyCollector.cpp
index 2e4e64f827b0c..4301e49f1d80d 100644
--- a/clang/lib/Frontend/ModuleDependencyCollector.cpp
+++ b/clang/lib/Frontend/ModuleDependencyCollector.cpp
@@ -148,7 +148,7 @@ void ModuleDependencyCollector::writeFileMap() {
std::error_code EC;
SmallString<256> YAMLPath = VFSDir;
llvm::sys::path::append(YAMLPath, "vfs.yaml");
- llvm::raw_fd_ostream OS(YAMLPath, EC, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream OS(YAMLPath, EC, llvm::sys::fs::OF_TextWithCRLF);
if (EC) {
HasErrors = true;
return;
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 06d3dc8d0a0db..a6f1aef42e914 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -4172,7 +4172,8 @@ static void updateModuleTimestamp(ModuleFile &MF) {
// Overwrite the timestamp file contents so that file's mtime changes.
std::string TimestampFilename = MF.getTimestampFilename();
std::error_code EC;
- llvm::raw_fd_ostream OS(TimestampFilename, EC, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream OS(TimestampFilename, EC,
+ llvm::sys::fs::OF_TextWithCRLF);
if (EC)
return;
OS << "Timestamp file\n";
diff --git a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
index 7e7fe75082bbb..92104d628711a 100644
--- a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -660,7 +660,7 @@ void PlistDiagnostics::FlushDiagnosticsImpl(
// Open the file.
std::error_code EC;
- llvm::raw_fd_ostream o(OutputFile, EC, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream o(OutputFile, EC, llvm::sys::fs::OF_TextWithCRLF);
if (EC) {
llvm::errs() << "warning: could not create file: " << EC.message() << '\n';
return;
diff --git a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
index ca41fc5b042aa..e1319a4c2e413 100644
--- a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
@@ -387,7 +387,7 @@ void SarifDiagnostics::FlushDiagnosticsImpl(
// file can become large very quickly, so decoding into JSON to append a run
// may be an expensive operation.
std::error_code EC;
- llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::OF_TextWithCRLF);
if (EC) {
llvm::errs() << "warning: could not create file: " << EC.message() << '\n';
return;
diff --git a/clang/tools/clang-refactor/ClangRefactor.cpp b/clang/tools/clang-refactor/ClangRefactor.cpp
index 0c82fd78c7826..01edad43164fb 100644
--- a/clang/tools/clang-refactor/ClangRefactor.cpp
+++ b/clang/tools/clang-refactor/ClangRefactor.cpp
@@ -499,7 +499,7 @@ class ClangRefactorTool {
if (opts::Inplace) {
std::error_code EC;
- llvm::raw_fd_ostream OS(File, EC, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream OS(File, EC, llvm::sys::fs::OF_TextWithCRLF);
if (EC) {
llvm::errs() << EC.message() << "\n";
return true;
diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp
index 84dfb4213a0ae..570e3e40ebdd9 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -324,7 +324,7 @@ getOutputStream(StringRef Path, DiagnosticsEngine &Diags, bool Binary) {
std::error_code EC;
auto Out = std::make_unique<raw_fd_ostream>(
- Path, EC, (Binary ? sys::fs::OF_None : sys::fs::OF_Text));
+ Path, EC, (Binary ? sys::fs::OF_None : sys::fs::OF_TextWithCRLF));
if (EC) {
Diags.Report(diag::err_fe_unable_to_open_output) << Path << EC.message();
return nullptr;
diff --git a/flang/lib/Frontend/CompilerInstance.cpp b/flang/lib/Frontend/CompilerInstance.cpp
index 6c6b0b7335a93..01eaed32ed9f8 100644
--- a/flang/lib/Frontend/CompilerInstance.cpp
+++ b/flang/lib/Frontend/CompilerInstance.cpp
@@ -112,7 +112,7 @@ std::unique_ptr<llvm::raw_pwrite_stream> CompilerInstance::CreateOutputFile(
if (!os) {
osFile = outputFilePath;
os.reset(new llvm::raw_fd_ostream(osFile, error,
- (binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text)));
+ (binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_TextWithCRLF)));
if (error)
return nullptr;
}
diff --git a/lld/COFF/DriverUtils.cpp b/lld/COFF/DriverUtils.cpp
index 1e8cbe8e2b172..4c791130771b1 100644
--- a/lld/COFF/DriverUtils.cpp
+++ b/lld/COFF/DriverUtils.cpp
@@ -414,7 +414,7 @@ static std::string createManifestXmlWithExternalMt(StringRef defaultXml) {
// Create the default manifest file as a temporary file.
TemporaryFile Default("defaultxml", "manifest");
std::error_code ec;
- raw_fd_ostream os(Default.path, ec, sys::fs::OF_Text);
+ raw_fd_ostream os(Default.path, ec, sys::fs::OF_TextWithCRLF);
if (ec)
fatal("failed to open " + Default.path + ": " + ec.message());
os << defaultXml;
@@ -516,7 +516,7 @@ void createSideBySideManifest() {
if (path == "")
path = config->outputFile + ".manifest";
std::error_code ec;
- raw_fd_ostream out(path, ec, sys::fs::OF_Text);
+ raw_fd_ostream out(path, ec, sys::fs::OF_TextWithCRLF);
if (ec)
fatal("failed to create manifest: " + ec.message());
out << createManifestXml();
diff --git a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
index 279ffe5e2505f..c0e6e0334fa6a 100644
--- a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
+++ b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
@@ -1299,7 +1299,7 @@ class Writer : public lld::Writer {
llvm::Error writeFile(const lld::File &file, StringRef outPath) override {
// Create stream to path.
std::error_code ec;
- llvm::raw_fd_ostream out(outPath, ec, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream out(outPath, ec, llvm::sys::fs::OF_TextWithCRLF);
if (ec)
return llvm::errorCodeToError(ec);
diff --git a/lldb/include/lldb/Utility/ReproducerProvider.h b/lldb/include/lldb/Utility/ReproducerProvider.h
index 221c0eb9c5bb0..db7378069a879 100644
--- a/lldb/include/lldb/Utility/ReproducerProvider.h
+++ b/lldb/include/lldb/Utility/ReproducerProvider.h
@@ -32,7 +32,8 @@ class AbstractRecorder {
protected:
AbstractRecorder(const FileSpec &filename, std::error_code &ec)
: m_filename(filename.GetFilename().GetStringRef()),
- m_os(filename.GetPath(), ec, llvm::sys::fs::OF_Text), m_record(true) {}
+ m_os(filename.GetPath(), ec, llvm::sys::fs::OF_TextWithCRLF),
+ m_record(true) {}
public:
const FileSpec &GetFilename() { return m_filename; }
@@ -168,7 +169,7 @@ template <typename T> class DirectoryProvider : public repro::Provider<T> {
void Keep() override {
FileSpec file = this->GetRoot().CopyByAppendingPathComponent(T::Info::file);
std::error_code ec;
- llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_TextWithCRLF);
if (ec)
return;
os << m_directory << "\n";
@@ -290,7 +291,7 @@ class MultiProvider : public repro::Provider<V> {
FileSpec file = this->GetRoot().CopyByAppendingPathComponent(V::Info::file);
std::error_code ec;
- llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_TextWithCRLF);
if (ec)
return;
llvm::yaml::Output yout(os);
diff --git a/lldb/source/Utility/GDBRemote.cpp b/lldb/source/Utility/GDBRemote.cpp
index f267d00fc97ea..40448257b9e09 100644
--- a/lldb/source/Utility/GDBRemote.cpp
+++ b/lldb/source/Utility/GDBRemote.cpp
@@ -104,7 +104,7 @@ void GDBRemoteProvider::Keep() {
FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
std::error_code ec;
- llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_TextWithCRLF);
if (ec)
return;
yaml::Output yout(os);
@@ -150,8 +150,8 @@ llvm::raw_ostream *GDBRemoteProvider::GetHistoryStream() {
FileSpec history_file = GetRoot().CopyByAppendingPathComponent(Info::file);
std::error_code EC;
- m_stream_up = std::make_unique<raw_fd_ostream>(history_file.GetPath(), EC,
- sys::fs::OpenFlags::OF_Text);
+ m_stream_up = std::make_unique<raw_fd_ostream>(
+ history_file.GetPath(), EC, sys::fs::OpenFlags::OF_TextWithCRLF);
return m_stream_up.get();
}
diff --git a/lldb/source/Utility/ReproducerProvider.cpp b/lldb/source/Utility/ReproducerProvider.cpp
index ed016820db212..5145819b717c7 100644
--- a/lldb/source/Utility/ReproducerProvider.cpp
+++ b/lldb/source/Utility/ReproducerProvider.cpp
@@ -39,7 +39,7 @@ YamlRecorder::Create(const FileSpec &filename) {
void VersionProvider::Keep() {
FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
std::error_code ec;
- llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_TextWithCRLF);
if (ec)
return;
os << m_version << "\n";
@@ -108,7 +108,7 @@ void ProcessInfoProvider::Keep() {
FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
std::error_code ec;
- llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_TextWithCRLF);
if (ec)
return;
llvm::yaml::Output yout(os);
@@ -153,7 +153,7 @@ void SymbolFileProvider::AddSymbolFile(const UUID *uuid,
void SymbolFileProvider::Keep() {
FileSpec file = this->GetRoot().CopyByAppendingPathComponent(Info::file);
std::error_code ec;
- llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_TextWithCRLF);
if (ec)
return;
diff --git a/lldb/tools/lldb-server/LLDBServerUtilities.cpp b/lldb/tools/lldb-server/LLDBServerUtilities.cpp
index 7f9271e36b68e..a427af4800f78 100644
--- a/lldb/tools/lldb-server/LLDBServerUtilities.cpp
+++ b/lldb/tools/lldb-server/LLDBServerUtilities.cpp
@@ -24,7 +24,7 @@ static std::shared_ptr<raw_ostream> GetLogStream(StringRef log_file) {
if (!log_file.empty()) {
std::error_code EC;
std::shared_ptr<raw_ostream> stream_sp = std::make_shared<raw_fd_ostream>(
- log_file, EC, sys::fs::OF_Text | sys::fs::OF_Append);
+ log_file, EC, sys::fs::OF_TextWithCRLF | sys::fs::OF_Append);
if (!EC)
return stream_sp;
errs() << llvm::formatv(
diff --git a/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h b/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
index ecf54cd8a680d..59737744f5767 100644
--- a/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
+++ b/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
@@ -97,7 +97,7 @@ class DOTGraphTraitsPrinter : public FunctionPass {
errs() << "Writing '" << Filename << "'...";
- raw_fd_ostream File(Filename, EC, sys::fs::OF_Text);
+ raw_fd_ostream File(Filename, EC, sys::fs::OF_TextWithCRLF);
std::string GraphName = DOTGraphTraits<GraphT>::getGraphName(Graph);
std::string Title = GraphName + " for '" + F.getName().str() + "' function";
@@ -160,7 +160,7 @@ class DOTGraphTraitsModulePrinter : public ModulePass {
errs() << "Writing '" << Filename << "'...";
- raw_fd_ostream File(Filename, EC, sys::fs::OF_Text);
+ raw_fd_ostream File(Filename, EC, sys::fs::OF_TextWithCRLF);
std::string Title = DOTGraphTraits<GraphT>::getGraphName(Graph);
if (!EC)
diff --git a/llvm/include/llvm/Support/FileSystem.h b/llvm/include/llvm/Support/FileSystem.h
index 1dc88243e8357..2ed7d87690cbb 100644
--- a/llvm/include/llvm/Support/FileSystem.h
+++ b/llvm/include/llvm/Support/FileSystem.h
@@ -742,24 +742,34 @@ enum OpenFlags : unsigned {
OF_None = 0,
F_None = 0, // For compatibility
- /// The file should be opened in text mode on platforms that make this
- /// distinction.
+ /// The file should be opened in text mode on platforms like z/OS that make
+ /// this distinction.
OF_Text = 1,
F_Text = 1, // For compatibility
+ /// The file should use a carriage linefeed '\r\n'. This flag should only be
+ /// used with OF_Text. Only makes a
diff erence on Windows.
+ OF_CRLF = 2,
+
+ /// The file should be opened in text mode and use a carriage linefeed '\r\n'.
+ /// This flag has the same functionality as OF_Text on z/OS but adds a
+ /// carriage linefeed on Windows.
+ OF_TextWithCRLF = OF_Text | OF_CRLF,
+
/// The file should be opened in append mode.
- OF_Append = 2,
- F_Append = 2, // For compatibility
+ OF_Append = 4,
+ F_Append = 4, // For compatibility
/// Delete the file on close. Only makes a
diff erence on windows.
- OF_Delete = 4,
+ OF_Delete = 8,
/// When a child process is launched, this file should remain open in the
/// child process.
- OF_ChildInherit = 8,
+ OF_ChildInherit = 16,
- /// Force files Atime to be updated on access. Only makes a
diff erence on windows.
- OF_UpdateAtime = 16,
+ /// Force files Atime to be updated on access. Only makes a
diff erence on
+ /// Windows.
+ OF_UpdateAtime = 32,
};
/// Create a potentially unique file name but does not create it.
diff --git a/llvm/lib/CodeGen/RegAllocPBQP.cpp b/llvm/lib/CodeGen/RegAllocPBQP.cpp
index 763505c04fb36..b22eb080791ee 100644
--- a/llvm/lib/CodeGen/RegAllocPBQP.cpp
+++ b/llvm/lib/CodeGen/RegAllocPBQP.cpp
@@ -859,7 +859,7 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) {
std::string GraphFileName = FullyQualifiedName + "." + RS.str() +
".pbqpgraph";
std::error_code EC;
- raw_fd_ostream OS(GraphFileName, EC, sys::fs::OF_Text);
+ raw_fd_ostream OS(GraphFileName, EC, sys::fs::OF_TextWithCRLF);
LLVM_DEBUG(dbgs() << "Dumping graph for round " << Round << " to \""
<< GraphFileName << "\"\n");
G.dump(OS);
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 2d93d50b88995..d597a69dbd537 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -412,7 +412,7 @@ void LLVMDumpModule(LLVMModuleRef M) {
LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
char **ErrorMessage) {
std::error_code EC;
- raw_fd_ostream dest(Filename, EC, sys::fs::OF_Text);
+ raw_fd_ostream dest(Filename, EC, sys::fs::OF_TextWithCRLF);
if (EC) {
*ErrorMessage = strdup(EC.message().c_str());
return true;
diff --git a/llvm/lib/IR/LLVMRemarkStreamer.cpp b/llvm/lib/IR/LLVMRemarkStreamer.cpp
index 18b47611c97cd..21ce47457f528 100644
--- a/llvm/lib/IR/LLVMRemarkStreamer.cpp
+++ b/llvm/lib/IR/LLVMRemarkStreamer.cpp
@@ -106,7 +106,7 @@ Expected<std::unique_ptr<ToolOutputFile>> llvm::setupLLVMOptimizationRemarks(
return make_error<LLVMRemarkSetupFormatError>(std::move(E));
std::error_code EC;
- auto Flags = *Format == remarks::Format::YAML ? sys::fs::OF_Text
+ auto Flags = *Format == remarks::Format::YAML ? sys::fs::OF_TextWithCRLF
: sys::fs::OF_None;
auto RemarksFile =
std::make_unique<ToolOutputFile>(RemarksFilename, EC, Flags);
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 34d1c9317e095..8a03a4fa89a97 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -85,8 +85,9 @@ Error Config::addSaveTemps(std::string OutputFileName,
ShouldDiscardValueNames = false;
std::error_code EC;
- ResolutionFile = std::make_unique<raw_fd_ostream>(
- OutputFileName + "resolution.txt", EC, sys::fs::OpenFlags::OF_Text);
+ ResolutionFile =
+ std::make_unique<raw_fd_ostream>(OutputFileName + "resolution.txt", EC,
+ sys::fs::OpenFlags::OF_TextWithCRLF);
if (EC) {
ResolutionFile.reset();
return errorCodeToError(EC);
diff --git a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
index f56013869a6db..26c814d0ab0e8 100644
--- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
@@ -776,8 +776,9 @@ bool DarwinAsmParser::parseDirectiveSecureLogUnique(StringRef, SMLoc IDLoc) {
raw_fd_ostream *OS = getContext().getSecureLog();
if (!OS) {
std::error_code EC;
- auto NewOS = std::make_unique<raw_fd_ostream>(
- StringRef(SecureLogFile), EC, sys::fs::OF_Append | sys::fs::OF_Text);
+ auto NewOS = std::make_unique<raw_fd_ostream>(StringRef(SecureLogFile), EC,
+ sys::fs::OF_Append |
+ sys::fs::OF_TextWithCRLF);
if (EC)
return Error(IDLoc, Twine("can't open secure log file: ") +
SecureLogFile + " (" + EC.message() + ")");
diff --git a/llvm/lib/ProfileData/GCOV.cpp b/llvm/lib/ProfileData/GCOV.cpp
index f24c4b0cf9b5b..9978af061cd99 100644
--- a/llvm/lib/ProfileData/GCOV.cpp
+++ b/llvm/lib/ProfileData/GCOV.cpp
@@ -866,7 +866,7 @@ void Context::print(StringRef filename, StringRef gcno, StringRef gcda,
Optional<raw_fd_ostream> os;
if (!options.UseStdout) {
std::error_code ec;
- os.emplace(gcovName, ec, sys::fs::OF_Text);
+ os.emplace(gcovName, ec, sys::fs::OF_TextWithCRLF);
if (ec) {
errs() << ec.message() << '\n';
continue;
@@ -881,7 +881,7 @@ void Context::print(StringRef filename, StringRef gcno, StringRef gcda,
// (PR GCC/82702). We create just one file.
std::string outputPath(sys::path::filename(filename));
std::error_code ec;
- raw_fd_ostream os(outputPath + ".gcov", ec, sys::fs::OF_Text);
+ raw_fd_ostream os(outputPath + ".gcov", ec, sys::fs::OF_TextWithCRLF);
if (ec) {
errs() << ec.message() << '\n';
return;
diff --git a/llvm/lib/ProfileData/SampleProfWriter.cpp b/llvm/lib/ProfileData/SampleProfWriter.cpp
index b9643480a8e4d..d32fcbf7912ef 100644
--- a/llvm/lib/ProfileData/SampleProfWriter.cpp
+++ b/llvm/lib/ProfileData/SampleProfWriter.cpp
@@ -728,7 +728,7 @@ SampleProfileWriter::create(StringRef Filename, SampleProfileFormat Format) {
Format == SPF_Compact_Binary)
OS.reset(new raw_fd_ostream(Filename, EC, sys::fs::OF_None));
else
- OS.reset(new raw_fd_ostream(Filename, EC, sys::fs::OF_Text));
+ OS.reset(new raw_fd_ostream(Filename, EC, sys::fs::OF_TextWithCRLF));
if (EC)
return EC;
diff --git a/llvm/lib/Support/FileCollector.cpp b/llvm/lib/Support/FileCollector.cpp
index 7d23d036fac25..5854baeebbb97 100644
--- a/llvm/lib/Support/FileCollector.cpp
+++ b/llvm/lib/Support/FileCollector.cpp
@@ -241,7 +241,7 @@ std::error_code FileCollector::writeMapping(StringRef MappingFile) {
VFSWriter.setUseExternalNames(false);
std::error_code EC;
- raw_fd_ostream os(MappingFile, EC, sys::fs::OF_Text);
+ raw_fd_ostream os(MappingFile, EC, sys::fs::OF_TextWithCRLF);
if (EC)
return EC;
diff --git a/llvm/lib/Support/MemoryBuffer.cpp b/llvm/lib/Support/MemoryBuffer.cpp
index 1d75f0be1ca62..dbdf41f255ebc 100644
--- a/llvm/lib/Support/MemoryBuffer.cpp
+++ b/llvm/lib/Support/MemoryBuffer.cpp
@@ -259,7 +259,7 @@ static ErrorOr<std::unique_ptr<MB>>
getFileAux(const Twine &Filename, uint64_t MapSize, uint64_t Offset,
bool IsText, bool RequiresNullTerminator, bool IsVolatile) {
Expected<sys::fs::file_t> FDOrErr = sys::fs::openNativeFileForRead(
- Filename, IsText ? sys::fs::OF_Text : sys::fs::OF_None);
+ Filename, IsText ? sys::fs::OF_TextWithCRLF : sys::fs::OF_None);
if (!FDOrErr)
return errorToErrorCode(FDOrErr.takeError());
sys::fs::file_t FD = *FDOrErr;
diff --git a/llvm/lib/Support/TimeProfiler.cpp b/llvm/lib/Support/TimeProfiler.cpp
index 93bf6f57e3480..c37c74c61f3ce 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -304,7 +304,7 @@ Error llvm::timeTraceProfilerWrite(StringRef PreferredFileName,
}
std::error_code EC;
- raw_fd_ostream OS(Path, EC, sys::fs::OF_Text);
+ raw_fd_ostream OS(Path, EC, sys::fs::OF_TextWithCRLF);
if (EC)
return createStringError(EC, "Could not open " + Path);
diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp
index a959cf35ec21f..6e592dbc0ba1a 100644
--- a/llvm/lib/Support/Timer.cpp
+++ b/llvm/lib/Support/Timer.cpp
@@ -82,7 +82,7 @@ std::unique_ptr<raw_fd_ostream> llvm::CreateInfoOutputFile() {
// info output file before running commands which write to it.
std::error_code EC;
auto Result = std::make_unique<raw_fd_ostream>(
- OutputFilename, EC, sys::fs::OF_Append | sys::fs::OF_Text);
+ OutputFilename, EC, sys::fs::OF_Append | sys::fs::OF_TextWithCRLF);
if (!EC)
return Result;
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index 679ba536c99ec..3f18d89fbdefc 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -507,7 +507,7 @@ std::error_code
llvm::sys::writeFileWithEncoding(StringRef FileName, StringRef Contents,
WindowsEncodingMethod Encoding /*unused*/) {
std::error_code EC;
- llvm::raw_fd_ostream OS(FileName, EC, llvm::sys::fs::OpenFlags::OF_Text);
+ llvm::raw_fd_ostream OS(FileName, EC, llvm::sys::fs::OpenFlags::OF_TextWithCRLF);
if (EC)
return EC;
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index e2bd7da4f04bf..4a6d4a4cd1b08 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -1083,8 +1083,10 @@ static std::error_code nativeFileToFd(Expected<HANDLE> H, int &ResultFD,
if (Flags & OF_Append)
CrtOpenFlags |= _O_APPEND;
- if (Flags & OF_Text)
+ if (Flags & OF_CRLF) {
+ assert(Flags & OF_Text && "Flags set OF_CRLF without OF_Text");
CrtOpenFlags |= _O_TEXT;
+ }
ResultFD = -1;
if (!H)
diff --git a/llvm/lib/Support/Windows/Program.inc b/llvm/lib/Support/Windows/Program.inc
index 687109c01355e..92a607180c351 100644
--- a/llvm/lib/Support/Windows/Program.inc
+++ b/llvm/lib/Support/Windows/Program.inc
@@ -506,7 +506,7 @@ std::error_code
llvm::sys::writeFileWithEncoding(StringRef FileName, StringRef Contents,
WindowsEncodingMethod Encoding) {
std::error_code EC;
- llvm::raw_fd_ostream OS(FileName, EC, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream OS(FileName, EC, llvm::sys::fs::OF_TextWithCRLF);
if (EC)
return EC;
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index eef780d29704c..0223ff97ac9a8 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -2413,7 +2413,7 @@ void AADepGraph::dumpGraph() {
std::error_code EC;
- raw_fd_ostream File(Filename, EC, sys::fs::OF_Text);
+ raw_fd_ostream File(Filename, EC, sys::fs::OF_TextWithCRLF);
if (!EC)
llvm::WriteGraph(File, this);
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index 804d1065a5e11..9204bec38239f 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -1722,7 +1722,7 @@ bool LowerTypeTestsModule::runForTesting(Module &M) {
ExitOnError ExitOnErr("-lowertypetests-write-summary: " + ClWriteSummary +
": ");
std::error_code EC;
- raw_fd_ostream OS(ClWriteSummary, EC, sys::fs::OF_Text);
+ raw_fd_ostream OS(ClWriteSummary, EC, sys::fs::OF_TextWithCRLF);
ExitOnErr(errorCodeToError(EC));
yaml::Output Out(OS);
diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index 6fe3116f6fc61..ee79bb2a310d5 100644
--- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -918,7 +918,7 @@ bool DevirtModule::runForTesting(
ExitOnErr(errorCodeToError(EC));
WriteIndexToFile(*Summary, OS);
} else {
- raw_fd_ostream OS(ClWriteSummary, EC, sys::fs::OF_Text);
+ raw_fd_ostream OS(ClWriteSummary, EC, sys::fs::OF_TextWithCRLF);
ExitOnErr(errorCodeToError(EC));
yaml::Output Out(OS);
Out << *Summary;
diff --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp
index 73a3a4063f6b5..a9c07c2973993 100644
--- a/llvm/lib/Transforms/Utils/Debugify.cpp
+++ b/llvm/lib/Transforms/Utils/Debugify.cpp
@@ -440,7 +440,7 @@ static void writeJSON(StringRef OrigDIVerifyBugsReportFilePath,
llvm::json::Array &Bugs) {
std::error_code EC;
raw_fd_ostream OS_FILE{OrigDIVerifyBugsReportFilePath, EC,
- sys::fs::OF_Append | sys::fs::OF_Text};
+ sys::fs::OF_Append | sys::fs::OF_TextWithCRLF};
if (EC) {
errs() << "Could not open file: " << EC.message() << ", "
<< OrigDIVerifyBugsReportFilePath << '\n';
diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp
index 347b2dd91668c..27681fae3ca7a 100644
--- a/llvm/tools/dsymutil/dsymutil.cpp
+++ b/llvm/tools/dsymutil/dsymutil.cpp
@@ -312,7 +312,7 @@ static Error createPlistFile(StringRef Bin, StringRef BundleRoot,
SmallString<128> InfoPlist(BundleRoot);
sys::path::append(InfoPlist, "Contents/Info.plist");
std::error_code EC;
- raw_fd_ostream PL(InfoPlist, EC, sys::fs::OF_Text);
+ raw_fd_ostream PL(InfoPlist, EC, sys::fs::OF_TextWithCRLF);
if (EC)
return make_error<StringError>(
"cannot create Plist: " + toString(errorCodeToError(EC)), EC);
diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index 2e8865a98b467..f685fb8aa3e10 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -276,7 +276,7 @@ static std::unique_ptr<ToolOutputFile> GetOutputStream(const char *TargetName,
std::error_code EC;
sys::fs::OpenFlags OpenFlags = sys::fs::OF_None;
if (!Binary)
- OpenFlags |= sys::fs::OF_Text;
+ OpenFlags |= sys::fs::OF_TextWithCRLF;
auto FDOut = std::make_unique<ToolOutputFile>(OutputFilename, EC, OpenFlags);
if (EC) {
reportError(EC.message());
diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index ced1e2a6d629a..a15b0ddc512bc 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -791,7 +791,8 @@ static std::function<void(Module &)> createDebugDumper() {
case DumpKind::DumpModsToDisk:
return [](Module &M) {
std::error_code EC;
- raw_fd_ostream Out(M.getModuleIdentifier() + ".ll", EC, sys::fs::OF_Text);
+ raw_fd_ostream Out(M.getModuleIdentifier() + ".ll", EC,
+ sys::fs::OF_TextWithCRLF);
if (EC) {
errs() << "Couldn't open " << M.getModuleIdentifier()
<< " for dumping.\nError:" << EC.message() << "\n";
diff --git a/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp b/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
index b53a6364c89e5..f87c0169e7516 100644
--- a/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
+++ b/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
@@ -145,7 +145,7 @@ int main(int argc, const char *argv[]) {
exitWithErrorCode(RemappingBufOrError.getError(), RemappingFile);
std::error_code EC;
- raw_fd_ostream OS(OutputFilename.data(), EC, sys::fs::OF_Text);
+ raw_fd_ostream OS(OutputFilename.data(), EC, sys::fs::OF_TextWithCRLF);
if (EC)
exitWithErrorCode(EC, OutputFilename);
diff --git a/llvm/tools/llvm-dis/llvm-dis.cpp b/llvm/tools/llvm-dis/llvm-dis.cpp
index 5d609468a380b..2dcdbf0cf29e8 100644
--- a/llvm/tools/llvm-dis/llvm-dis.cpp
+++ b/llvm/tools/llvm-dis/llvm-dis.cpp
@@ -203,7 +203,7 @@ int main(int argc, char **argv) {
std::error_code EC;
std::unique_ptr<ToolOutputFile> Out(
- new ToolOutputFile(FinalFilename, EC, sys::fs::OF_Text));
+ new ToolOutputFile(FinalFilename, EC, sys::fs::OF_TextWithCRLF));
if (EC) {
errs() << EC.message() << '\n';
return 1;
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index 4322f125a84d8..642e452ce0e64 100644
--- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -628,7 +628,7 @@ int main(int argc, char **argv) {
}
std::error_code EC;
- ToolOutputFile OutputFile(OutputFilename, EC, sys::fs::OF_Text);
+ ToolOutputFile OutputFile(OutputFilename, EC, sys::fs::OF_TextWithCRLF);
error("Unable to open output file" + OutputFilename, EC);
// Don't remove output file if we exit with an error.
OutputFile.keep();
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
index 819a062e9b6af..d86ab475cb9a8 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -401,8 +401,9 @@ Error InstructionBenchmark::writeYaml(const LLVMState &State,
return Err;
} else {
int ResultFD = 0;
- if (auto E = errorCodeToError(openFileForWrite(
- Filename, ResultFD, sys::fs::CD_CreateAlways, sys::fs::OF_Text))) {
+ if (auto E = errorCodeToError(openFileForWrite(Filename, ResultFD,
+ sys::fs::CD_CreateAlways,
+ sys::fs::OF_TextWithCRLF))) {
return E;
}
raw_fd_ostream Ostr(ResultFD, true /*shouldClose*/);
diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp
index 846532ec6df99..dde82382384a5 100644
--- a/llvm/tools/llvm-link/llvm-link.cpp
+++ b/llvm/tools/llvm-link/llvm-link.cpp
@@ -468,7 +468,8 @@ int main(int argc, char **argv) {
std::error_code EC;
ToolOutputFile Out(OutputFilename, EC,
- OutputAssembly ? sys::fs::OF_Text : sys::fs::OF_None);
+ OutputAssembly ? sys::fs::OF_TextWithCRLF
+ : sys::fs::OF_None);
if (EC) {
WithColor::error() << EC.message() << '\n';
return 1;
diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp
index 5c88428f436cc..017d6a4e89a3c 100644
--- a/llvm/tools/llvm-mc/llvm-mc.cpp
+++ b/llvm/tools/llvm-mc/llvm-mc.cpp
@@ -452,8 +452,9 @@ int main(int argc, char **argv) {
FeaturesStr = Features.getString();
}
- sys::fs::OpenFlags Flags = (FileType == OFT_AssemblyFile) ? sys::fs::OF_Text
- : sys::fs::OF_None;
+ sys::fs::OpenFlags Flags = (FileType == OFT_AssemblyFile)
+ ? sys::fs::OF_TextWithCRLF
+ : sys::fs::OF_None;
std::unique_ptr<ToolOutputFile> Out = GetOutputStream(OutputFilename, Flags);
if (!Out)
return 1;
diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp
index 0e0a39883f93a..53c582af477bc 100644
--- a/llvm/tools/llvm-mca/llvm-mca.cpp
+++ b/llvm/tools/llvm-mca/llvm-mca.cpp
@@ -244,8 +244,8 @@ ErrorOr<std::unique_ptr<ToolOutputFile>> getOutputStream() {
if (OutputFilename == "")
OutputFilename = "-";
std::error_code EC;
- auto Out =
- std::make_unique<ToolOutputFile>(OutputFilename, EC, sys::fs::OF_Text);
+ auto Out = std::make_unique<ToolOutputFile>(OutputFilename, EC,
+ sys::fs::OF_TextWithCRLF);
if (!EC)
return std::move(Out);
return EC;
diff --git a/llvm/tools/llvm-opt-report/OptReport.cpp b/llvm/tools/llvm-opt-report/OptReport.cpp
index 8d7ecfb2d01b8..c47212de8837c 100644
--- a/llvm/tools/llvm-opt-report/OptReport.cpp
+++ b/llvm/tools/llvm-opt-report/OptReport.cpp
@@ -247,7 +247,7 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) {
static bool writeReport(LocationInfoTy &LocationInfo) {
std::error_code EC;
- llvm::raw_fd_ostream OS(OutputFileName, EC, llvm::sys::fs::OF_Text);
+ llvm::raw_fd_ostream OS(OutputFileName, EC, llvm::sys::fs::OF_TextWithCRLF);
if (EC) {
WithColor::error() << "Can't open file " << OutputFileName << ": "
<< EC.message() << "\n";
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 4f919b06ff20d..f274f5a911066 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -306,7 +306,7 @@ static void writeInstrProfile(StringRef OutputFilename,
InstrProfWriter &Writer) {
std::error_code EC;
raw_fd_ostream Output(OutputFilename.data(), EC,
- OutputFormat == PF_Text ? sys::fs::OF_Text
+ OutputFormat == PF_Text ? sys::fs::OF_TextWithCRLF
: sys::fs::OF_None);
if (EC)
exitWithErrorCode(EC, OutputFilename);
@@ -1931,7 +1931,7 @@ static int overlap_main(int argc, const char *argv[]) {
cl::ParseCommandLineOptions(argc, argv, "LLVM profile data overlap tool\n");
std::error_code EC;
- raw_fd_ostream OS(Output.data(), EC, sys::fs::OF_Text);
+ raw_fd_ostream OS(Output.data(), EC, sys::fs::OF_TextWithCRLF);
if (EC)
exitWithErrorCode(EC, Output);
@@ -2457,7 +2457,7 @@ static int show_main(int argc, const char *argv[]) {
}
std::error_code EC;
- raw_fd_ostream OS(OutputFilename.data(), EC, sys::fs::OF_Text);
+ raw_fd_ostream OS(OutputFilename.data(), EC, sys::fs::OF_TextWithCRLF);
if (EC)
exitWithErrorCode(EC, OutputFilename);
diff --git a/llvm/tools/llvm-xray/xray-account.cpp b/llvm/tools/llvm-xray/xray-account.cpp
index bde028a432fed..111704665c0b7 100644
--- a/llvm/tools/llvm-xray/xray-account.cpp
+++ b/llvm/tools/llvm-xray/xray-account.cpp
@@ -459,7 +459,7 @@ static CommandRegistration Unused(&Account, []() -> Error {
}
std::error_code EC;
- raw_fd_ostream OS(AccountOutput, EC, sys::fs::OpenFlags::OF_Text);
+ raw_fd_ostream OS(AccountOutput, EC, sys::fs::OpenFlags::OF_TextWithCRLF);
if (EC)
return make_error<StringError>(
Twine("Cannot open file '") + AccountOutput + "' for writing.", EC);
diff --git a/llvm/tools/llvm-xray/xray-converter.cpp b/llvm/tools/llvm-xray/xray-converter.cpp
index 645e2e3d71992..47cb645a54088 100644
--- a/llvm/tools/llvm-xray/xray-converter.cpp
+++ b/llvm/tools/llvm-xray/xray-converter.cpp
@@ -381,7 +381,7 @@ static CommandRegistration Unused(&Convert, []() -> Error {
raw_fd_ostream OS(ConvertOutput, EC,
ConvertOutputFormat == ConvertFormats::BINARY
? sys::fs::OpenFlags::OF_None
- : sys::fs::OpenFlags::OF_Text);
+ : sys::fs::OpenFlags::OF_TextWithCRLF);
if (EC)
return make_error<StringError>(
Twine("Cannot open file '") + ConvertOutput + "' for writing.", EC);
diff --git a/llvm/tools/llvm-xray/xray-extract.cpp b/llvm/tools/llvm-xray/xray-extract.cpp
index 8304d2d27afa3..a6ffacc6ab925 100644
--- a/llvm/tools/llvm-xray/xray-extract.cpp
+++ b/llvm/tools/llvm-xray/xray-extract.cpp
@@ -83,7 +83,7 @@ static CommandRegistration Unused(&Extract, []() -> Error {
InstrumentationMapOrError.takeError());
std::error_code EC;
- raw_fd_ostream OS(ExtractOutput, EC, sys::fs::OpenFlags::OF_Text);
+ raw_fd_ostream OS(ExtractOutput, EC, sys::fs::OpenFlags::OF_TextWithCRLF);
if (EC)
return make_error<StringError>(
Twine("Cannot open file '") + ExtractOutput + "' for writing.", EC);
diff --git a/llvm/tools/llvm-xray/xray-graph-
diff .cpp b/llvm/tools/llvm-xray/xray-graph-
diff .cpp
index 9ff84f22d8245..f22ea06e0537b 100644
--- a/llvm/tools/llvm-xray/xray-graph-
diff .cpp
+++ b/llvm/tools/llvm-xray/xray-graph-
diff .cpp
@@ -456,7 +456,7 @@ static CommandRegistration Unused(&GraphDiff, []() -> Error {
auto &GDR = *GDROrErr;
std::error_code EC;
- raw_fd_ostream OS(GraphDiffOutput, EC, sys::fs::OpenFlags::OF_Text);
+ raw_fd_ostream OS(GraphDiffOutput, EC, sys::fs::OpenFlags::OF_TextWithCRLF);
if (EC)
return make_error<StringError>(
Twine("Cannot open file '") + GraphDiffOutput + "' for writing.", EC);
diff --git a/llvm/tools/llvm-xray/xray-graph.cpp b/llvm/tools/llvm-xray/xray-graph.cpp
index 00a1807c07c9d..39d2c5c153ef1 100644
--- a/llvm/tools/llvm-xray/xray-graph.cpp
+++ b/llvm/tools/llvm-xray/xray-graph.cpp
@@ -523,7 +523,7 @@ static CommandRegistration Unused(&GraphC, []() -> Error {
auto &GR = *GROrError;
std::error_code EC;
- raw_fd_ostream OS(GraphOutput, EC, sys::fs::OpenFlags::OF_Text);
+ raw_fd_ostream OS(GraphOutput, EC, sys::fs::OpenFlags::OF_TextWithCRLF);
if (EC)
return make_error<StringError>(
Twine("Cannot open file '") + GraphOutput + "' for writing.", EC);
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 83b7391c0bf01..bb0d6b962048a 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -700,8 +700,8 @@ int main(int argc, char **argv) {
OutputFilename = "-";
std::error_code EC;
- sys::fs::OpenFlags Flags = OutputAssembly ? sys::fs::OF_Text
- : sys::fs::OF_None;
+ sys::fs::OpenFlags Flags =
+ OutputAssembly ? sys::fs::OF_TextWithCRLF : sys::fs::OF_None;
Out.reset(new ToolOutputFile(OutputFilename, EC, Flags));
if (EC) {
errs() << EC.message() << '\n';
diff --git a/llvm/tools/verify-uselistorder/verify-uselistorder.cpp b/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
index cbd2f85ec3e0b..28d3467d71503 100644
--- a/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ b/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -136,7 +136,7 @@ bool TempFile::writeBitcode(const Module &M) const {
bool TempFile::writeAssembly(const Module &M) const {
LLVM_DEBUG(dbgs() << " - write assembly\n");
std::error_code EC;
- raw_fd_ostream OS(Filename, EC, sys::fs::OF_Text);
+ raw_fd_ostream OS(Filename, EC, sys::fs::OF_TextWithCRLF);
if (EC) {
errs() << "verify-uselistorder: error: " << EC.message() << "\n";
return true;
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index 73f0cbbaae38e..35b41092fddaa 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -1253,7 +1253,7 @@ TEST_F(FileSystemTest, CarriageReturn) {
path::append(FilePathname, "test");
{
- raw_fd_ostream File(FilePathname, EC, sys::fs::OF_Text);
+ raw_fd_ostream File(FilePathname, EC, sys::fs::OF_TextWithCRLF);
ASSERT_NO_ERROR(EC);
File << '\n';
}
diff --git a/polly/lib/Exchange/JSONExporter.cpp b/polly/lib/Exchange/JSONExporter.cpp
index 3f54bce141d73..453daef72f2d9 100644
--- a/polly/lib/Exchange/JSONExporter.cpp
+++ b/polly/lib/Exchange/JSONExporter.cpp
@@ -178,7 +178,7 @@ static void exportScop(Scop &S) {
// Write to file.
std::error_code EC;
- ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_Text);
+ ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_TextWithCRLF);
std::string FunctionName = S.getFunction().getName().str();
errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
More information about the flang-commits
mailing list