Update for raw_fd_ostream API changes. raw_fd_ostream now has a

Force flag to control whether the case of opening an existing
file is considered an error.

llvm-svn: 75802
This commit is contained in:
Dan Gohman 2009-07-15 17:32:18 +00:00
parent 607818a2c1
commit 74e3eb49ea
5 changed files with 11 additions and 6 deletions

View File

@ -149,7 +149,7 @@ void CXXRecordDecl::viewInheritance(ASTContext& Context) const {
llvm::errs() << "Writing '" << Filename.c_str() << "'... ";
llvm::raw_fd_ostream O(Filename.c_str(), false, ErrMsg);
llvm::raw_fd_ostream O(Filename.c_str(), false, /*Force=*/true, ErrMsg);
if (ErrMsg.empty()) {
InheritanceHierarchyWriter Writer(Context, O);

View File

@ -587,7 +587,8 @@ static ExplodedNodeImpl::Auditor* CreateUbiViz() {
llvm::OwningPtr<llvm::raw_fd_ostream> Stream;
std::string filename = Filename.toString();
Stream.reset(new llvm::raw_fd_ostream(filename.c_str(), false, ErrMsg));
Stream.reset(new llvm::raw_fd_ostream(filename.c_str(), false,
/*Force=*/true, ErrMsg));
if (!ErrMsg.empty())
return 0;

View File

@ -47,6 +47,7 @@ bool FixItRewriter::WriteFixedFile(const std::string &InFileName,
OutFile = new llvm::raw_fd_ostream(OutFileName.c_str(),
// set binary mode (critical for Windoze)
true,
/*Force=*/true,
Err);
OwnedStream.reset(OutFile);
} else if (InFileName == "-") {
@ -60,6 +61,7 @@ bool FixItRewriter::WriteFixedFile(const std::string &InFileName,
OutFile = new llvm::raw_fd_ostream(Path.toString().c_str(),
// set binary mode (critical for Windoze)
true,
/*Force=*/true,
Err);
OwnedStream.reset(OutFile);
}

View File

@ -319,7 +319,7 @@ PlistDiagnostics::~PlistDiagnostics() {
// Open the file.
std::string ErrMsg;
llvm::raw_fd_ostream o(OutputFile.c_str(), false, ErrMsg);
llvm::raw_fd_ostream o(OutputFile.c_str(), false, /*Force=*/true, ErrMsg);
if (!ErrMsg.empty()) {
llvm::errs() << "warning: could not creat file: " << OutputFile << '\n';
return;

View File

@ -1682,7 +1682,7 @@ static void SetUpBuildDumpLog(unsigned argc, char **argv,
std::string ErrorInfo;
BuildLogFile = new llvm::raw_fd_ostream(DumpBuildInformation.c_str(), false,
ErrorInfo);
/*Force=*/true, ErrorInfo);
if (!ErrorInfo.empty()) {
llvm::errs() << "error opening -dump-build-information file '"
@ -1735,7 +1735,8 @@ static llvm::raw_ostream* ComputeOutFile(const std::string& InFile,
llvm::sys::Program::ChangeStdoutToBinary();
} else {
std::string Error;
Ret = new llvm::raw_fd_ostream(OutFile.c_str(), Binary, Error);
Ret = new llvm::raw_fd_ostream(OutFile.c_str(), Binary,
/*Force=*/true, Error);
if (!Error.empty()) {
// FIXME: Don't fail this way.
llvm::cerr << "ERROR: " << Error << "\n";
@ -2276,7 +2277,8 @@ int main(int argc, char **argv) {
}
std::string ErrStr;
DependencyOS =
new llvm::raw_fd_ostream(DependencyFile.c_str(), false, ErrStr);
new llvm::raw_fd_ostream(DependencyFile.c_str(), false,
/*Force=*/true, ErrStr);
if (!ErrStr.empty()) {
// FIXME: Use a proper diagnostic
llvm::cerr << "unable to open dependency file: " + ErrStr;