|
@@ -134,17 +134,17 @@ void CompilerInstance::setModuleDepCollector(
|
|
|
static void SetUpDiagnosticLog(DiagnosticOptions *DiagOpts,
|
|
|
const CodeGenOptions *CodeGenOpts,
|
|
|
DiagnosticsEngine &Diags) {
|
|
|
- std::string ErrorInfo;
|
|
|
+ std::error_code EC;
|
|
|
bool OwnsStream = false;
|
|
|
raw_ostream *OS = &llvm::errs();
|
|
|
if (DiagOpts->DiagnosticLogFile != "-") {
|
|
|
// Create the output stream.
|
|
|
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));
|
|
|
- if (!ErrorInfo.empty()) {
|
|
|
+ if (EC) {
|
|
|
Diags.Report(diag::warn_fe_cc_log_diagnostics_failure)
|
|
|
- << DiagOpts->DiagnosticLogFile << ErrorInfo;
|
|
|
+ << DiagOpts->DiagnosticLogFile << EC.message();
|
|
|
} else {
|
|
|
FileOS->SetUnbuffered();
|
|
|
FileOS->SetUseAtomicWrites(true);
|
|
@@ -164,14 +164,14 @@ static void SetUpDiagnosticLog(DiagnosticOptions *DiagOpts,
|
|
|
static void SetupSerializedDiagnostics(DiagnosticOptions *DiagOpts,
|
|
|
DiagnosticsEngine &Diags,
|
|
|
StringRef OutputFile) {
|
|
|
- std::string ErrorInfo;
|
|
|
+ std::error_code EC;
|
|
|
std::unique_ptr<llvm::raw_fd_ostream> OS;
|
|
|
- OS.reset(new llvm::raw_fd_ostream(OutputFile.str().c_str(), ErrorInfo,
|
|
|
- llvm::sys::fs::F_None));
|
|
|
+ OS.reset(
|
|
|
+ new llvm::raw_fd_ostream(OutputFile.str(), EC, llvm::sys::fs::F_None));
|
|
|
|
|
|
- if (!ErrorInfo.empty()) {
|
|
|
- Diags.Report(diag::warn_fe_serialized_diag_failure)
|
|
|
- << OutputFile << ErrorInfo;
|
|
|
+ if (EC) {
|
|
|
+ Diags.Report(diag::warn_fe_serialized_diag_failure) << OutputFile
|
|
|
+ << EC.message();
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -573,17 +573,14 @@ CompilerInstance::createOutputFile(StringRef OutputPath,
|
|
|
StringRef Extension,
|
|
|
bool UseTemporary,
|
|
|
bool CreateMissingDirectories) {
|
|
|
- std::string Error, OutputPathName, TempPathName;
|
|
|
- llvm::raw_fd_ostream *OS = createOutputFile(OutputPath, Error, Binary,
|
|
|
- RemoveFileOnSignal,
|
|
|
- InFile, Extension,
|
|
|
- UseTemporary,
|
|
|
- CreateMissingDirectories,
|
|
|
- &OutputPathName,
|
|
|
- &TempPathName);
|
|
|
+ std::string OutputPathName, TempPathName;
|
|
|
+ std::error_code EC;
|
|
|
+ llvm::raw_fd_ostream *OS = createOutputFile(
|
|
|
+ OutputPath, EC, Binary, RemoveFileOnSignal, InFile, Extension,
|
|
|
+ UseTemporary, CreateMissingDirectories, &OutputPathName, &TempPathName);
|
|
|
if (!OS) {
|
|
|
- getDiagnostics().Report(diag::err_fe_unable_to_open_output)
|
|
|
- << OutputPath << Error;
|
|
|
+ getDiagnostics().Report(diag::err_fe_unable_to_open_output) << OutputPath
|
|
|
+ << EC.message();
|
|
|
return nullptr;
|
|
|
}
|
|
|
|
|
@@ -595,17 +592,11 @@ CompilerInstance::createOutputFile(StringRef OutputPath,
|
|
|
return OS;
|
|
|
}
|
|
|
|
|
|
-llvm::raw_fd_ostream *
|
|
|
-CompilerInstance::createOutputFile(StringRef OutputPath,
|
|
|
- std::string &Error,
|
|
|
- bool Binary,
|
|
|
- bool RemoveFileOnSignal,
|
|
|
- StringRef InFile,
|
|
|
- StringRef Extension,
|
|
|
- bool UseTemporary,
|
|
|
- bool CreateMissingDirectories,
|
|
|
- std::string *ResultPathName,
|
|
|
- std::string *TempPathName) {
|
|
|
+llvm::raw_fd_ostream *CompilerInstance::createOutputFile(
|
|
|
+ StringRef OutputPath, std::error_code &Error, bool Binary,
|
|
|
+ bool RemoveFileOnSignal, StringRef InFile, StringRef Extension,
|
|
|
+ bool UseTemporary, bool CreateMissingDirectories,
|
|
|
+ std::string *ResultPathName, std::string *TempPathName) {
|
|
|
assert((!CreateMissingDirectories || UseTemporary) &&
|
|
|
"CreateMissingDirectories is only allowed when using temporary files");
|
|
|
|
|
@@ -674,9 +665,9 @@ CompilerInstance::createOutputFile(StringRef OutputPath,
|
|
|
if (!OS) {
|
|
|
OSFile = OutFile;
|
|
|
OS.reset(new llvm::raw_fd_ostream(
|
|
|
- OSFile.c_str(), Error,
|
|
|
+ OSFile, Error,
|
|
|
(Binary ? llvm::sys::fs::F_None : llvm::sys::fs::F_Text)));
|
|
|
- if (!Error.empty())
|
|
|
+ if (Error)
|
|
|
return nullptr;
|
|
|
}
|
|
|
|
|
@@ -1136,9 +1127,8 @@ static void checkConfigMacro(Preprocessor &PP, StringRef ConfigMacro,
|
|
|
|
|
|
/// \brief Write a new timestamp file with the given path.
|
|
|
static void writeTimestampFile(StringRef TimestampFile) {
|
|
|
- std::string ErrorInfo;
|
|
|
- llvm::raw_fd_ostream Out(TimestampFile.str().c_str(), ErrorInfo,
|
|
|
- llvm::sys::fs::F_None);
|
|
|
+ std::error_code EC;
|
|
|
+ llvm::raw_fd_ostream Out(TimestampFile.str(), EC, llvm::sys::fs::F_None);
|
|
|
}
|
|
|
|
|
|
/// \brief Prune the module cache of modules that haven't been accessed in
|