forked from OSchip/llvm-project
parent
b14bd53e6d
commit
dae941a6c8
|
@ -641,7 +641,7 @@ public:
|
||||||
/// renamed to \p OutputPath in the end.
|
/// renamed to \p OutputPath in the end.
|
||||||
///
|
///
|
||||||
/// \param OutputPath - If given, the path to the output file.
|
/// \param OutputPath - If given, the path to the output file.
|
||||||
/// \param Error [out] - On failure, the error message.
|
/// \param Error [out] - On failure, the error.
|
||||||
/// \param BaseInput - If \p OutputPath is empty, the input path name to use
|
/// \param BaseInput - If \p OutputPath is empty, the input path name to use
|
||||||
/// for deriving the output path.
|
/// for deriving the output path.
|
||||||
/// \param Extension - The extension to use for derived output names.
|
/// \param Extension - The extension to use for derived output names.
|
||||||
|
@ -658,13 +658,10 @@ public:
|
||||||
/// \param TempPathName [out] - If given, the temporary file path name
|
/// \param TempPathName [out] - If given, the temporary file path name
|
||||||
/// will be stored here on success.
|
/// will be stored here on success.
|
||||||
static llvm::raw_fd_ostream *
|
static llvm::raw_fd_ostream *
|
||||||
createOutputFile(StringRef OutputPath, std::string &Error,
|
createOutputFile(StringRef OutputPath, std::error_code &Error, bool Binary,
|
||||||
bool Binary, bool RemoveFileOnSignal,
|
bool RemoveFileOnSignal, StringRef BaseInput,
|
||||||
StringRef BaseInput,
|
StringRef Extension, bool UseTemporary,
|
||||||
StringRef Extension,
|
bool CreateMissingDirectories, std::string *ResultPathName,
|
||||||
bool UseTemporary,
|
|
||||||
bool CreateMissingDirectories,
|
|
||||||
std::string *ResultPathName,
|
|
||||||
std::string *TempPathName);
|
std::string *TempPathName);
|
||||||
|
|
||||||
llvm::raw_null_ostream *createNullOutputFile();
|
llvm::raw_null_ostream *createNullOutputFile();
|
||||||
|
|
|
@ -122,11 +122,11 @@ bool FileRemapper::flushToDisk(StringRef outputDir, DiagnosticsEngine &Diag) {
|
||||||
bool FileRemapper::flushToFile(StringRef outputPath, DiagnosticsEngine &Diag) {
|
bool FileRemapper::flushToFile(StringRef outputPath, DiagnosticsEngine &Diag) {
|
||||||
using namespace llvm::sys;
|
using namespace llvm::sys;
|
||||||
|
|
||||||
std::string errMsg;
|
std::error_code EC;
|
||||||
std::string infoFile = outputPath;
|
std::string infoFile = outputPath;
|
||||||
llvm::raw_fd_ostream infoOut(infoFile.c_str(), errMsg, llvm::sys::fs::F_None);
|
llvm::raw_fd_ostream infoOut(infoFile, EC, llvm::sys::fs::F_None);
|
||||||
if (!errMsg.empty())
|
if (EC)
|
||||||
return report(errMsg, Diag);
|
return report(EC.message(), Diag);
|
||||||
|
|
||||||
for (MappingsTy::iterator
|
for (MappingsTy::iterator
|
||||||
I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I) {
|
I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I) {
|
||||||
|
@ -179,10 +179,10 @@ bool FileRemapper::overwriteOriginal(DiagnosticsEngine &Diag,
|
||||||
return report(StringRef("File does not exist: ") + origFE->getName(),
|
return report(StringRef("File does not exist: ") + origFE->getName(),
|
||||||
Diag);
|
Diag);
|
||||||
|
|
||||||
std::string errMsg;
|
std::error_code EC;
|
||||||
llvm::raw_fd_ostream Out(origFE->getName(), errMsg, llvm::sys::fs::F_None);
|
llvm::raw_fd_ostream Out(origFE->getName(), EC, llvm::sys::fs::F_None);
|
||||||
if (!errMsg.empty())
|
if (EC)
|
||||||
return report(errMsg, Diag);
|
return report(EC.message(), Diag);
|
||||||
|
|
||||||
llvm::MemoryBuffer *mem = I->second.get<llvm::MemoryBuffer *>();
|
llvm::MemoryBuffer *mem = I->second.get<llvm::MemoryBuffer *>();
|
||||||
Out.write(mem->getBufferStart(), mem->getBufferSize());
|
Out.write(mem->getBufferStart(), mem->getBufferSize());
|
||||||
|
|
|
@ -1791,12 +1791,12 @@ void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsOutputFile) {
|
if (IsOutputFile) {
|
||||||
std::string Error;
|
std::error_code EC;
|
||||||
llvm::raw_fd_ostream OS(MigrateDir.c_str(), Error, llvm::sys::fs::F_None);
|
llvm::raw_fd_ostream OS(MigrateDir, EC, llvm::sys::fs::F_None);
|
||||||
if (!Error.empty()) {
|
if (EC) {
|
||||||
DiagnosticsEngine &Diags = Ctx.getDiagnostics();
|
DiagnosticsEngine &Diags = Ctx.getDiagnostics();
|
||||||
Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Error, "%0"))
|
Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Error, "%0"))
|
||||||
<< Error;
|
<< EC.message();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,9 +56,9 @@ void arcmt::writeARCDiagsToPlist(const std::string &outPath,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string errMsg;
|
std::error_code EC;
|
||||||
llvm::raw_fd_ostream o(outPath.c_str(), errMsg, llvm::sys::fs::F_Text);
|
llvm::raw_fd_ostream o(outPath, EC, llvm::sys::fs::F_Text);
|
||||||
if (!errMsg.empty()) {
|
if (EC) {
|
||||||
llvm::errs() << "error: could not create file: " << outPath << '\n';
|
llvm::errs() << "error: could not create file: " << outPath << '\n';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,13 +131,13 @@ int Compilation::ExecuteCommand(const Command &C,
|
||||||
// Follow gcc implementation of CC_PRINT_OPTIONS; we could also cache the
|
// Follow gcc implementation of CC_PRINT_OPTIONS; we could also cache the
|
||||||
// output stream.
|
// output stream.
|
||||||
if (getDriver().CCPrintOptions && getDriver().CCPrintOptionsFilename) {
|
if (getDriver().CCPrintOptions && getDriver().CCPrintOptionsFilename) {
|
||||||
std::string Error;
|
std::error_code EC;
|
||||||
OS = new llvm::raw_fd_ostream(getDriver().CCPrintOptionsFilename, Error,
|
OS = new llvm::raw_fd_ostream(getDriver().CCPrintOptionsFilename, EC,
|
||||||
llvm::sys::fs::F_Append |
|
llvm::sys::fs::F_Append |
|
||||||
llvm::sys::fs::F_Text);
|
llvm::sys::fs::F_Text);
|
||||||
if (!Error.empty()) {
|
if (EC) {
|
||||||
getDriver().Diag(clang::diag::err_drv_cc_print_options_failure)
|
getDriver().Diag(clang::diag::err_drv_cc_print_options_failure)
|
||||||
<< Error;
|
<< EC.message();
|
||||||
FailingCommand = &C;
|
FailingCommand = &C;
|
||||||
delete OS;
|
delete OS;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -533,12 +533,12 @@ void Driver::generateCompilationDiagnostics(Compilation &C,
|
||||||
llvm::sys::path::append(VFS, "vfs", "vfs.yaml");
|
llvm::sys::path::append(VFS, "vfs", "vfs.yaml");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Err;
|
std::error_code EC;
|
||||||
Script += ".sh";
|
Script += ".sh";
|
||||||
llvm::raw_fd_ostream ScriptOS(Script.c_str(), Err, llvm::sys::fs::F_Excl);
|
llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::F_Excl);
|
||||||
if (!Err.empty()) {
|
if (EC) {
|
||||||
Diag(clang::diag::note_drv_command_failed_diag_msg)
|
Diag(clang::diag::note_drv_command_failed_diag_msg)
|
||||||
<< "Error generating run script: " + Script + " " + Err;
|
<< "Error generating run script: " + Script + " " + EC.message();
|
||||||
} else {
|
} else {
|
||||||
// Replace the original filename with the preprocessed one.
|
// Replace the original filename with the preprocessed one.
|
||||||
size_t I, E;
|
size_t I, E;
|
||||||
|
|
|
@ -134,17 +134,17 @@ void CompilerInstance::setModuleDepCollector(
|
||||||
static void SetUpDiagnosticLog(DiagnosticOptions *DiagOpts,
|
static void SetUpDiagnosticLog(DiagnosticOptions *DiagOpts,
|
||||||
const CodeGenOptions *CodeGenOpts,
|
const CodeGenOptions *CodeGenOpts,
|
||||||
DiagnosticsEngine &Diags) {
|
DiagnosticsEngine &Diags) {
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
bool OwnsStream = false;
|
bool OwnsStream = false;
|
||||||
raw_ostream *OS = &llvm::errs();
|
raw_ostream *OS = &llvm::errs();
|
||||||
if (DiagOpts->DiagnosticLogFile != "-") {
|
if (DiagOpts->DiagnosticLogFile != "-") {
|
||||||
// Create the output stream.
|
// Create the output stream.
|
||||||
llvm::raw_fd_ostream *FileOS(new llvm::raw_fd_ostream(
|
llvm::raw_fd_ostream *FileOS(new llvm::raw_fd_ostream(
|
||||||
DiagOpts->DiagnosticLogFile.c_str(), ErrorInfo,
|
DiagOpts->DiagnosticLogFile, EC,
|
||||||
llvm::sys::fs::F_Append | llvm::sys::fs::F_Text));
|
llvm::sys::fs::F_Append | llvm::sys::fs::F_Text));
|
||||||
if (!ErrorInfo.empty()) {
|
if (EC) {
|
||||||
Diags.Report(diag::warn_fe_cc_log_diagnostics_failure)
|
Diags.Report(diag::warn_fe_cc_log_diagnostics_failure)
|
||||||
<< DiagOpts->DiagnosticLogFile << ErrorInfo;
|
<< DiagOpts->DiagnosticLogFile << EC.message();
|
||||||
} else {
|
} else {
|
||||||
FileOS->SetUnbuffered();
|
FileOS->SetUnbuffered();
|
||||||
FileOS->SetUseAtomicWrites(true);
|
FileOS->SetUseAtomicWrites(true);
|
||||||
|
@ -164,14 +164,14 @@ static void SetUpDiagnosticLog(DiagnosticOptions *DiagOpts,
|
||||||
static void SetupSerializedDiagnostics(DiagnosticOptions *DiagOpts,
|
static void SetupSerializedDiagnostics(DiagnosticOptions *DiagOpts,
|
||||||
DiagnosticsEngine &Diags,
|
DiagnosticsEngine &Diags,
|
||||||
StringRef OutputFile) {
|
StringRef OutputFile) {
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
std::unique_ptr<llvm::raw_fd_ostream> OS;
|
std::unique_ptr<llvm::raw_fd_ostream> OS;
|
||||||
OS.reset(new llvm::raw_fd_ostream(OutputFile.str().c_str(), ErrorInfo,
|
OS.reset(
|
||||||
llvm::sys::fs::F_None));
|
new llvm::raw_fd_ostream(OutputFile.str(), EC, llvm::sys::fs::F_None));
|
||||||
|
|
||||||
if (!ErrorInfo.empty()) {
|
if (EC) {
|
||||||
Diags.Report(diag::warn_fe_serialized_diag_failure)
|
Diags.Report(diag::warn_fe_serialized_diag_failure) << OutputFile
|
||||||
<< OutputFile << ErrorInfo;
|
<< EC.message();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,17 +573,14 @@ CompilerInstance::createOutputFile(StringRef OutputPath,
|
||||||
StringRef Extension,
|
StringRef Extension,
|
||||||
bool UseTemporary,
|
bool UseTemporary,
|
||||||
bool CreateMissingDirectories) {
|
bool CreateMissingDirectories) {
|
||||||
std::string Error, OutputPathName, TempPathName;
|
std::string OutputPathName, TempPathName;
|
||||||
llvm::raw_fd_ostream *OS = createOutputFile(OutputPath, Error, Binary,
|
std::error_code EC;
|
||||||
RemoveFileOnSignal,
|
llvm::raw_fd_ostream *OS = createOutputFile(
|
||||||
InFile, Extension,
|
OutputPath, EC, Binary, RemoveFileOnSignal, InFile, Extension,
|
||||||
UseTemporary,
|
UseTemporary, CreateMissingDirectories, &OutputPathName, &TempPathName);
|
||||||
CreateMissingDirectories,
|
|
||||||
&OutputPathName,
|
|
||||||
&TempPathName);
|
|
||||||
if (!OS) {
|
if (!OS) {
|
||||||
getDiagnostics().Report(diag::err_fe_unable_to_open_output)
|
getDiagnostics().Report(diag::err_fe_unable_to_open_output) << OutputPath
|
||||||
<< OutputPath << Error;
|
<< EC.message();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,17 +592,11 @@ CompilerInstance::createOutputFile(StringRef OutputPath,
|
||||||
return OS;
|
return OS;
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::raw_fd_ostream *
|
llvm::raw_fd_ostream *CompilerInstance::createOutputFile(
|
||||||
CompilerInstance::createOutputFile(StringRef OutputPath,
|
StringRef OutputPath, std::error_code &Error, bool Binary,
|
||||||
std::string &Error,
|
bool RemoveFileOnSignal, StringRef InFile, StringRef Extension,
|
||||||
bool Binary,
|
bool UseTemporary, bool CreateMissingDirectories,
|
||||||
bool RemoveFileOnSignal,
|
std::string *ResultPathName, std::string *TempPathName) {
|
||||||
StringRef InFile,
|
|
||||||
StringRef Extension,
|
|
||||||
bool UseTemporary,
|
|
||||||
bool CreateMissingDirectories,
|
|
||||||
std::string *ResultPathName,
|
|
||||||
std::string *TempPathName) {
|
|
||||||
assert((!CreateMissingDirectories || UseTemporary) &&
|
assert((!CreateMissingDirectories || UseTemporary) &&
|
||||||
"CreateMissingDirectories is only allowed when using temporary files");
|
"CreateMissingDirectories is only allowed when using temporary files");
|
||||||
|
|
||||||
|
@ -674,9 +665,9 @@ CompilerInstance::createOutputFile(StringRef OutputPath,
|
||||||
if (!OS) {
|
if (!OS) {
|
||||||
OSFile = OutFile;
|
OSFile = OutFile;
|
||||||
OS.reset(new llvm::raw_fd_ostream(
|
OS.reset(new llvm::raw_fd_ostream(
|
||||||
OSFile.c_str(), Error,
|
OSFile, Error,
|
||||||
(Binary ? llvm::sys::fs::F_None : llvm::sys::fs::F_Text)));
|
(Binary ? llvm::sys::fs::F_None : llvm::sys::fs::F_Text)));
|
||||||
if (!Error.empty())
|
if (Error)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1136,9 +1127,8 @@ static void checkConfigMacro(Preprocessor &PP, StringRef ConfigMacro,
|
||||||
|
|
||||||
/// \brief Write a new timestamp file with the given path.
|
/// \brief Write a new timestamp file with the given path.
|
||||||
static void writeTimestampFile(StringRef TimestampFile) {
|
static void writeTimestampFile(StringRef TimestampFile) {
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
llvm::raw_fd_ostream Out(TimestampFile.str().c_str(), ErrorInfo,
|
llvm::raw_fd_ostream Out(TimestampFile.str(), EC, llvm::sys::fs::F_None);
|
||||||
llvm::sys::fs::F_None);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Prune the module cache of modules that haven't been accessed in
|
/// \brief Prune the module cache of modules that haven't been accessed in
|
||||||
|
|
|
@ -297,11 +297,11 @@ void DFGImpl::OutputDependencyFile() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Err;
|
std::error_code EC;
|
||||||
llvm::raw_fd_ostream OS(OutputFile.c_str(), Err, llvm::sys::fs::F_Text);
|
llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_Text);
|
||||||
if (!Err.empty()) {
|
if (EC) {
|
||||||
PP->getDiagnostics().Report(diag::err_fe_error_opening)
|
PP->getDiagnostics().Report(diag::err_fe_error_opening) << OutputFile
|
||||||
<< OutputFile << Err;
|
<< EC.message();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,11 +96,11 @@ DependencyGraphCallback::writeNodeReference(raw_ostream &OS,
|
||||||
}
|
}
|
||||||
|
|
||||||
void DependencyGraphCallback::OutputGraphFile() {
|
void DependencyGraphCallback::OutputGraphFile() {
|
||||||
std::string Err;
|
std::error_code EC;
|
||||||
llvm::raw_fd_ostream OS(OutputFile.c_str(), Err, llvm::sys::fs::F_Text);
|
llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_Text);
|
||||||
if (!Err.empty()) {
|
if (EC) {
|
||||||
PP->getDiagnostics().Report(diag::err_fe_error_opening)
|
PP->getDiagnostics().Report(diag::err_fe_error_opening) << OutputFile
|
||||||
<< OutputFile << Err;
|
<< EC.message();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -534,9 +534,9 @@ void DumpModuleInfoAction::ExecuteAction() {
|
||||||
std::unique_ptr<llvm::raw_fd_ostream> OutFile;
|
std::unique_ptr<llvm::raw_fd_ostream> OutFile;
|
||||||
StringRef OutputFileName = getCompilerInstance().getFrontendOpts().OutputFile;
|
StringRef OutputFileName = getCompilerInstance().getFrontendOpts().OutputFile;
|
||||||
if (!OutputFileName.empty() && OutputFileName != "-") {
|
if (!OutputFileName.empty() && OutputFileName != "-") {
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
OutFile.reset(new llvm::raw_fd_ostream(OutputFileName.str().c_str(),
|
OutFile.reset(new llvm::raw_fd_ostream(OutputFileName.str(), EC,
|
||||||
ErrorInfo, llvm::sys::fs::F_Text));
|
llvm::sys::fs::F_Text));
|
||||||
}
|
}
|
||||||
llvm::raw_ostream &Out = OutFile.get()? *OutFile.get() : llvm::outs();
|
llvm::raw_ostream &Out = OutFile.get()? *OutFile.get() : llvm::outs();
|
||||||
|
|
||||||
|
|
|
@ -54,13 +54,12 @@ void clang::AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders,
|
||||||
|
|
||||||
// Open the output file, if used.
|
// Open the output file, if used.
|
||||||
if (!OutputPath.empty()) {
|
if (!OutputPath.empty()) {
|
||||||
std::string Error;
|
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().c_str(), Error,
|
OutputPath.str(), EC, llvm::sys::fs::F_Append | llvm::sys::fs::F_Text);
|
||||||
llvm::sys::fs::F_Append | llvm::sys::fs::F_Text);
|
if (EC) {
|
||||||
if (!Error.empty()) {
|
PP.getDiagnostics().Report(clang::diag::warn_fe_cc_print_header_failure)
|
||||||
PP.getDiagnostics().Report(
|
<< EC.message();
|
||||||
clang::diag::warn_fe_cc_print_header_failure) << Error;
|
|
||||||
delete OS;
|
delete OS;
|
||||||
} else {
|
} else {
|
||||||
OS->SetUnbuffered();
|
OS->SetUnbuffered();
|
||||||
|
|
|
@ -48,9 +48,9 @@ void ModuleDependencyCollector::writeFileMap() {
|
||||||
SmallString<256> Dest = getDest();
|
SmallString<256> Dest = getDest();
|
||||||
llvm::sys::path::append(Dest, "vfs.yaml");
|
llvm::sys::path::append(Dest, "vfs.yaml");
|
||||||
|
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
llvm::raw_fd_ostream OS(Dest.c_str(), ErrorInfo, llvm::sys::fs::F_Text);
|
llvm::raw_fd_ostream OS(Dest, EC, llvm::sys::fs::F_Text);
|
||||||
if (!ErrorInfo.empty()) {
|
if (EC) {
|
||||||
setHasErrors();
|
setHasErrors();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,17 +86,16 @@ bool FixItRewriter::WriteFixedFiles(
|
||||||
const FileEntry *Entry = Rewrite.getSourceMgr().getFileEntryForID(I->first);
|
const FileEntry *Entry = Rewrite.getSourceMgr().getFileEntryForID(I->first);
|
||||||
int fd;
|
int fd;
|
||||||
std::string Filename = FixItOpts->RewriteFilename(Entry->getName(), fd);
|
std::string Filename = FixItOpts->RewriteFilename(Entry->getName(), fd);
|
||||||
std::string Err;
|
std::error_code EC;
|
||||||
std::unique_ptr<llvm::raw_fd_ostream> OS;
|
std::unique_ptr<llvm::raw_fd_ostream> OS;
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
OS.reset(new llvm::raw_fd_ostream(fd, /*shouldClose=*/true));
|
OS.reset(new llvm::raw_fd_ostream(fd, /*shouldClose=*/true));
|
||||||
} else {
|
} else {
|
||||||
OS.reset(new llvm::raw_fd_ostream(Filename.c_str(), Err,
|
OS.reset(new llvm::raw_fd_ostream(Filename, EC, llvm::sys::fs::F_None));
|
||||||
llvm::sys::fs::F_None));
|
|
||||||
}
|
}
|
||||||
if (!Err.empty()) {
|
if (EC) {
|
||||||
Diags.Report(clang::diag::err_fe_unable_to_open_output)
|
Diags.Report(clang::diag::err_fe_unable_to_open_output) << Filename
|
||||||
<< Filename << Err;
|
<< EC.message();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
RewriteBuffer &RewriteBuf = I->second;
|
RewriteBuffer &RewriteBuf = I->second;
|
||||||
|
|
|
@ -3521,10 +3521,9 @@ bool ASTReader::isGlobalIndexUnavailable() const {
|
||||||
static void updateModuleTimestamp(ModuleFile &MF) {
|
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::string ErrorInfo;
|
std::error_code EC;
|
||||||
llvm::raw_fd_ostream OS(TimestampFilename.c_str(), ErrorInfo,
|
llvm::raw_fd_ostream OS(TimestampFilename, EC, llvm::sys::fs::F_Text);
|
||||||
llvm::sys::fs::F_Text);
|
if (EC)
|
||||||
if (!ErrorInfo.empty())
|
|
||||||
return;
|
return;
|
||||||
OS << "Timestamp file\n";
|
OS << "Timestamp file\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -338,10 +338,10 @@ void PlistDiagnostics::FlushDiagnosticsImpl(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the file.
|
// Open the file.
|
||||||
std::string ErrMsg;
|
std::error_code EC;
|
||||||
llvm::raw_fd_ostream o(OutputFile.c_str(), ErrMsg, llvm::sys::fs::F_Text);
|
llvm::raw_fd_ostream o(OutputFile, EC, llvm::sys::fs::F_Text);
|
||||||
if (!ErrMsg.empty()) {
|
if (EC) {
|
||||||
llvm::errs() << "warning: could not create file: " << OutputFile << '\n';
|
llvm::errs() << "warning: could not create file: " << EC.message() << '\n';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// RUN: not %clang_cc1 -emit-llvm -o %S/doesnotexist/somename %s 2> %t
|
// RUN: not %clang_cc1 -emit-llvm -o %S/doesnotexist/somename %s 2> %t
|
||||||
// RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s
|
// RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s
|
||||||
|
|
||||||
// OUTPUTFAIL: Error opening output file '{{.*}}doesnotexist{{.*}}'
|
// OUTPUTFAIL: error: unable to open output file '{{.*}}/test/Frontend/doesnotexist/somename': 'No such file or directory'
|
||||||
|
|
|
@ -262,13 +262,12 @@ static formatted_raw_ostream *GetOutputStream(AssemblerInvocation &Opts,
|
||||||
if (Opts.OutputPath != "-")
|
if (Opts.OutputPath != "-")
|
||||||
sys::RemoveFileOnSignal(Opts.OutputPath);
|
sys::RemoveFileOnSignal(Opts.OutputPath);
|
||||||
|
|
||||||
std::string Error;
|
std::error_code EC;
|
||||||
raw_fd_ostream *Out =
|
raw_fd_ostream *Out = new raw_fd_ostream(
|
||||||
new raw_fd_ostream(Opts.OutputPath.c_str(), Error,
|
Opts.OutputPath, EC, (Binary ? sys::fs::F_None : sys::fs::F_Text));
|
||||||
(Binary ? sys::fs::F_None : sys::fs::F_Text));
|
if (EC) {
|
||||||
if (!Error.empty()) {
|
Diags.Report(diag::err_fe_unable_to_open_output) << Opts.OutputPath
|
||||||
Diags.Report(diag::err_fe_unable_to_open_output)
|
<< EC.message();
|
||||||
<< Opts.OutputPath << Error;
|
|
||||||
delete Out;
|
delete Out;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue