summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/utils/FileUpdate/FileUpdate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/utils/FileUpdate/FileUpdate.cpp')
-rw-r--r--contrib/llvm/utils/FileUpdate/FileUpdate.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/contrib/llvm/utils/FileUpdate/FileUpdate.cpp b/contrib/llvm/utils/FileUpdate/FileUpdate.cpp
index 00c2091..2cf366f 100644
--- a/contrib/llvm/utils/FileUpdate/FileUpdate.cpp
+++ b/contrib/llvm/utils/FileUpdate/FileUpdate.cpp
@@ -36,6 +36,11 @@ int main(int argc, char **argv) {
PrettyStackTraceProgram X(argc, argv);
cl::ParseCommandLineOptions(argc, argv);
+ if (OutputFilename == "-") {
+ errs() << argv[0] << ": error: Can't update standard output\n";
+ return 1;
+ }
+
// Get the input data.
std::string ErrorStr;
MemoryBuffer *In =
@@ -54,7 +59,7 @@ int main(int argc, char **argv) {
memcmp(In->getBufferStart(), Out->getBufferStart(),
Out->getBufferSize()) == 0) {
if (!Quiet)
- outs() << argv[0] << ": Not updating '" << OutputFilename
+ errs() << argv[0] << ": Not updating '" << OutputFilename
<< "', contents match input.\n";
return 0;
}
@@ -63,25 +68,20 @@ int main(int argc, char **argv) {
// Otherwise, overwrite the output.
if (!Quiet)
- outs() << argv[0] << ": Updating '" << OutputFilename
+ errs() << argv[0] << ": Updating '" << OutputFilename
<< "', contents changed.\n";
- raw_fd_ostream OutStream(OutputFilename.c_str(), ErrorStr,
- raw_fd_ostream::F_Binary);
+ tool_output_file OutStream(OutputFilename.c_str(), ErrorStr,
+ raw_fd_ostream::F_Binary);
if (!ErrorStr.empty()) {
errs() << argv[0] << ": Unable to write output '"
<< OutputFilename << "': " << ErrorStr << '\n';
return 1;
}
- OutStream.write(In->getBufferStart(), In->getBufferSize());
- OutStream.close();
+ OutStream.os().write(In->getBufferStart(), In->getBufferSize());
- if (OutStream.has_error()) {
- errs() << argv[0] << ": Could not open output file '"
- << OutputFilename << "': " << ErrorStr << '\n';
- OutStream.clear_error();
- return 1;
- }
+ // Declare success.
+ OutStream.keep();
return 0;
}
OpenPOWER on IntegriCloud