[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
This commit is contained in:
parent
65c22acfa4
commit
82b3e28e83
|
|
@ -30,7 +30,8 @@ namespace {
|
||||||
std::error_code CreateNewFile(const llvm::Twine &path) {
|
std::error_code CreateNewFile(const llvm::Twine &path) {
|
||||||
int fd = 0;
|
int fd = 0;
|
||||||
if (std::error_code ec = llvm::sys::fs::openFileForWrite(
|
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 ec;
|
||||||
|
|
||||||
return llvm::sys::Process::SafelyCloseFileDescriptor(fd);
|
return llvm::sys::Process::SafelyCloseFileDescriptor(fd);
|
||||||
|
|
|
||||||
|
|
@ -268,7 +268,7 @@ static bool writeModuleMap(llvm::StringRef ModuleMapPath,
|
||||||
|
|
||||||
// Set up module map output file.
|
// Set up module map output file.
|
||||||
std::error_code EC;
|
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) {
|
if (EC) {
|
||||||
llvm::errs() << Argv0 << ": error opening " << FilePath << ":"
|
llvm::errs() << Argv0 << ": error opening " << FilePath << ":"
|
||||||
<< EC.message() << "\n";
|
<< EC.message() << "\n";
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ int main(int argc, const char **argv) {
|
||||||
OptionsParser->getSourcePathList());
|
OptionsParser->getSourcePathList());
|
||||||
|
|
||||||
std::error_code EC;
|
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)
|
if (EC)
|
||||||
error(EC.message());
|
error(EC.message());
|
||||||
PPTraceFrontendActionFactory Factory(Filters, Out.os());
|
PPTraceFrontendActionFactory Factory(Filters, Out.os());
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ void arcmt::writeARCDiagsToPlist(const std::string &outPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::error_code EC;
|
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) {
|
if (EC) {
|
||||||
llvm::errs() << "error: could not create file: " << outPath << '\n';
|
llvm::errs() << "error: could not create file: " << outPath << '\n';
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ int Compilation::ExecuteCommand(const Command &C,
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
OwnedStream.reset(new llvm::raw_fd_ostream(
|
OwnedStream.reset(new llvm::raw_fd_ostream(
|
||||||
getDriver().CCPrintOptionsFilename.c_str(), EC,
|
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) {
|
if (EC) {
|
||||||
getDriver().Diag(diag::err_drv_cc_print_options_failure)
|
getDriver().Diag(diag::err_drv_cc_print_options_failure)
|
||||||
<< EC.message();
|
<< EC.message();
|
||||||
|
|
|
||||||
|
|
@ -2264,8 +2264,8 @@ void Clang::DumpCompilationDatabase(Compilation &C, StringRef Filename,
|
||||||
|
|
||||||
if (!CompilationDatabase) {
|
if (!CompilationDatabase) {
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
auto File = std::make_unique<llvm::raw_fd_ostream>(Filename, EC,
|
auto File = std::make_unique<llvm::raw_fd_ostream>(
|
||||||
llvm::sys::fs::OF_Text);
|
Filename, EC, llvm::sys::fs::OF_TextWithCRLF);
|
||||||
if (EC) {
|
if (EC) {
|
||||||
D.Diag(clang::diag::err_drv_compilationdatabase) << Filename
|
D.Diag(clang::diag::err_drv_compilationdatabase) << Filename
|
||||||
<< EC.message();
|
<< EC.message();
|
||||||
|
|
|
||||||
|
|
@ -277,7 +277,7 @@ static void SetUpDiagnosticLog(DiagnosticOptions *DiagOpts,
|
||||||
// Create the output stream.
|
// Create the output stream.
|
||||||
auto FileOS = std::make_unique<llvm::raw_fd_ostream>(
|
auto FileOS = std::make_unique<llvm::raw_fd_ostream>(
|
||||||
DiagOpts->DiagnosticLogFile, EC,
|
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) {
|
if (EC) {
|
||||||
Diags.Report(diag::warn_fe_cc_log_diagnostics_failure)
|
Diags.Report(diag::warn_fe_cc_log_diagnostics_failure)
|
||||||
<< DiagOpts->DiagnosticLogFile << EC.message();
|
<< DiagOpts->DiagnosticLogFile << EC.message();
|
||||||
|
|
@ -843,7 +843,7 @@ CompilerInstance::createOutputFileImpl(StringRef OutputPath, bool Binary,
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
OS.reset(new llvm::raw_fd_ostream(
|
OS.reset(new llvm::raw_fd_ostream(
|
||||||
*OSFile, EC,
|
*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)
|
if (EC)
|
||||||
return llvm::errorCodeToError(EC);
|
return llvm::errorCodeToError(EC);
|
||||||
}
|
}
|
||||||
|
|
@ -1001,7 +1001,7 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
|
||||||
if (!StatsFile.empty()) {
|
if (!StatsFile.empty()) {
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
auto StatS = std::make_unique<llvm::raw_fd_ostream>(
|
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) {
|
if (EC) {
|
||||||
getDiagnostics().Report(diag::warn_fe_unable_to_open_stats_file)
|
getDiagnostics().Report(diag::warn_fe_unable_to_open_stats_file)
|
||||||
<< StatsFile << EC.message();
|
<< StatsFile << EC.message();
|
||||||
|
|
|
||||||
|
|
@ -307,7 +307,7 @@ void DependencyFileGenerator::outputDependencyFile(DiagnosticsEngine &Diags) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::error_code EC;
|
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) {
|
if (EC) {
|
||||||
Diags.Report(diag::err_fe_error_opening) << OutputFile << EC.message();
|
Diags.Report(diag::err_fe_error_opening) << OutputFile << EC.message();
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ DependencyGraphCallback::writeNodeReference(raw_ostream &OS,
|
||||||
|
|
||||||
void DependencyGraphCallback::OutputGraphFile() {
|
void DependencyGraphCallback::OutputGraphFile() {
|
||||||
std::error_code EC;
|
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) {
|
if (EC) {
|
||||||
PP->getDiagnostics().Report(diag::err_fe_error_opening) << OutputFile
|
PP->getDiagnostics().Report(diag::err_fe_error_opening) << OutputFile
|
||||||
<< EC.message();
|
<< EC.message();
|
||||||
|
|
|
||||||
|
|
@ -722,7 +722,7 @@ void DumpModuleInfoAction::ExecuteAction() {
|
||||||
if (!OutputFileName.empty() && OutputFileName != "-") {
|
if (!OutputFileName.empty() && OutputFileName != "-") {
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
OutFile.reset(new llvm::raw_fd_ostream(OutputFileName.str(), 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();
|
llvm::raw_ostream &Out = OutFile.get()? *OutFile.get() : llvm::outs();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ void clang::AttachHeaderIncludeGen(Preprocessor &PP,
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
llvm::raw_fd_ostream *OS = new llvm::raw_fd_ostream(
|
llvm::raw_fd_ostream *OS = new llvm::raw_fd_ostream(
|
||||||
OutputPath.str(), EC,
|
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) {
|
if (EC) {
|
||||||
PP.getDiagnostics().Report(clang::diag::warn_fe_cc_print_header_failure)
|
PP.getDiagnostics().Report(clang::diag::warn_fe_cc_print_header_failure)
|
||||||
<< EC.message();
|
<< EC.message();
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ void ModuleDependencyCollector::writeFileMap() {
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
SmallString<256> YAMLPath = VFSDir;
|
SmallString<256> YAMLPath = VFSDir;
|
||||||
llvm::sys::path::append(YAMLPath, "vfs.yaml");
|
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) {
|
if (EC) {
|
||||||
HasErrors = true;
|
HasErrors = true;
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -4172,7 +4172,8 @@ static void updateModuleTimestamp(ModuleFile &MF) {
|
||||||
// Overwrite the timestamp file contents so that file's mtime changes.
|
// Overwrite the timestamp file contents so that file's mtime changes.
|
||||||
std::string TimestampFilename = MF.getTimestampFilename();
|
std::string TimestampFilename = MF.getTimestampFilename();
|
||||||
std::error_code EC;
|
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)
|
if (EC)
|
||||||
return;
|
return;
|
||||||
OS << "Timestamp file\n";
|
OS << "Timestamp file\n";
|
||||||
|
|
|
||||||
|
|
@ -660,7 +660,7 @@ void PlistDiagnostics::FlushDiagnosticsImpl(
|
||||||
|
|
||||||
// Open the file.
|
// Open the file.
|
||||||
std::error_code EC;
|
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) {
|
if (EC) {
|
||||||
llvm::errs() << "warning: could not create file: " << EC.message() << '\n';
|
llvm::errs() << "warning: could not create file: " << EC.message() << '\n';
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -387,7 +387,7 @@ void SarifDiagnostics::FlushDiagnosticsImpl(
|
||||||
// file can become large very quickly, so decoding into JSON to append a run
|
// file can become large very quickly, so decoding into JSON to append a run
|
||||||
// may be an expensive operation.
|
// may be an expensive operation.
|
||||||
std::error_code EC;
|
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) {
|
if (EC) {
|
||||||
llvm::errs() << "warning: could not create file: " << EC.message() << '\n';
|
llvm::errs() << "warning: could not create file: " << EC.message() << '\n';
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -499,7 +499,7 @@ public:
|
||||||
|
|
||||||
if (opts::Inplace) {
|
if (opts::Inplace) {
|
||||||
std::error_code EC;
|
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) {
|
if (EC) {
|
||||||
llvm::errs() << EC.message() << "\n";
|
llvm::errs() << EC.message() << "\n";
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ getOutputStream(StringRef Path, DiagnosticsEngine &Diags, bool Binary) {
|
||||||
|
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
auto Out = std::make_unique<raw_fd_ostream>(
|
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) {
|
if (EC) {
|
||||||
Diags.Report(diag::err_fe_unable_to_open_output) << Path << EC.message();
|
Diags.Report(diag::err_fe_unable_to_open_output) << Path << EC.message();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ std::unique_ptr<llvm::raw_pwrite_stream> CompilerInstance::CreateOutputFile(
|
||||||
if (!os) {
|
if (!os) {
|
||||||
osFile = outputFilePath;
|
osFile = outputFilePath;
|
||||||
os.reset(new llvm::raw_fd_ostream(osFile, error,
|
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)
|
if (error)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -414,7 +414,7 @@ static std::string createManifestXmlWithExternalMt(StringRef defaultXml) {
|
||||||
// Create the default manifest file as a temporary file.
|
// Create the default manifest file as a temporary file.
|
||||||
TemporaryFile Default("defaultxml", "manifest");
|
TemporaryFile Default("defaultxml", "manifest");
|
||||||
std::error_code ec;
|
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)
|
if (ec)
|
||||||
fatal("failed to open " + Default.path + ": " + ec.message());
|
fatal("failed to open " + Default.path + ": " + ec.message());
|
||||||
os << defaultXml;
|
os << defaultXml;
|
||||||
|
|
@ -516,7 +516,7 @@ void createSideBySideManifest() {
|
||||||
if (path == "")
|
if (path == "")
|
||||||
path = config->outputFile + ".manifest";
|
path = config->outputFile + ".manifest";
|
||||||
std::error_code ec;
|
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)
|
if (ec)
|
||||||
fatal("failed to create manifest: " + ec.message());
|
fatal("failed to create manifest: " + ec.message());
|
||||||
out << createManifestXml();
|
out << createManifestXml();
|
||||||
|
|
|
||||||
|
|
@ -1299,7 +1299,7 @@ public:
|
||||||
llvm::Error writeFile(const lld::File &file, StringRef outPath) override {
|
llvm::Error writeFile(const lld::File &file, StringRef outPath) override {
|
||||||
// Create stream to path.
|
// Create stream to path.
|
||||||
std::error_code ec;
|
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)
|
if (ec)
|
||||||
return llvm::errorCodeToError(ec);
|
return llvm::errorCodeToError(ec);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ class AbstractRecorder {
|
||||||
protected:
|
protected:
|
||||||
AbstractRecorder(const FileSpec &filename, std::error_code &ec)
|
AbstractRecorder(const FileSpec &filename, std::error_code &ec)
|
||||||
: m_filename(filename.GetFilename().GetStringRef()),
|
: 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:
|
public:
|
||||||
const FileSpec &GetFilename() { return m_filename; }
|
const FileSpec &GetFilename() { return m_filename; }
|
||||||
|
|
@ -168,7 +169,7 @@ public:
|
||||||
void Keep() override {
|
void Keep() override {
|
||||||
FileSpec file = this->GetRoot().CopyByAppendingPathComponent(T::Info::file);
|
FileSpec file = this->GetRoot().CopyByAppendingPathComponent(T::Info::file);
|
||||||
std::error_code ec;
|
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)
|
if (ec)
|
||||||
return;
|
return;
|
||||||
os << m_directory << "\n";
|
os << m_directory << "\n";
|
||||||
|
|
@ -290,7 +291,7 @@ public:
|
||||||
|
|
||||||
FileSpec file = this->GetRoot().CopyByAppendingPathComponent(V::Info::file);
|
FileSpec file = this->GetRoot().CopyByAppendingPathComponent(V::Info::file);
|
||||||
std::error_code ec;
|
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)
|
if (ec)
|
||||||
return;
|
return;
|
||||||
llvm::yaml::Output yout(os);
|
llvm::yaml::Output yout(os);
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ void GDBRemoteProvider::Keep() {
|
||||||
|
|
||||||
FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
|
FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
|
||||||
std::error_code ec;
|
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)
|
if (ec)
|
||||||
return;
|
return;
|
||||||
yaml::Output yout(os);
|
yaml::Output yout(os);
|
||||||
|
|
@ -150,8 +150,8 @@ llvm::raw_ostream *GDBRemoteProvider::GetHistoryStream() {
|
||||||
FileSpec history_file = GetRoot().CopyByAppendingPathComponent(Info::file);
|
FileSpec history_file = GetRoot().CopyByAppendingPathComponent(Info::file);
|
||||||
|
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
m_stream_up = std::make_unique<raw_fd_ostream>(history_file.GetPath(), EC,
|
m_stream_up = std::make_unique<raw_fd_ostream>(
|
||||||
sys::fs::OpenFlags::OF_Text);
|
history_file.GetPath(), EC, sys::fs::OpenFlags::OF_TextWithCRLF);
|
||||||
return m_stream_up.get();
|
return m_stream_up.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ YamlRecorder::Create(const FileSpec &filename) {
|
||||||
void VersionProvider::Keep() {
|
void VersionProvider::Keep() {
|
||||||
FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
|
FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
|
||||||
std::error_code ec;
|
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)
|
if (ec)
|
||||||
return;
|
return;
|
||||||
os << m_version << "\n";
|
os << m_version << "\n";
|
||||||
|
|
@ -108,7 +108,7 @@ void ProcessInfoProvider::Keep() {
|
||||||
|
|
||||||
FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
|
FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
|
||||||
std::error_code ec;
|
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)
|
if (ec)
|
||||||
return;
|
return;
|
||||||
llvm::yaml::Output yout(os);
|
llvm::yaml::Output yout(os);
|
||||||
|
|
@ -153,7 +153,7 @@ void SymbolFileProvider::AddSymbolFile(const UUID *uuid,
|
||||||
void SymbolFileProvider::Keep() {
|
void SymbolFileProvider::Keep() {
|
||||||
FileSpec file = this->GetRoot().CopyByAppendingPathComponent(Info::file);
|
FileSpec file = this->GetRoot().CopyByAppendingPathComponent(Info::file);
|
||||||
std::error_code ec;
|
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)
|
if (ec)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ static std::shared_ptr<raw_ostream> GetLogStream(StringRef log_file) {
|
||||||
if (!log_file.empty()) {
|
if (!log_file.empty()) {
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
std::shared_ptr<raw_ostream> stream_sp = std::make_shared<raw_fd_ostream>(
|
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)
|
if (!EC)
|
||||||
return stream_sp;
|
return stream_sp;
|
||||||
errs() << llvm::formatv(
|
errs() << llvm::formatv(
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ public:
|
||||||
|
|
||||||
errs() << "Writing '" << Filename << "'...";
|
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 GraphName = DOTGraphTraits<GraphT>::getGraphName(Graph);
|
||||||
std::string Title = GraphName + " for '" + F.getName().str() + "' function";
|
std::string Title = GraphName + " for '" + F.getName().str() + "' function";
|
||||||
|
|
||||||
|
|
@ -160,7 +160,7 @@ public:
|
||||||
|
|
||||||
errs() << "Writing '" << Filename << "'...";
|
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);
|
std::string Title = DOTGraphTraits<GraphT>::getGraphName(Graph);
|
||||||
|
|
||||||
if (!EC)
|
if (!EC)
|
||||||
|
|
|
||||||
|
|
@ -742,24 +742,34 @@ enum OpenFlags : unsigned {
|
||||||
OF_None = 0,
|
OF_None = 0,
|
||||||
F_None = 0, // For compatibility
|
F_None = 0, // For compatibility
|
||||||
|
|
||||||
/// The file should be opened in text mode on platforms that make this
|
/// The file should be opened in text mode on platforms like z/OS that make
|
||||||
/// distinction.
|
/// this distinction.
|
||||||
OF_Text = 1,
|
OF_Text = 1,
|
||||||
F_Text = 1, // For compatibility
|
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 difference 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.
|
/// The file should be opened in append mode.
|
||||||
OF_Append = 2,
|
OF_Append = 4,
|
||||||
F_Append = 2, // For compatibility
|
F_Append = 4, // For compatibility
|
||||||
|
|
||||||
/// Delete the file on close. Only makes a difference on windows.
|
/// Delete the file on close. Only makes a difference on windows.
|
||||||
OF_Delete = 4,
|
OF_Delete = 8,
|
||||||
|
|
||||||
/// When a child process is launched, this file should remain open in the
|
/// When a child process is launched, this file should remain open in the
|
||||||
/// child process.
|
/// child process.
|
||||||
OF_ChildInherit = 8,
|
OF_ChildInherit = 16,
|
||||||
|
|
||||||
/// Force files Atime to be updated on access. Only makes a difference on windows.
|
/// Force files Atime to be updated on access. Only makes a difference on
|
||||||
OF_UpdateAtime = 16,
|
/// Windows.
|
||||||
|
OF_UpdateAtime = 32,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Create a potentially unique file name but does not create it.
|
/// Create a potentially unique file name but does not create it.
|
||||||
|
|
|
||||||
|
|
@ -859,7 +859,7 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) {
|
||||||
std::string GraphFileName = FullyQualifiedName + "." + RS.str() +
|
std::string GraphFileName = FullyQualifiedName + "." + RS.str() +
|
||||||
".pbqpgraph";
|
".pbqpgraph";
|
||||||
std::error_code EC;
|
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 \""
|
LLVM_DEBUG(dbgs() << "Dumping graph for round " << Round << " to \""
|
||||||
<< GraphFileName << "\"\n");
|
<< GraphFileName << "\"\n");
|
||||||
G.dump(OS);
|
G.dump(OS);
|
||||||
|
|
|
||||||
|
|
@ -412,7 +412,7 @@ void LLVMDumpModule(LLVMModuleRef M) {
|
||||||
LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
|
LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
|
||||||
char **ErrorMessage) {
|
char **ErrorMessage) {
|
||||||
std::error_code EC;
|
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) {
|
if (EC) {
|
||||||
*ErrorMessage = strdup(EC.message().c_str());
|
*ErrorMessage = strdup(EC.message().c_str());
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ Expected<std::unique_ptr<ToolOutputFile>> llvm::setupLLVMOptimizationRemarks(
|
||||||
return make_error<LLVMRemarkSetupFormatError>(std::move(E));
|
return make_error<LLVMRemarkSetupFormatError>(std::move(E));
|
||||||
|
|
||||||
std::error_code EC;
|
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;
|
: sys::fs::OF_None;
|
||||||
auto RemarksFile =
|
auto RemarksFile =
|
||||||
std::make_unique<ToolOutputFile>(RemarksFilename, EC, Flags);
|
std::make_unique<ToolOutputFile>(RemarksFilename, EC, Flags);
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,9 @@ Error Config::addSaveTemps(std::string OutputFileName,
|
||||||
ShouldDiscardValueNames = false;
|
ShouldDiscardValueNames = false;
|
||||||
|
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
ResolutionFile = std::make_unique<raw_fd_ostream>(
|
ResolutionFile =
|
||||||
OutputFileName + "resolution.txt", EC, sys::fs::OpenFlags::OF_Text);
|
std::make_unique<raw_fd_ostream>(OutputFileName + "resolution.txt", EC,
|
||||||
|
sys::fs::OpenFlags::OF_TextWithCRLF);
|
||||||
if (EC) {
|
if (EC) {
|
||||||
ResolutionFile.reset();
|
ResolutionFile.reset();
|
||||||
return errorCodeToError(EC);
|
return errorCodeToError(EC);
|
||||||
|
|
|
||||||
|
|
@ -776,8 +776,9 @@ bool DarwinAsmParser::parseDirectiveSecureLogUnique(StringRef, SMLoc IDLoc) {
|
||||||
raw_fd_ostream *OS = getContext().getSecureLog();
|
raw_fd_ostream *OS = getContext().getSecureLog();
|
||||||
if (!OS) {
|
if (!OS) {
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
auto NewOS = std::make_unique<raw_fd_ostream>(
|
auto NewOS = std::make_unique<raw_fd_ostream>(StringRef(SecureLogFile), EC,
|
||||||
StringRef(SecureLogFile), EC, sys::fs::OF_Append | sys::fs::OF_Text);
|
sys::fs::OF_Append |
|
||||||
|
sys::fs::OF_TextWithCRLF);
|
||||||
if (EC)
|
if (EC)
|
||||||
return Error(IDLoc, Twine("can't open secure log file: ") +
|
return Error(IDLoc, Twine("can't open secure log file: ") +
|
||||||
SecureLogFile + " (" + EC.message() + ")");
|
SecureLogFile + " (" + EC.message() + ")");
|
||||||
|
|
|
||||||
|
|
@ -866,7 +866,7 @@ void Context::print(StringRef filename, StringRef gcno, StringRef gcda,
|
||||||
Optional<raw_fd_ostream> os;
|
Optional<raw_fd_ostream> os;
|
||||||
if (!options.UseStdout) {
|
if (!options.UseStdout) {
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
os.emplace(gcovName, ec, sys::fs::OF_Text);
|
os.emplace(gcovName, ec, sys::fs::OF_TextWithCRLF);
|
||||||
if (ec) {
|
if (ec) {
|
||||||
errs() << ec.message() << '\n';
|
errs() << ec.message() << '\n';
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -881,7 +881,7 @@ void Context::print(StringRef filename, StringRef gcno, StringRef gcda,
|
||||||
// (PR GCC/82702). We create just one file.
|
// (PR GCC/82702). We create just one file.
|
||||||
std::string outputPath(sys::path::filename(filename));
|
std::string outputPath(sys::path::filename(filename));
|
||||||
std::error_code ec;
|
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) {
|
if (ec) {
|
||||||
errs() << ec.message() << '\n';
|
errs() << ec.message() << '\n';
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -728,7 +728,7 @@ SampleProfileWriter::create(StringRef Filename, SampleProfileFormat Format) {
|
||||||
Format == SPF_Compact_Binary)
|
Format == SPF_Compact_Binary)
|
||||||
OS.reset(new raw_fd_ostream(Filename, EC, sys::fs::OF_None));
|
OS.reset(new raw_fd_ostream(Filename, EC, sys::fs::OF_None));
|
||||||
else
|
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)
|
if (EC)
|
||||||
return EC;
|
return EC;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ std::error_code FileCollector::writeMapping(StringRef MappingFile) {
|
||||||
VFSWriter.setUseExternalNames(false);
|
VFSWriter.setUseExternalNames(false);
|
||||||
|
|
||||||
std::error_code EC;
|
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)
|
if (EC)
|
||||||
return EC;
|
return EC;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,7 @@ static ErrorOr<std::unique_ptr<MB>>
|
||||||
getFileAux(const Twine &Filename, uint64_t MapSize, uint64_t Offset,
|
getFileAux(const Twine &Filename, uint64_t MapSize, uint64_t Offset,
|
||||||
bool IsText, bool RequiresNullTerminator, bool IsVolatile) {
|
bool IsText, bool RequiresNullTerminator, bool IsVolatile) {
|
||||||
Expected<sys::fs::file_t> FDOrErr = sys::fs::openNativeFileForRead(
|
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)
|
if (!FDOrErr)
|
||||||
return errorToErrorCode(FDOrErr.takeError());
|
return errorToErrorCode(FDOrErr.takeError());
|
||||||
sys::fs::file_t FD = *FDOrErr;
|
sys::fs::file_t FD = *FDOrErr;
|
||||||
|
|
|
||||||
|
|
@ -304,7 +304,7 @@ Error llvm::timeTraceProfilerWrite(StringRef PreferredFileName,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::error_code EC;
|
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)
|
if (EC)
|
||||||
return createStringError(EC, "Could not open " + Path);
|
return createStringError(EC, "Could not open " + Path);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ std::unique_ptr<raw_fd_ostream> llvm::CreateInfoOutputFile() {
|
||||||
// info output file before running commands which write to it.
|
// info output file before running commands which write to it.
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
auto Result = std::make_unique<raw_fd_ostream>(
|
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)
|
if (!EC)
|
||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -507,7 +507,7 @@ std::error_code
|
||||||
llvm::sys::writeFileWithEncoding(StringRef FileName, StringRef Contents,
|
llvm::sys::writeFileWithEncoding(StringRef FileName, StringRef Contents,
|
||||||
WindowsEncodingMethod Encoding /*unused*/) {
|
WindowsEncodingMethod Encoding /*unused*/) {
|
||||||
std::error_code EC;
|
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)
|
if (EC)
|
||||||
return EC;
|
return EC;
|
||||||
|
|
|
||||||
|
|
@ -1083,8 +1083,10 @@ static std::error_code nativeFileToFd(Expected<HANDLE> H, int &ResultFD,
|
||||||
if (Flags & OF_Append)
|
if (Flags & OF_Append)
|
||||||
CrtOpenFlags |= _O_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;
|
CrtOpenFlags |= _O_TEXT;
|
||||||
|
}
|
||||||
|
|
||||||
ResultFD = -1;
|
ResultFD = -1;
|
||||||
if (!H)
|
if (!H)
|
||||||
|
|
|
||||||
|
|
@ -506,7 +506,7 @@ std::error_code
|
||||||
llvm::sys::writeFileWithEncoding(StringRef FileName, StringRef Contents,
|
llvm::sys::writeFileWithEncoding(StringRef FileName, StringRef Contents,
|
||||||
WindowsEncodingMethod Encoding) {
|
WindowsEncodingMethod Encoding) {
|
||||||
std::error_code EC;
|
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)
|
if (EC)
|
||||||
return EC;
|
return EC;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2413,7 +2413,7 @@ void AADepGraph::dumpGraph() {
|
||||||
|
|
||||||
std::error_code EC;
|
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)
|
if (!EC)
|
||||||
llvm::WriteGraph(File, this);
|
llvm::WriteGraph(File, this);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1722,7 +1722,7 @@ bool LowerTypeTestsModule::runForTesting(Module &M) {
|
||||||
ExitOnError ExitOnErr("-lowertypetests-write-summary: " + ClWriteSummary +
|
ExitOnError ExitOnErr("-lowertypetests-write-summary: " + ClWriteSummary +
|
||||||
": ");
|
": ");
|
||||||
std::error_code EC;
|
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));
|
ExitOnErr(errorCodeToError(EC));
|
||||||
|
|
||||||
yaml::Output Out(OS);
|
yaml::Output Out(OS);
|
||||||
|
|
|
||||||
|
|
@ -918,7 +918,7 @@ bool DevirtModule::runForTesting(
|
||||||
ExitOnErr(errorCodeToError(EC));
|
ExitOnErr(errorCodeToError(EC));
|
||||||
WriteIndexToFile(*Summary, OS);
|
WriteIndexToFile(*Summary, OS);
|
||||||
} else {
|
} else {
|
||||||
raw_fd_ostream OS(ClWriteSummary, EC, sys::fs::OF_Text);
|
raw_fd_ostream OS(ClWriteSummary, EC, sys::fs::OF_TextWithCRLF);
|
||||||
ExitOnErr(errorCodeToError(EC));
|
ExitOnErr(errorCodeToError(EC));
|
||||||
yaml::Output Out(OS);
|
yaml::Output Out(OS);
|
||||||
Out << *Summary;
|
Out << *Summary;
|
||||||
|
|
|
||||||
|
|
@ -440,7 +440,7 @@ static void writeJSON(StringRef OrigDIVerifyBugsReportFilePath,
|
||||||
llvm::json::Array &Bugs) {
|
llvm::json::Array &Bugs) {
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
raw_fd_ostream OS_FILE{OrigDIVerifyBugsReportFilePath, 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) {
|
if (EC) {
|
||||||
errs() << "Could not open file: " << EC.message() << ", "
|
errs() << "Could not open file: " << EC.message() << ", "
|
||||||
<< OrigDIVerifyBugsReportFilePath << '\n';
|
<< OrigDIVerifyBugsReportFilePath << '\n';
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,7 @@ static Error createPlistFile(StringRef Bin, StringRef BundleRoot,
|
||||||
SmallString<128> InfoPlist(BundleRoot);
|
SmallString<128> InfoPlist(BundleRoot);
|
||||||
sys::path::append(InfoPlist, "Contents/Info.plist");
|
sys::path::append(InfoPlist, "Contents/Info.plist");
|
||||||
std::error_code EC;
|
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)
|
if (EC)
|
||||||
return make_error<StringError>(
|
return make_error<StringError>(
|
||||||
"cannot create Plist: " + toString(errorCodeToError(EC)), EC);
|
"cannot create Plist: " + toString(errorCodeToError(EC)), EC);
|
||||||
|
|
|
||||||
|
|
@ -276,7 +276,7 @@ static std::unique_ptr<ToolOutputFile> GetOutputStream(const char *TargetName,
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
sys::fs::OpenFlags OpenFlags = sys::fs::OF_None;
|
sys::fs::OpenFlags OpenFlags = sys::fs::OF_None;
|
||||||
if (!Binary)
|
if (!Binary)
|
||||||
OpenFlags |= sys::fs::OF_Text;
|
OpenFlags |= sys::fs::OF_TextWithCRLF;
|
||||||
auto FDOut = std::make_unique<ToolOutputFile>(OutputFilename, EC, OpenFlags);
|
auto FDOut = std::make_unique<ToolOutputFile>(OutputFilename, EC, OpenFlags);
|
||||||
if (EC) {
|
if (EC) {
|
||||||
reportError(EC.message());
|
reportError(EC.message());
|
||||||
|
|
|
||||||
|
|
@ -791,7 +791,8 @@ static std::function<void(Module &)> createDebugDumper() {
|
||||||
case DumpKind::DumpModsToDisk:
|
case DumpKind::DumpModsToDisk:
|
||||||
return [](Module &M) {
|
return [](Module &M) {
|
||||||
std::error_code EC;
|
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) {
|
if (EC) {
|
||||||
errs() << "Couldn't open " << M.getModuleIdentifier()
|
errs() << "Couldn't open " << M.getModuleIdentifier()
|
||||||
<< " for dumping.\nError:" << EC.message() << "\n";
|
<< " for dumping.\nError:" << EC.message() << "\n";
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ int main(int argc, const char *argv[]) {
|
||||||
exitWithErrorCode(RemappingBufOrError.getError(), RemappingFile);
|
exitWithErrorCode(RemappingBufOrError.getError(), RemappingFile);
|
||||||
|
|
||||||
std::error_code EC;
|
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)
|
if (EC)
|
||||||
exitWithErrorCode(EC, OutputFilename);
|
exitWithErrorCode(EC, OutputFilename);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
std::unique_ptr<ToolOutputFile> Out(
|
std::unique_ptr<ToolOutputFile> Out(
|
||||||
new ToolOutputFile(FinalFilename, EC, sys::fs::OF_Text));
|
new ToolOutputFile(FinalFilename, EC, sys::fs::OF_TextWithCRLF));
|
||||||
if (EC) {
|
if (EC) {
|
||||||
errs() << EC.message() << '\n';
|
errs() << EC.message() << '\n';
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -628,7 +628,7 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::error_code EC;
|
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);
|
error("Unable to open output file" + OutputFilename, EC);
|
||||||
// Don't remove output file if we exit with an error.
|
// Don't remove output file if we exit with an error.
|
||||||
OutputFile.keep();
|
OutputFile.keep();
|
||||||
|
|
|
||||||
|
|
@ -401,8 +401,9 @@ Error InstructionBenchmark::writeYaml(const LLVMState &State,
|
||||||
return Err;
|
return Err;
|
||||||
} else {
|
} else {
|
||||||
int ResultFD = 0;
|
int ResultFD = 0;
|
||||||
if (auto E = errorCodeToError(openFileForWrite(
|
if (auto E = errorCodeToError(openFileForWrite(Filename, ResultFD,
|
||||||
Filename, ResultFD, sys::fs::CD_CreateAlways, sys::fs::OF_Text))) {
|
sys::fs::CD_CreateAlways,
|
||||||
|
sys::fs::OF_TextWithCRLF))) {
|
||||||
return E;
|
return E;
|
||||||
}
|
}
|
||||||
raw_fd_ostream Ostr(ResultFD, true /*shouldClose*/);
|
raw_fd_ostream Ostr(ResultFD, true /*shouldClose*/);
|
||||||
|
|
|
||||||
|
|
@ -468,7 +468,8 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
ToolOutputFile Out(OutputFilename, 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) {
|
if (EC) {
|
||||||
WithColor::error() << EC.message() << '\n';
|
WithColor::error() << EC.message() << '\n';
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -452,8 +452,9 @@ int main(int argc, char **argv) {
|
||||||
FeaturesStr = Features.getString();
|
FeaturesStr = Features.getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
sys::fs::OpenFlags Flags = (FileType == OFT_AssemblyFile) ? sys::fs::OF_Text
|
sys::fs::OpenFlags Flags = (FileType == OFT_AssemblyFile)
|
||||||
: sys::fs::OF_None;
|
? sys::fs::OF_TextWithCRLF
|
||||||
|
: sys::fs::OF_None;
|
||||||
std::unique_ptr<ToolOutputFile> Out = GetOutputStream(OutputFilename, Flags);
|
std::unique_ptr<ToolOutputFile> Out = GetOutputStream(OutputFilename, Flags);
|
||||||
if (!Out)
|
if (!Out)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -244,8 +244,8 @@ ErrorOr<std::unique_ptr<ToolOutputFile>> getOutputStream() {
|
||||||
if (OutputFilename == "")
|
if (OutputFilename == "")
|
||||||
OutputFilename = "-";
|
OutputFilename = "-";
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
auto Out =
|
auto Out = std::make_unique<ToolOutputFile>(OutputFilename, EC,
|
||||||
std::make_unique<ToolOutputFile>(OutputFilename, EC, sys::fs::OF_Text);
|
sys::fs::OF_TextWithCRLF);
|
||||||
if (!EC)
|
if (!EC)
|
||||||
return std::move(Out);
|
return std::move(Out);
|
||||||
return EC;
|
return EC;
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,7 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) {
|
||||||
|
|
||||||
static bool writeReport(LocationInfoTy &LocationInfo) {
|
static bool writeReport(LocationInfoTy &LocationInfo) {
|
||||||
std::error_code EC;
|
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) {
|
if (EC) {
|
||||||
WithColor::error() << "Can't open file " << OutputFileName << ": "
|
WithColor::error() << "Can't open file " << OutputFileName << ": "
|
||||||
<< EC.message() << "\n";
|
<< EC.message() << "\n";
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,7 @@ static void writeInstrProfile(StringRef OutputFilename,
|
||||||
InstrProfWriter &Writer) {
|
InstrProfWriter &Writer) {
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
raw_fd_ostream Output(OutputFilename.data(), 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);
|
: sys::fs::OF_None);
|
||||||
if (EC)
|
if (EC)
|
||||||
exitWithErrorCode(EC, OutputFilename);
|
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");
|
cl::ParseCommandLineOptions(argc, argv, "LLVM profile data overlap tool\n");
|
||||||
|
|
||||||
std::error_code EC;
|
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)
|
if (EC)
|
||||||
exitWithErrorCode(EC, Output);
|
exitWithErrorCode(EC, Output);
|
||||||
|
|
||||||
|
|
@ -2457,7 +2457,7 @@ static int show_main(int argc, const char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::error_code EC;
|
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)
|
if (EC)
|
||||||
exitWithErrorCode(EC, OutputFilename);
|
exitWithErrorCode(EC, OutputFilename);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -459,7 +459,7 @@ static CommandRegistration Unused(&Account, []() -> Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::error_code EC;
|
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)
|
if (EC)
|
||||||
return make_error<StringError>(
|
return make_error<StringError>(
|
||||||
Twine("Cannot open file '") + AccountOutput + "' for writing.", EC);
|
Twine("Cannot open file '") + AccountOutput + "' for writing.", EC);
|
||||||
|
|
|
||||||
|
|
@ -381,7 +381,7 @@ static CommandRegistration Unused(&Convert, []() -> Error {
|
||||||
raw_fd_ostream OS(ConvertOutput, EC,
|
raw_fd_ostream OS(ConvertOutput, EC,
|
||||||
ConvertOutputFormat == ConvertFormats::BINARY
|
ConvertOutputFormat == ConvertFormats::BINARY
|
||||||
? sys::fs::OpenFlags::OF_None
|
? sys::fs::OpenFlags::OF_None
|
||||||
: sys::fs::OpenFlags::OF_Text);
|
: sys::fs::OpenFlags::OF_TextWithCRLF);
|
||||||
if (EC)
|
if (EC)
|
||||||
return make_error<StringError>(
|
return make_error<StringError>(
|
||||||
Twine("Cannot open file '") + ConvertOutput + "' for writing.", EC);
|
Twine("Cannot open file '") + ConvertOutput + "' for writing.", EC);
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ static CommandRegistration Unused(&Extract, []() -> Error {
|
||||||
InstrumentationMapOrError.takeError());
|
InstrumentationMapOrError.takeError());
|
||||||
|
|
||||||
std::error_code EC;
|
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)
|
if (EC)
|
||||||
return make_error<StringError>(
|
return make_error<StringError>(
|
||||||
Twine("Cannot open file '") + ExtractOutput + "' for writing.", EC);
|
Twine("Cannot open file '") + ExtractOutput + "' for writing.", EC);
|
||||||
|
|
|
||||||
|
|
@ -456,7 +456,7 @@ static CommandRegistration Unused(&GraphDiff, []() -> Error {
|
||||||
auto &GDR = *GDROrErr;
|
auto &GDR = *GDROrErr;
|
||||||
|
|
||||||
std::error_code EC;
|
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)
|
if (EC)
|
||||||
return make_error<StringError>(
|
return make_error<StringError>(
|
||||||
Twine("Cannot open file '") + GraphDiffOutput + "' for writing.", EC);
|
Twine("Cannot open file '") + GraphDiffOutput + "' for writing.", EC);
|
||||||
|
|
|
||||||
|
|
@ -523,7 +523,7 @@ static CommandRegistration Unused(&GraphC, []() -> Error {
|
||||||
auto &GR = *GROrError;
|
auto &GR = *GROrError;
|
||||||
|
|
||||||
std::error_code EC;
|
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)
|
if (EC)
|
||||||
return make_error<StringError>(
|
return make_error<StringError>(
|
||||||
Twine("Cannot open file '") + GraphOutput + "' for writing.", EC);
|
Twine("Cannot open file '") + GraphOutput + "' for writing.", EC);
|
||||||
|
|
|
||||||
|
|
@ -700,8 +700,8 @@ int main(int argc, char **argv) {
|
||||||
OutputFilename = "-";
|
OutputFilename = "-";
|
||||||
|
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
sys::fs::OpenFlags Flags = OutputAssembly ? sys::fs::OF_Text
|
sys::fs::OpenFlags Flags =
|
||||||
: sys::fs::OF_None;
|
OutputAssembly ? sys::fs::OF_TextWithCRLF : sys::fs::OF_None;
|
||||||
Out.reset(new ToolOutputFile(OutputFilename, EC, Flags));
|
Out.reset(new ToolOutputFile(OutputFilename, EC, Flags));
|
||||||
if (EC) {
|
if (EC) {
|
||||||
errs() << EC.message() << '\n';
|
errs() << EC.message() << '\n';
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ bool TempFile::writeBitcode(const Module &M) const {
|
||||||
bool TempFile::writeAssembly(const Module &M) const {
|
bool TempFile::writeAssembly(const Module &M) const {
|
||||||
LLVM_DEBUG(dbgs() << " - write assembly\n");
|
LLVM_DEBUG(dbgs() << " - write assembly\n");
|
||||||
std::error_code EC;
|
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) {
|
if (EC) {
|
||||||
errs() << "verify-uselistorder: error: " << EC.message() << "\n";
|
errs() << "verify-uselistorder: error: " << EC.message() << "\n";
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -1253,7 +1253,7 @@ TEST_F(FileSystemTest, CarriageReturn) {
|
||||||
path::append(FilePathname, "test");
|
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);
|
ASSERT_NO_ERROR(EC);
|
||||||
File << '\n';
|
File << '\n';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ static void exportScop(Scop &S) {
|
||||||
|
|
||||||
// Write to file.
|
// Write to file.
|
||||||
std::error_code EC;
|
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();
|
std::string FunctionName = S.getFunction().getName().str();
|
||||||
errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
|
errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue