llvm.org GIT mirror llvm / 7a4575e
Convert FileUpdate to use tool_output_file, and to use errs() instead of outs() for its verbose messages. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111648 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 9 years ago
1 changed file(s) with 6 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
5353 memcmp(In->getBufferStart(), Out->getBufferStart(),
5454 Out->getBufferSize()) == 0) {
5555 if (!Quiet)
56 outs() << argv[0] << ": Not updating '" << OutputFilename
56 errs() << argv[0] << ": Not updating '" << OutputFilename
5757 << "', contents match input.\n";
5858 return 0;
5959 }
6262
6363 // Otherwise, overwrite the output.
6464 if (!Quiet)
65 outs() << argv[0] << ": Updating '" << OutputFilename
65 errs() << argv[0] << ": Updating '" << OutputFilename
6666 << "', contents changed.\n";
67 raw_fd_ostream OutStream(OutputFilename.c_str(), ErrorStr,
68 raw_fd_ostream::F_Binary);
67 tool_output_file OutStream(OutputFilename.c_str(), ErrorStr,
68 raw_fd_ostream::F_Binary);
6969 if (!ErrorStr.empty()) {
7070 errs() << argv[0] << ": Unable to write output '"
7171 << OutputFilename << "': " << ErrorStr << '\n';
7373 }
7474
7575 OutStream.write(In->getBufferStart(), In->getBufferSize());
76 OutStream.close();
7776
78 if (OutStream.has_error()) {
79 errs() << argv[0] << ": Could not open output file '"
80 << OutputFilename << "': " << ErrorStr << '\n';
81 OutStream.clear_error();
82 return 1;
83 }
77 // Declare success.
78 OutStream.keep();
8479
8580 return 0;
8681 }