forked from OSchip/llvm-project
Modernize raw_fd_ostream's constructor a bit.
Take a StringRef instead of a "const char *". Take a "std::error_code &" instead of a "std::string &" for error. A create static method would be even better, but this patch is already a bit too big. llvm-svn: 216393
This commit is contained in:
parent
b709222b8a
commit
3fd1e9933f
|
@ -107,9 +107,8 @@ int main(int argc, char **argv) {
|
||||||
OutputFilename = base+".bc";
|
OutputFilename = base+".bc";
|
||||||
}
|
}
|
||||||
if (OutputFilename != "-") {
|
if (OutputFilename != "-") {
|
||||||
std::string ErrInfo;
|
std::error_code EC;
|
||||||
out = new raw_fd_ostream(OutputFilename.c_str(), ErrInfo,
|
out = new raw_fd_ostream(OutputFilename, EC, sys::fs::F_None);
|
||||||
sys::fs::F_None);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,15 +66,15 @@ public:
|
||||||
bool runOnFunction(Function &F) override {
|
bool runOnFunction(Function &F) override {
|
||||||
GraphT Graph = AnalysisGraphTraitsT::getGraph(&getAnalysis<AnalysisT>());
|
GraphT Graph = AnalysisGraphTraitsT::getGraph(&getAnalysis<AnalysisT>());
|
||||||
std::string Filename = Name + "." + F.getName().str() + ".dot";
|
std::string Filename = Name + "." + F.getName().str() + ".dot";
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
|
|
||||||
errs() << "Writing '" << Filename << "'...";
|
errs() << "Writing '" << Filename << "'...";
|
||||||
|
|
||||||
raw_fd_ostream File(Filename.c_str(), ErrorInfo, sys::fs::F_Text);
|
raw_fd_ostream File(Filename, EC, sys::fs::F_Text);
|
||||||
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";
|
||||||
|
|
||||||
if (ErrorInfo.empty())
|
if (!EC)
|
||||||
WriteGraph(File, Graph, IsSimple, Title);
|
WriteGraph(File, Graph, IsSimple, Title);
|
||||||
else
|
else
|
||||||
errs() << " error opening file for writing!";
|
errs() << " error opening file for writing!";
|
||||||
|
@ -129,14 +129,14 @@ public:
|
||||||
bool runOnModule(Module &M) override {
|
bool runOnModule(Module &M) override {
|
||||||
GraphT Graph = AnalysisGraphTraitsT::getGraph(&getAnalysis<AnalysisT>());
|
GraphT Graph = AnalysisGraphTraitsT::getGraph(&getAnalysis<AnalysisT>());
|
||||||
std::string Filename = Name + ".dot";
|
std::string Filename = Name + ".dot";
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
|
|
||||||
errs() << "Writing '" << Filename << "'...";
|
errs() << "Writing '" << Filename << "'...";
|
||||||
|
|
||||||
raw_fd_ostream File(Filename.c_str(), ErrorInfo, sys::fs::F_Text);
|
raw_fd_ostream File(Filename, EC, sys::fs::F_Text);
|
||||||
std::string Title = DOTGraphTraits<GraphT>::getGraphName(Graph);
|
std::string Title = DOTGraphTraits<GraphT>::getGraphName(Graph);
|
||||||
|
|
||||||
if (ErrorInfo.empty())
|
if (!EC)
|
||||||
WriteGraph(File, Graph, IsSimple, Title);
|
WriteGraph(File, Graph, IsSimple, Title);
|
||||||
else
|
else
|
||||||
errs() << " error opening file for writing!";
|
errs() << " error opening file for writing!";
|
||||||
|
|
|
@ -29,13 +29,13 @@ class tool_output_file {
|
||||||
/// destructed after the raw_fd_ostream is destructed. It installs
|
/// destructed after the raw_fd_ostream is destructed. It installs
|
||||||
/// cleanups in its constructor and uninstalls them in its destructor.
|
/// cleanups in its constructor and uninstalls them in its destructor.
|
||||||
class CleanupInstaller {
|
class CleanupInstaller {
|
||||||
/// Filename - The name of the file.
|
/// The name of the file.
|
||||||
std::string Filename;
|
std::string Filename;
|
||||||
public:
|
public:
|
||||||
/// Keep - The flag which indicates whether we should not delete the file.
|
/// The flag which indicates whether we should not delete the file.
|
||||||
bool Keep;
|
bool Keep;
|
||||||
|
|
||||||
explicit CleanupInstaller(const char *filename);
|
explicit CleanupInstaller(StringRef ilename);
|
||||||
~CleanupInstaller();
|
~CleanupInstaller();
|
||||||
} Installer;
|
} Installer;
|
||||||
|
|
||||||
|
@ -44,12 +44,12 @@ class tool_output_file {
|
||||||
raw_fd_ostream OS;
|
raw_fd_ostream OS;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// tool_output_file - This constructor's arguments are passed to
|
/// This constructor's arguments are passed to to raw_fd_ostream's
|
||||||
/// to raw_fd_ostream's constructor.
|
/// constructor.
|
||||||
tool_output_file(const char *filename, std::string &ErrorInfo,
|
tool_output_file(StringRef Filename, std::error_code &EC,
|
||||||
sys::fs::OpenFlags Flags);
|
sys::fs::OpenFlags Flags);
|
||||||
|
|
||||||
tool_output_file(const char *Filename, int FD);
|
tool_output_file(StringRef Filename, int FD);
|
||||||
|
|
||||||
/// os - Return the contained raw_fd_ostream.
|
/// os - Return the contained raw_fd_ostream.
|
||||||
raw_fd_ostream &os() { return OS; }
|
raw_fd_ostream &os() { return OS; }
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
#include "llvm/Support/DataTypes.h"
|
#include "llvm/Support/DataTypes.h"
|
||||||
|
#include <system_error>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class format_object_base;
|
class format_object_base;
|
||||||
|
@ -341,17 +342,17 @@ class raw_fd_ostream : public raw_ostream {
|
||||||
void error_detected() { Error = true; }
|
void error_detected() { Error = true; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// raw_fd_ostream - Open the specified file for writing. If an error occurs,
|
/// Open the specified file for writing. If an error occurs, information
|
||||||
/// information about the error is put into ErrorInfo, and the stream should
|
/// about the error is put into EC, and the stream should be immediately
|
||||||
/// be immediately destroyed; the string will be empty if no error occurred.
|
/// destroyed;
|
||||||
/// This allows optional flags to control how the file will be opened.
|
/// \p Flags allows optional flags to control how the file will be opened.
|
||||||
///
|
///
|
||||||
/// As a special case, if Filename is "-", then the stream will use
|
/// As a special case, if Filename is "-", then the stream will use
|
||||||
/// STDOUT_FILENO instead of opening a file. Note that it will still consider
|
/// STDOUT_FILENO instead of opening a file. Note that it will still consider
|
||||||
/// itself to own the file descriptor. In particular, it will close the
|
/// itself to own the file descriptor. In particular, it will close the
|
||||||
/// file descriptor when it is done (this is necessary to detect
|
/// file descriptor when it is done (this is necessary to detect
|
||||||
/// output errors).
|
/// output errors).
|
||||||
raw_fd_ostream(const char *Filename, std::string &ErrorInfo,
|
raw_fd_ostream(StringRef Filename, std::error_code &EC,
|
||||||
sys::fs::OpenFlags Flags);
|
sys::fs::OpenFlags Flags);
|
||||||
|
|
||||||
/// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If
|
/// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If
|
||||||
|
|
|
@ -80,10 +80,10 @@ namespace {
|
||||||
std::string Filename = "cfg." + F.getName().str() + ".dot";
|
std::string Filename = "cfg." + F.getName().str() + ".dot";
|
||||||
errs() << "Writing '" << Filename << "'...";
|
errs() << "Writing '" << Filename << "'...";
|
||||||
|
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
raw_fd_ostream File(Filename.c_str(), ErrorInfo, sys::fs::F_Text);
|
raw_fd_ostream File(Filename, EC, sys::fs::F_Text);
|
||||||
|
|
||||||
if (ErrorInfo.empty())
|
if (!EC)
|
||||||
WriteGraph(File, (const Function*)&F);
|
WriteGraph(File, (const Function*)&F);
|
||||||
else
|
else
|
||||||
errs() << " error opening file for writing!";
|
errs() << " error opening file for writing!";
|
||||||
|
@ -114,10 +114,10 @@ namespace {
|
||||||
std::string Filename = "cfg." + F.getName().str() + ".dot";
|
std::string Filename = "cfg." + F.getName().str() + ".dot";
|
||||||
errs() << "Writing '" << Filename << "'...";
|
errs() << "Writing '" << Filename << "'...";
|
||||||
|
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
raw_fd_ostream File(Filename.c_str(), ErrorInfo, sys::fs::F_Text);
|
raw_fd_ostream File(Filename, EC, sys::fs::F_Text);
|
||||||
|
|
||||||
if (ErrorInfo.empty())
|
if (!EC)
|
||||||
WriteGraph(File, (const Function*)&F, true);
|
WriteGraph(File, (const Function*)&F, true);
|
||||||
else
|
else
|
||||||
errs() << " error opening file for writing!";
|
errs() << " error opening file for writing!";
|
||||||
|
|
|
@ -18,10 +18,10 @@ using namespace llvm;
|
||||||
/*===-- Operations on modules ---------------------------------------------===*/
|
/*===-- Operations on modules ---------------------------------------------===*/
|
||||||
|
|
||||||
int LLVMWriteBitcodeToFile(LLVMModuleRef M, const char *Path) {
|
int LLVMWriteBitcodeToFile(LLVMModuleRef M, const char *Path) {
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
raw_fd_ostream OS(Path, ErrorInfo, sys::fs::F_None);
|
raw_fd_ostream OS(Path, EC, sys::fs::F_None);
|
||||||
|
|
||||||
if (!ErrorInfo.empty())
|
if (EC)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
WriteBitcodeToFile(unwrap(M), OS);
|
WriteBitcodeToFile(unwrap(M), OS);
|
||||||
|
|
|
@ -276,11 +276,12 @@ void MachineFunction::verify(Pass *p, const char *Banner) const {
|
||||||
bool MachineVerifier::runOnMachineFunction(MachineFunction &MF) {
|
bool MachineVerifier::runOnMachineFunction(MachineFunction &MF) {
|
||||||
raw_ostream *OutFile = nullptr;
|
raw_ostream *OutFile = nullptr;
|
||||||
if (OutFileName) {
|
if (OutFileName) {
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
OutFile = new raw_fd_ostream(OutFileName, ErrorInfo,
|
OutFile = new raw_fd_ostream(OutFileName, EC,
|
||||||
sys::fs::F_Append | sys::fs::F_Text);
|
sys::fs::F_Append | sys::fs::F_Text);
|
||||||
if (!ErrorInfo.empty()) {
|
if (EC) {
|
||||||
errs() << "Error opening '" << OutFileName << "': " << ErrorInfo << '\n';
|
errs() << "Error opening '" << OutFileName << "': " << EC.message()
|
||||||
|
<< '\n';
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -587,8 +587,8 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) {
|
||||||
std::ostringstream rs;
|
std::ostringstream rs;
|
||||||
rs << round;
|
rs << round;
|
||||||
std::string graphFileName(fqn + "." + rs.str() + ".pbqpgraph");
|
std::string graphFileName(fqn + "." + rs.str() + ".pbqpgraph");
|
||||||
std::string tmp;
|
std::error_code EC;
|
||||||
raw_fd_ostream os(graphFileName.c_str(), tmp, sys::fs::F_Text);
|
raw_fd_ostream os(graphFileName, EC, sys::fs::F_Text);
|
||||||
DEBUG(dbgs() << "Dumping graph for round " << round << " to \""
|
DEBUG(dbgs() << "Dumping graph for round " << round << " to \""
|
||||||
<< graphFileName << "\"\n");
|
<< graphFileName << "\"\n");
|
||||||
problem->getGraph().dump(os);
|
problem->getGraph().dump(os);
|
||||||
|
|
|
@ -183,20 +183,22 @@ void LLVMDumpModule(LLVMModuleRef M) {
|
||||||
|
|
||||||
LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
|
LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
|
||||||
char **ErrorMessage) {
|
char **ErrorMessage) {
|
||||||
std::string error;
|
std::error_code EC;
|
||||||
raw_fd_ostream dest(Filename, error, sys::fs::F_Text);
|
raw_fd_ostream dest(Filename, EC, sys::fs::F_Text);
|
||||||
if (!error.empty()) {
|
if (EC) {
|
||||||
*ErrorMessage = strdup(error.c_str());
|
*ErrorMessage = strdup(EC.message().c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unwrap(M)->print(dest, nullptr);
|
unwrap(M)->print(dest, nullptr);
|
||||||
|
|
||||||
if (!error.empty()) {
|
dest.close();
|
||||||
*ErrorMessage = strdup(error.c_str());
|
|
||||||
|
if (dest.has_error()) {
|
||||||
|
*ErrorMessage = strdup("Error printing to file");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
dest.flush();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -517,11 +517,11 @@ FileInfo::openCoveragePath(StringRef CoveragePath) {
|
||||||
if (Options.NoOutput)
|
if (Options.NoOutput)
|
||||||
return llvm::make_unique<raw_null_ostream>();
|
return llvm::make_unique<raw_null_ostream>();
|
||||||
|
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
auto OS = llvm::make_unique<raw_fd_ostream>(CoveragePath.str().c_str(),
|
auto OS = llvm::make_unique<raw_fd_ostream>(CoveragePath.str(), EC,
|
||||||
ErrorInfo, sys::fs::F_Text);
|
sys::fs::F_Text);
|
||||||
if (!ErrorInfo.empty()) {
|
if (EC) {
|
||||||
errs() << ErrorInfo << "\n";
|
errs() << EC.message() << "\n";
|
||||||
return llvm::make_unique<raw_null_ostream>();
|
return llvm::make_unique<raw_null_ostream>();
|
||||||
}
|
}
|
||||||
return std::move(OS);
|
return std::move(OS);
|
||||||
|
|
|
@ -163,9 +163,9 @@ bool LTOCodeGenerator::writeMergedModules(const char *path,
|
||||||
applyScopeRestrictions();
|
applyScopeRestrictions();
|
||||||
|
|
||||||
// create output file
|
// create output file
|
||||||
std::string ErrInfo;
|
std::error_code EC;
|
||||||
tool_output_file Out(path, ErrInfo, sys::fs::F_None);
|
tool_output_file Out(path, EC, sys::fs::F_None);
|
||||||
if (!ErrInfo.empty()) {
|
if (EC) {
|
||||||
errMsg = "could not open bitcode file for writing: ";
|
errMsg = "could not open bitcode file for writing: ";
|
||||||
errMsg += path;
|
errMsg += path;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -638,13 +638,13 @@ bool DarwinAsmParser::parseDirectiveSecureLogUnique(StringRef, SMLoc IDLoc) {
|
||||||
// Open the secure log file if we haven't already.
|
// Open the secure log file if we haven't already.
|
||||||
raw_ostream *OS = getContext().getSecureLog();
|
raw_ostream *OS = getContext().getSecureLog();
|
||||||
if (!OS) {
|
if (!OS) {
|
||||||
std::string Err;
|
std::error_code EC;
|
||||||
OS = new raw_fd_ostream(SecureLogFile, Err,
|
OS = new raw_fd_ostream(SecureLogFile, EC,
|
||||||
sys::fs::F_Append | sys::fs::F_Text);
|
sys::fs::F_Append | sys::fs::F_Text);
|
||||||
if (!Err.empty()) {
|
if (EC) {
|
||||||
delete OS;
|
delete OS;
|
||||||
return Error(IDLoc, Twine("can't open secure log file: ") +
|
return Error(IDLoc, Twine("can't open secure log file: ") +
|
||||||
SecureLogFile + " (" + Err + ")");
|
SecureLogFile + " (" + EC.message() + ")");
|
||||||
}
|
}
|
||||||
getContext().setSecureLog(OS);
|
getContext().setSecureLog(OS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,10 +66,10 @@ raw_ostream *llvm::CreateInfoOutputFile() {
|
||||||
// each time -stats or -time-passes wants to print output to it. To
|
// each time -stats or -time-passes wants to print output to it. To
|
||||||
// compensate for this, the test-suite Makefiles have code to delete the
|
// compensate for this, the test-suite Makefiles have code to delete the
|
||||||
// info output file before running commands which write to it.
|
// info output file before running commands which write to it.
|
||||||
std::string Error;
|
std::error_code EC;
|
||||||
raw_ostream *Result = new raw_fd_ostream(
|
raw_ostream *Result = new raw_fd_ostream(OutputFilename, EC,
|
||||||
OutputFilename.c_str(), Error, sys::fs::F_Append | sys::fs::F_Text);
|
sys::fs::F_Append | sys::fs::F_Text);
|
||||||
if (Error.empty())
|
if (!EC)
|
||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
errs() << "Error opening info-output-file '"
|
errs() << "Error opening info-output-file '"
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
#include "llvm/Support/Signals.h"
|
#include "llvm/Support/Signals.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
tool_output_file::CleanupInstaller::CleanupInstaller(const char *filename)
|
tool_output_file::CleanupInstaller::CleanupInstaller(StringRef Filename)
|
||||||
: Filename(filename), Keep(false) {
|
: Filename(Filename), Keep(false) {
|
||||||
// Arrange for the file to be deleted if the process is killed.
|
// Arrange for the file to be deleted if the process is killed.
|
||||||
if (Filename != "-")
|
if (Filename != "-")
|
||||||
sys::RemoveFileOnSignal(Filename);
|
sys::RemoveFileOnSignal(Filename);
|
||||||
|
@ -34,14 +34,13 @@ tool_output_file::CleanupInstaller::~CleanupInstaller() {
|
||||||
sys::DontRemoveFileOnSignal(Filename);
|
sys::DontRemoveFileOnSignal(Filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
tool_output_file::tool_output_file(const char *filename, std::string &ErrorInfo,
|
tool_output_file::tool_output_file(StringRef Filename, std::error_code &EC,
|
||||||
sys::fs::OpenFlags Flags)
|
sys::fs::OpenFlags Flags)
|
||||||
: Installer(filename), OS(filename, ErrorInfo, Flags) {
|
: Installer(Filename), OS(Filename, EC, Flags) {
|
||||||
// If open fails, no cleanup is needed.
|
// If open fails, no cleanup is needed.
|
||||||
if (!ErrorInfo.empty())
|
if (EC)
|
||||||
Installer.Keep = true;
|
Installer.Keep = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
tool_output_file::tool_output_file(const char *Filename, int FD)
|
tool_output_file::tool_output_file(StringRef Filename, int FD)
|
||||||
: Installer(Filename), OS(FD, true) {
|
: Installer(Filename), OS(FD, true) {}
|
||||||
}
|
|
||||||
|
|
|
@ -426,20 +426,14 @@ void format_object_base::home() {
|
||||||
// raw_fd_ostream
|
// raw_fd_ostream
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// raw_fd_ostream - Open the specified file for writing. If an error
|
raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
|
||||||
/// occurs, information about the error is put into ErrorInfo, and the
|
|
||||||
/// stream should be immediately destroyed; the string will be empty
|
|
||||||
/// if no error occurred.
|
|
||||||
raw_fd_ostream::raw_fd_ostream(const char *Filename, std::string &ErrorInfo,
|
|
||||||
sys::fs::OpenFlags Flags)
|
sys::fs::OpenFlags Flags)
|
||||||
: Error(false), UseAtomicWrites(false), pos(0) {
|
: Error(false), UseAtomicWrites(false), pos(0) {
|
||||||
assert(Filename && "Filename is null");
|
EC = std::error_code();
|
||||||
ErrorInfo.clear();
|
|
||||||
|
|
||||||
// Handle "-" as stdout. Note that when we do this, we consider ourself
|
// Handle "-" as stdout. Note that when we do this, we consider ourself
|
||||||
// the owner of stdout. This means that we can do things like close the
|
// the owner of stdout. This means that we can do things like close the
|
||||||
// file descriptor when we're done and set the "binary" flag globally.
|
// file descriptor when we're done and set the "binary" flag globally.
|
||||||
if (Filename[0] == '-' && Filename[1] == 0) {
|
if (Filename == "-") {
|
||||||
FD = STDOUT_FILENO;
|
FD = STDOUT_FILENO;
|
||||||
// If user requested binary then put stdout into binary mode if
|
// If user requested binary then put stdout into binary mode if
|
||||||
// possible.
|
// possible.
|
||||||
|
@ -450,11 +444,9 @@ raw_fd_ostream::raw_fd_ostream(const char *Filename, std::string &ErrorInfo,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::error_code EC = sys::fs::openFileForWrite(Filename, FD, Flags);
|
EC = sys::fs::openFileForWrite(Filename, FD, Flags);
|
||||||
|
|
||||||
if (EC) {
|
if (EC) {
|
||||||
ErrorInfo = "Error opening output file '" + std::string(Filename) + "': " +
|
|
||||||
EC.message();
|
|
||||||
ShouldClose = false;
|
ShouldClose = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,11 +56,11 @@ static int createDependencyFile(const TGParser &Parser, const char *argv0) {
|
||||||
errs() << argv0 << ": the option -d must be used together with -o\n";
|
errs() << argv0 << ": the option -d must be used together with -o\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
std::string Error;
|
std::error_code EC;
|
||||||
tool_output_file DepOut(DependFilename.c_str(), Error, sys::fs::F_Text);
|
tool_output_file DepOut(DependFilename, EC, sys::fs::F_Text);
|
||||||
if (!Error.empty()) {
|
if (EC) {
|
||||||
errs() << argv0 << ": error opening " << DependFilename
|
errs() << argv0 << ": error opening " << DependFilename << ":"
|
||||||
<< ":" << Error << "\n";
|
<< EC.message() << "\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
DepOut.os() << OutputFilename << ":";
|
DepOut.os() << OutputFilename << ":";
|
||||||
|
@ -101,11 +101,11 @@ int TableGenMain(char *argv0, TableGenMainFn *MainFn) {
|
||||||
if (Parser.ParseFile())
|
if (Parser.ParseFile())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
std::string Error;
|
std::error_code EC;
|
||||||
tool_output_file Out(OutputFilename.c_str(), Error, sys::fs::F_Text);
|
tool_output_file Out(OutputFilename, EC, sys::fs::F_Text);
|
||||||
if (!Error.empty()) {
|
if (EC) {
|
||||||
errs() << argv0 << ": error opening " << OutputFilename
|
errs() << argv0 << ": error opening " << OutputFilename << ":"
|
||||||
<< ":" << Error << "\n";
|
<< EC.message() << "\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!DependFilename.empty()) {
|
if (!DependFilename.empty()) {
|
||||||
|
|
|
@ -223,10 +223,10 @@ static LLVMBool LLVMTargetMachineEmit(LLVMTargetMachineRef T, LLVMModuleRef M,
|
||||||
|
|
||||||
LLVMBool LLVMTargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M,
|
LLVMBool LLVMTargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M,
|
||||||
char* Filename, LLVMCodeGenFileType codegen, char** ErrorMessage) {
|
char* Filename, LLVMCodeGenFileType codegen, char** ErrorMessage) {
|
||||||
std::string error;
|
std::error_code EC;
|
||||||
raw_fd_ostream dest(Filename, error, sys::fs::F_None);
|
raw_fd_ostream dest(Filename, EC, sys::fs::F_None);
|
||||||
if (!error.empty()) {
|
if (EC) {
|
||||||
*ErrorMessage = strdup(error.c_str());
|
*ErrorMessage = strdup(EC.message().c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
formatted_raw_ostream destf(dest);
|
formatted_raw_ostream destf(dest);
|
||||||
|
|
|
@ -525,11 +525,11 @@ std::string DebugIR::getPath() {
|
||||||
|
|
||||||
void DebugIR::writeDebugBitcode(const Module *M, int *fd) {
|
void DebugIR::writeDebugBitcode(const Module *M, int *fd) {
|
||||||
std::unique_ptr<raw_fd_ostream> Out;
|
std::unique_ptr<raw_fd_ostream> Out;
|
||||||
std::string error;
|
std::error_code EC;
|
||||||
|
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
std::string Path = getPath();
|
std::string Path = getPath();
|
||||||
Out.reset(new raw_fd_ostream(Path.c_str(), error, sys::fs::F_Text));
|
Out.reset(new raw_fd_ostream(Path, EC, sys::fs::F_Text));
|
||||||
DEBUG(dbgs() << "WRITING debug bitcode from Module " << M << " to file "
|
DEBUG(dbgs() << "WRITING debug bitcode from Module " << M << " to file "
|
||||||
<< Path << "\n");
|
<< Path << "\n");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -480,9 +480,8 @@ void GCOVProfiler::emitProfileNotes() {
|
||||||
// LTO, we'll generate the same .gcno files.
|
// LTO, we'll generate the same .gcno files.
|
||||||
|
|
||||||
DICompileUnit CU(CU_Nodes->getOperand(i));
|
DICompileUnit CU(CU_Nodes->getOperand(i));
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
raw_fd_ostream out(mangleName(CU, "gcno").c_str(), ErrorInfo,
|
raw_fd_ostream out(mangleName(CU, "gcno"), EC, sys::fs::F_None);
|
||||||
sys::fs::F_None);
|
|
||||||
std::string EdgeDestinations;
|
std::string EdgeDestinations;
|
||||||
|
|
||||||
DIArray SPs = CU.getSubprograms();
|
DIArray SPs = CU.getSubprograms();
|
||||||
|
|
|
@ -66,15 +66,15 @@ static bool writeProgramToFileAux(tool_output_file &Out, const Module *M) {
|
||||||
|
|
||||||
bool BugDriver::writeProgramToFile(const std::string &Filename, int FD,
|
bool BugDriver::writeProgramToFile(const std::string &Filename, int FD,
|
||||||
const Module *M) const {
|
const Module *M) const {
|
||||||
tool_output_file Out(Filename.c_str(), FD);
|
tool_output_file Out(Filename, FD);
|
||||||
return writeProgramToFileAux(Out, M);
|
return writeProgramToFileAux(Out, M);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BugDriver::writeProgramToFile(const std::string &Filename,
|
bool BugDriver::writeProgramToFile(const std::string &Filename,
|
||||||
const Module *M) const {
|
const Module *M) const {
|
||||||
std::string ErrInfo;
|
std::error_code EC;
|
||||||
tool_output_file Out(Filename.c_str(), ErrInfo, sys::fs::F_None);
|
tool_output_file Out(Filename, EC, sys::fs::F_None);
|
||||||
if (ErrInfo.empty())
|
if (!EC)
|
||||||
return writeProgramToFileAux(Out, M);
|
return writeProgramToFileAux(Out, M);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ bool BugDriver::runPasses(Module *Program,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tool_output_file InFile(InputFilename.c_str(), InputFD);
|
tool_output_file InFile(InputFilename, InputFD);
|
||||||
|
|
||||||
WriteBitcodeToFile(Program, InFile.os());
|
WriteBitcodeToFile(Program, InFile.os());
|
||||||
InFile.os().close();
|
InFile.os().close();
|
||||||
|
|
|
@ -775,9 +775,9 @@ static ld_plugin_status allSymbolsReadHook(raw_fd_ostream *ApiFile) {
|
||||||
else
|
else
|
||||||
path = output_name + ".bc";
|
path = output_name + ".bc";
|
||||||
{
|
{
|
||||||
std::string Error;
|
std::error_code EC;
|
||||||
raw_fd_ostream OS(path.c_str(), Error, sys::fs::OpenFlags::F_None);
|
raw_fd_ostream OS(path, EC, sys::fs::OpenFlags::F_None);
|
||||||
if (!Error.empty())
|
if (EC)
|
||||||
message(LDPL_FATAL, "Failed to write the output file.");
|
message(LDPL_FATAL, "Failed to write the output file.");
|
||||||
WriteBitcodeToFile(L.getModule(), OS);
|
WriteBitcodeToFile(L.getModule(), OS);
|
||||||
}
|
}
|
||||||
|
@ -799,11 +799,11 @@ static ld_plugin_status all_symbols_read_hook(void) {
|
||||||
if (!options::generate_api_file) {
|
if (!options::generate_api_file) {
|
||||||
Ret = allSymbolsReadHook(nullptr);
|
Ret = allSymbolsReadHook(nullptr);
|
||||||
} else {
|
} else {
|
||||||
std::string Error;
|
std::error_code EC;
|
||||||
raw_fd_ostream ApiFile("apifile.txt", Error, sys::fs::F_None);
|
raw_fd_ostream ApiFile("apifile.txt", EC, sys::fs::F_None);
|
||||||
if (!Error.empty())
|
if (EC)
|
||||||
message(LDPL_FATAL, "Unable to open apifile.txt for writing: %s",
|
message(LDPL_FATAL, "Unable to open apifile.txt for writing: %s",
|
||||||
Error.c_str());
|
EC.message().c_str());
|
||||||
Ret = allSymbolsReadHook(&ApiFile);
|
Ret = allSymbolsReadHook(&ApiFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,14 +159,13 @@ static tool_output_file *GetOutputStream(const char *TargetName,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the file.
|
// Open the file.
|
||||||
std::string error;
|
std::error_code EC;
|
||||||
sys::fs::OpenFlags OpenFlags = sys::fs::F_None;
|
sys::fs::OpenFlags OpenFlags = sys::fs::F_None;
|
||||||
if (!Binary)
|
if (!Binary)
|
||||||
OpenFlags |= sys::fs::F_Text;
|
OpenFlags |= sys::fs::F_Text;
|
||||||
tool_output_file *FDOut = new tool_output_file(OutputFilename.c_str(), error,
|
tool_output_file *FDOut = new tool_output_file(OutputFilename, EC, OpenFlags);
|
||||||
OpenFlags);
|
if (EC) {
|
||||||
if (!error.empty()) {
|
errs() << EC.message() << '\n';
|
||||||
errs() << error << '\n';
|
|
||||||
delete FDOut;
|
delete FDOut;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,13 +268,13 @@ public:
|
||||||
std::string CacheName;
|
std::string CacheName;
|
||||||
if (!getCacheFilename(ModuleID, CacheName))
|
if (!getCacheFilename(ModuleID, CacheName))
|
||||||
return;
|
return;
|
||||||
std::string errStr;
|
|
||||||
if (!CacheDir.empty()) { // Create user-defined cache dir.
|
if (!CacheDir.empty()) { // Create user-defined cache dir.
|
||||||
SmallString<128> dir(CacheName);
|
SmallString<128> dir(CacheName);
|
||||||
sys::path::remove_filename(dir);
|
sys::path::remove_filename(dir);
|
||||||
sys::fs::create_directories(Twine(dir));
|
sys::fs::create_directories(Twine(dir));
|
||||||
}
|
}
|
||||||
raw_fd_ostream outfile(CacheName.c_str(), errStr, sys::fs::F_None);
|
std::error_code EC;
|
||||||
|
raw_fd_ostream outfile(CacheName, EC, sys::fs::F_None);
|
||||||
outfile.write(Obj.getBufferStart(), Obj.getBufferSize());
|
outfile.write(Obj.getBufferStart(), Obj.getBufferSize());
|
||||||
outfile.close();
|
outfile.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,11 +69,11 @@ static void WriteOutputFile(const Module *M) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
std::unique_ptr<tool_output_file> Out(
|
std::unique_ptr<tool_output_file> Out(
|
||||||
new tool_output_file(OutputFilename.c_str(), ErrorInfo, sys::fs::F_None));
|
new tool_output_file(OutputFilename, EC, sys::fs::F_None));
|
||||||
if (!ErrorInfo.empty()) {
|
if (EC) {
|
||||||
errs() << ErrorInfo << '\n';
|
errs() << EC.message() << '\n';
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,11 +171,11 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
std::unique_ptr<tool_output_file> Out(
|
std::unique_ptr<tool_output_file> Out(
|
||||||
new tool_output_file(OutputFilename.c_str(), ErrorInfo, sys::fs::F_None));
|
new tool_output_file(OutputFilename, EC, sys::fs::F_None));
|
||||||
if (!ErrorInfo.empty()) {
|
if (EC) {
|
||||||
errs() << ErrorInfo << '\n';
|
errs() << EC.message() << '\n';
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -261,10 +261,10 @@ int main(int argc, char **argv) {
|
||||||
Passes.add(createStripDeadDebugInfoPass()); // Remove dead debug info
|
Passes.add(createStripDeadDebugInfoPass()); // Remove dead debug info
|
||||||
Passes.add(createStripDeadPrototypesPass()); // Remove dead func decls
|
Passes.add(createStripDeadPrototypesPass()); // Remove dead func decls
|
||||||
|
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
tool_output_file Out(OutputFilename.c_str(), ErrorInfo, sys::fs::F_None);
|
tool_output_file Out(OutputFilename, EC, sys::fs::F_None);
|
||||||
if (!ErrorInfo.empty()) {
|
if (EC) {
|
||||||
errs() << ErrorInfo << '\n';
|
errs() << EC.message() << '\n';
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,10 +110,10 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
if (DumpAsm) errs() << "Here's the assembly:\n" << *Composite;
|
if (DumpAsm) errs() << "Here's the assembly:\n" << *Composite;
|
||||||
|
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
tool_output_file Out(OutputFilename.c_str(), ErrorInfo, sys::fs::F_None);
|
tool_output_file Out(OutputFilename, EC, sys::fs::F_None);
|
||||||
if (!ErrorInfo.empty()) {
|
if (EC) {
|
||||||
errs() << ErrorInfo << '\n';
|
errs() << EC.message() << '\n';
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,11 +165,11 @@ int main(int argc, char **argv) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
raw_fd_ostream FileStream(OutputFilename.c_str(), ErrorInfo,
|
std::error_code EC;
|
||||||
sys::fs::F_None);
|
raw_fd_ostream FileStream(OutputFilename, EC, sys::fs::F_None);
|
||||||
if (!ErrorInfo.empty()) {
|
if (EC) {
|
||||||
errs() << argv[0] << ": error opening the file '" << OutputFilename
|
errs() << argv[0] << ": error opening the file '" << OutputFilename
|
||||||
<< "': " << ErrorInfo << "\n";
|
<< "': " << EC.message() << "\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,11 +208,11 @@ static tool_output_file *GetOutputStream() {
|
||||||
if (OutputFilename == "")
|
if (OutputFilename == "")
|
||||||
OutputFilename = "-";
|
OutputFilename = "-";
|
||||||
|
|
||||||
std::string Err;
|
std::error_code EC;
|
||||||
tool_output_file *Out =
|
tool_output_file *Out =
|
||||||
new tool_output_file(OutputFilename.c_str(), Err, sys::fs::F_None);
|
new tool_output_file(OutputFilename, EC, sys::fs::F_None);
|
||||||
if (!Err.empty()) {
|
if (EC) {
|
||||||
errs() << Err << '\n';
|
errs() << EC.message() << '\n';
|
||||||
delete Out;
|
delete Out;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,10 +202,10 @@ static const Target *getTarget(const ObjectFile *Obj = nullptr) {
|
||||||
static void emitDOTFile(const char *FileName, const MCFunction &f,
|
static void emitDOTFile(const char *FileName, const MCFunction &f,
|
||||||
MCInstPrinter *IP) {
|
MCInstPrinter *IP) {
|
||||||
// Start a new dot file.
|
// Start a new dot file.
|
||||||
std::string Error;
|
std::error_code EC;
|
||||||
raw_fd_ostream Out(FileName, Error, sys::fs::F_Text);
|
raw_fd_ostream Out(FileName, EC, sys::fs::F_Text);
|
||||||
if (!Error.empty()) {
|
if (EC) {
|
||||||
errs() << "llvm-objdump: warning: " << Error << '\n';
|
errs() << "llvm-objdump: warning: " << EC.message() << '\n';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,10 +386,10 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!YAMLCFG.empty()) {
|
if (!YAMLCFG.empty()) {
|
||||||
std::string Error;
|
std::error_code EC;
|
||||||
raw_fd_ostream YAMLOut(YAMLCFG.c_str(), Error, sys::fs::F_Text);
|
raw_fd_ostream YAMLOut(YAMLCFG, EC, sys::fs::F_Text);
|
||||||
if (!Error.empty()) {
|
if (EC) {
|
||||||
errs() << ToolName << ": warning: " << Error << '\n';
|
errs() << ToolName << ": warning: " << EC.message() << '\n';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mcmodule2yaml(YAMLOut, *Mod, *MII, *MRI);
|
mcmodule2yaml(YAMLOut, *Mod, *MII, *MRI);
|
||||||
|
|
|
@ -48,10 +48,10 @@ int merge_main(int argc, const char *argv[]) {
|
||||||
if (OutputFilename.compare("-") == 0)
|
if (OutputFilename.compare("-") == 0)
|
||||||
exitWithError("Cannot write indexed profdata format to stdout.");
|
exitWithError("Cannot write indexed profdata format to stdout.");
|
||||||
|
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
raw_fd_ostream Output(OutputFilename.data(), ErrorInfo, sys::fs::F_None);
|
raw_fd_ostream Output(OutputFilename.data(), EC, sys::fs::F_None);
|
||||||
if (!ErrorInfo.empty())
|
if (EC)
|
||||||
exitWithError(ErrorInfo, OutputFilename);
|
exitWithError(EC.message(), OutputFilename);
|
||||||
|
|
||||||
InstrProfWriter Writer;
|
InstrProfWriter Writer;
|
||||||
for (const auto &Filename : Inputs) {
|
for (const auto &Filename : Inputs) {
|
||||||
|
@ -97,10 +97,10 @@ int show_main(int argc, const char *argv[]) {
|
||||||
if (OutputFilename.empty())
|
if (OutputFilename.empty())
|
||||||
OutputFilename = "-";
|
OutputFilename = "-";
|
||||||
|
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
raw_fd_ostream OS(OutputFilename.data(), ErrorInfo, sys::fs::F_Text);
|
raw_fd_ostream OS(OutputFilename.data(), EC, sys::fs::F_Text);
|
||||||
if (!ErrorInfo.empty())
|
if (EC)
|
||||||
exitWithError(ErrorInfo, OutputFilename);
|
exitWithError(EC.message(), OutputFilename);
|
||||||
|
|
||||||
if (ShowAllFunctions && !ShowFunction.empty())
|
if (ShowAllFunctions && !ShowFunction.empty())
|
||||||
errs() << "warning: -function argument ignored: showing all functions\n";
|
errs() << "warning: -function argument ignored: showing all functions\n";
|
||||||
|
|
|
@ -704,11 +704,10 @@ int main(int argc, char **argv) {
|
||||||
if (OutputFilename.empty())
|
if (OutputFilename.empty())
|
||||||
OutputFilename = "-";
|
OutputFilename = "-";
|
||||||
|
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
Out.reset(new tool_output_file(OutputFilename.c_str(), ErrorInfo,
|
Out.reset(new tool_output_file(OutputFilename, EC, sys::fs::F_None));
|
||||||
sys::fs::F_None));
|
if (EC) {
|
||||||
if (!ErrorInfo.empty()) {
|
errs() << EC.message() << '\n';
|
||||||
errs() << ErrorInfo << '\n';
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -385,11 +385,10 @@ int main(int argc, char **argv) {
|
||||||
if (OutputFilename.empty())
|
if (OutputFilename.empty())
|
||||||
OutputFilename = "-";
|
OutputFilename = "-";
|
||||||
|
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
Out.reset(new tool_output_file(OutputFilename.c_str(), ErrorInfo,
|
Out.reset(new tool_output_file(OutputFilename, EC, sys::fs::F_None));
|
||||||
sys::fs::F_None));
|
if (EC) {
|
||||||
if (!ErrorInfo.empty()) {
|
errs() << EC.message() << '\n';
|
||||||
errs() << ErrorInfo << '\n';
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -470,11 +469,10 @@ int main(int argc, char **argv) {
|
||||||
if (OutputFilename.empty())
|
if (OutputFilename.empty())
|
||||||
OutputFilename = "-";
|
OutputFilename = "-";
|
||||||
|
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
Out.reset(new tool_output_file(OutputFilename.c_str(), ErrorInfo,
|
Out.reset(new tool_output_file(OutputFilename, EC, sys::fs::F_None));
|
||||||
sys::fs::F_None));
|
if (EC) {
|
||||||
if (!ErrorInfo.empty()) {
|
errs() << EC.message() << '\n';
|
||||||
errs() << ErrorInfo << '\n';
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,10 +123,10 @@ bool TempFile::init(const std::string &Ext) {
|
||||||
|
|
||||||
bool TempFile::writeBitcode(const Module &M) const {
|
bool TempFile::writeBitcode(const Module &M) const {
|
||||||
DEBUG(dbgs() << " - write bitcode\n");
|
DEBUG(dbgs() << " - write bitcode\n");
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
raw_fd_ostream OS(Filename.c_str(), ErrorInfo, sys::fs::F_None);
|
raw_fd_ostream OS(Filename, EC, sys::fs::F_None);
|
||||||
if (!ErrorInfo.empty()) {
|
if (EC) {
|
||||||
DEBUG(dbgs() << "error: " << ErrorInfo << "\n");
|
DEBUG(dbgs() << "error: " << EC.message() << "\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,10 +136,10 @@ bool TempFile::writeBitcode(const Module &M) const {
|
||||||
|
|
||||||
bool TempFile::writeAssembly(const Module &M) const {
|
bool TempFile::writeAssembly(const Module &M) const {
|
||||||
DEBUG(dbgs() << " - write assembly\n");
|
DEBUG(dbgs() << " - write assembly\n");
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
raw_fd_ostream OS(Filename.c_str(), ErrorInfo, sys::fs::F_Text);
|
raw_fd_ostream OS(Filename, EC, sys::fs::F_Text);
|
||||||
if (!ErrorInfo.empty()) {
|
if (EC) {
|
||||||
DEBUG(dbgs() << "error: " << ErrorInfo << "\n");
|
DEBUG(dbgs() << "error: " << EC.message() << "\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,11 +83,11 @@ int main(int argc, char **argv) {
|
||||||
if (OutputFilename.empty())
|
if (OutputFilename.empty())
|
||||||
OutputFilename = "-";
|
OutputFilename = "-";
|
||||||
|
|
||||||
std::string ErrorInfo;
|
std::error_code EC;
|
||||||
std::unique_ptr<tool_output_file> Out(
|
std::unique_ptr<tool_output_file> Out(
|
||||||
new tool_output_file(OutputFilename.c_str(), ErrorInfo, sys::fs::F_None));
|
new tool_output_file(OutputFilename, EC, sys::fs::F_None));
|
||||||
if (!ErrorInfo.empty()) {
|
if (EC) {
|
||||||
errs() << ErrorInfo << '\n';
|
errs() << EC.message() << '\n';
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -535,8 +535,8 @@ TEST_F(FileSystemTest, Magic) {
|
||||||
++i) {
|
++i) {
|
||||||
SmallString<128> file_pathname(TestDirectory);
|
SmallString<128> file_pathname(TestDirectory);
|
||||||
path::append(file_pathname, i->filename);
|
path::append(file_pathname, i->filename);
|
||||||
std::string ErrMsg;
|
std::error_code EC;
|
||||||
raw_fd_ostream file(file_pathname.c_str(), ErrMsg, sys::fs::F_None);
|
raw_fd_ostream file(file_pathname, EC, sys::fs::F_None);
|
||||||
ASSERT_FALSE(file.has_error());
|
ASSERT_FALSE(file.has_error());
|
||||||
StringRef magic(i->magic_str, i->magic_str_len);
|
StringRef magic(i->magic_str, i->magic_str_len);
|
||||||
file << magic;
|
file << magic;
|
||||||
|
@ -553,23 +553,23 @@ TEST_F(FileSystemTest, CarriageReturn) {
|
||||||
path::append(FilePathname, "test");
|
path::append(FilePathname, "test");
|
||||||
|
|
||||||
{
|
{
|
||||||
raw_fd_ostream File(FilePathname.c_str(), ErrMsg, sys::fs::F_Text);
|
raw_fd_ostream File(FilePathname, ErrMsg, sys::fs::F_Text);
|
||||||
EXPECT_EQ(ErrMsg, "");
|
EXPECT_EQ(ErrMsg, "");
|
||||||
File << '\n';
|
File << '\n';
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto Buf = MemoryBuffer::getFile(FilePathname.c_str());
|
auto Buf = MemoryBuffer::getFile(FilePathname);
|
||||||
EXPECT_TRUE((bool)Buf);
|
EXPECT_TRUE((bool)Buf);
|
||||||
EXPECT_EQ(Buf.get()->getBuffer(), "\r\n");
|
EXPECT_EQ(Buf.get()->getBuffer(), "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
raw_fd_ostream File(FilePathname.c_str(), ErrMsg, sys::fs::F_None);
|
raw_fd_ostream File(FilePathname, ErrMsg, sys::fs::F_None);
|
||||||
EXPECT_EQ(ErrMsg, "");
|
EXPECT_EQ(ErrMsg, "");
|
||||||
File << '\n';
|
File << '\n';
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto Buf = MemoryBuffer::getFile(FilePathname.c_str());
|
auto Buf = MemoryBuffer::getFile(FilePathname);
|
||||||
EXPECT_TRUE((bool)Buf);
|
EXPECT_TRUE((bool)Buf);
|
||||||
EXPECT_EQ(Buf.get()->getBuffer(), "\n");
|
EXPECT_EQ(Buf.get()->getBuffer(), "\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue