[clang] fdb640e - Mark output as text if it is really text
Abhina Sreeskantharajan via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 12 04:14:28 PST 2021
Author: Abhina Sreeskantharajan
Date: 2021-02-12T07:14:21-05:00
New Revision: fdb640ea30d416368b76b68b106deda580c6aced
URL: https://github.com/llvm/llvm-project/commit/fdb640ea30d416368b76b68b106deda580c6aced
DIFF: https://github.com/llvm/llvm-project/commit/fdb640ea30d416368b76b68b106deda580c6aced.diff
LOG: Mark output as text if it is really text
This is a continuation of https://reviews.llvm.org/D67696. The following places need to set the OF_Text flag correctly.
Reviewed By: JDevlieghere
Differential Revision: https://reviews.llvm.org/D96363
Added:
Modified:
clang/lib/Driver/Driver.cpp
clang/lib/Frontend/Rewrite/FrontendActions.cpp
llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 54a66992f84b..02f4f478031f 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1445,7 +1445,9 @@ void Driver::generateCompilationDiagnostics(
llvm::SmallString<128> Script(CrashInfo.Filename);
llvm::sys::path::replace_extension(Script, "sh");
std::error_code EC;
- llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew);
+ llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew,
+ llvm::sys::fs::FA_Write,
+ llvm::sys::fs::OF_Text);
if (EC) {
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< "Error generating run script: " << Script << " " << EC.message();
diff --git a/clang/lib/Frontend/Rewrite/FrontendActions.cpp b/clang/lib/Frontend/Rewrite/FrontendActions.cpp
index 5351ff0593ed..13e668a47a2f 100644
--- a/clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ b/clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -185,7 +185,7 @@ RewriteObjCAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
void RewriteMacrosAction::ExecuteAction() {
CompilerInstance &CI = getCompilerInstance();
std::unique_ptr<raw_ostream> OS =
- CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+ CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
if (!OS) return;
RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@ class RewriteIncludesAction::RewriteImportsListener : public ASTReaderListener {
bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
if (!OutputStream) {
OutputStream =
- CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+ CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
if (!OutputStream)
return false;
}
diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
index 01ee325002df..b2eaa067a3d9 100644
--- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -252,7 +252,10 @@ static Error emitRemarks(const LinkOptions &Options, StringRef BinaryPath,
}
std::error_code EC;
- raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC, sys::fs::OF_None);
+ raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC,
+ Options.RemarksFormat == remarks::Format::Bitstream
+ ? sys::fs::OF_None
+ : sys::fs::OF_Text);
if (EC)
return errorCodeToError(EC);
More information about the cfe-commits
mailing list