llvm.org GIT mirror llvm / 17e9edc
Change raw_fd_ostream to take flags as an optional bitmask instead of as two bools. Use this to add a F_Append flag which has the obvious behavior. Other unrelated changes conflated into this patch: 1. REmove EH stuff from llvm-dis and llvm-as, the try blocks are dead. 2. Simplify the filename inference code in llvm-as/llvm-dis, because raw_fd_ostream does the right thing with '-'. 3. Switch machine verifier to use raw_ostream instead of ostream (Which is the thing that needed append in the first place). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79807 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
16 changed file(s) with 228 addition(s) and 245 deletion(s). Raw diff Collapse all Expand all
333333 virtual size_t preferred_buffer_size();
334334
335335 public:
336 /// raw_fd_ostream - Open the specified file for writing. If an
337 /// error occurs, information about the error is put into ErrorInfo,
338 /// and the stream should be immediately destroyed; the string will
339 /// be empty if no error occurred.
336
337 enum {
338 /// F_Force - When opening a file, this flag makes raw_fd_ostream overwrite
339 /// a file if it already exists instead of emitting an error. This may not
340 /// be specified with F_Append.
341 F_Force = 1,
342
343 /// F_Append - When opening a file, if it already exists append to the
344 /// existing file instead of returning an error. This may not be specified
345 /// with F_Force.
346 F_Append = 2,
347
348 /// F_Binary - The file should be opened in binary mode on platforms that
349 /// support this distinction.
350 F_Binary = 4
351 };
352
353 /// raw_fd_ostream - Open the specified file for writing. If an error occurs,
354 /// information about the error is put into ErrorInfo, and the stream should
355 /// be immediately destroyed; the string will be empty if no error occurred.
356 /// This allows optional flags to control how the file will be opened.
340357 ///
341358 /// \param Filename - The file to open. If this is "-" then the
342359 /// stream will use stdout instead.
343 /// \param Binary - The file should be opened in binary mode on
344 /// platforms that support this distinction.
345 /// \param Force - Don't consider the case where the file already
346 /// exists to be an error.
347 raw_fd_ostream(const char *Filename, bool Binary, bool Force,
348 std::string &ErrorInfo);
360 raw_fd_ostream(const char *Filename, std::string &ErrorInfo,
361 unsigned Flags = 0);
349362
350363 /// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If
351364 /// ShouldClose is true, this closes the file when the stream is destroyed.
3838 #include "llvm/Support/Debug.h"
3939 #include "llvm/Support/ErrorHandling.h"
4040 #include "llvm/Support/raw_ostream.h"
41 #include
42
4341 using namespace llvm;
4442
4543 namespace {
6462 const bool allowPhysDoubleDefs;
6563
6664 const char *const OutFileName;
67 std::ostream *OS;
65 raw_ostream *OS;
6866 const MachineFunction *MF;
6967 const TargetMachine *TM;
7068 const TargetRegisterInfo *TRI;
172170 MachineVer("machineverifier", "Verify generated machine code");
173171 static const PassInfo *const MachineVerifyID = &MachineVer;
174172
175 FunctionPass *
176 llvm::createMachineVerifierPass(bool allowPhysDoubleDefs)
177 {
173 FunctionPass *llvm::createMachineVerifierPass(bool allowPhysDoubleDefs) {
178174 return new MachineVerifier(allowPhysDoubleDefs);
179175 }
180176
181 bool
182 MachineVerifier::runOnMachineFunction(MachineFunction &MF)
183 {
184 std::ofstream OutFile;
177 bool MachineVerifier::runOnMachineFunction(MachineFunction &MF) {
178 raw_ostream *OutFile = 0;
185179 if (OutFileName) {
186 OutFile.open(OutFileName, std::ios::out | std::ios::app);
187 OS = &OutFile;
180 std::string ErrorInfo;
181 OutFile = new raw_fd_ostream(OutFileName, ErrorInfo,
182 raw_fd_ostream::F_Append);
183 if (!ErrorInfo.empty()) {
184 errs() << "Error opening '" << OutFileName << "': " << ErrorInfo << '\n';
185 exit(1);
186 }
187
188 OS = OutFile;
188189 } else {
189 OS = cerr.stream();
190 OS = &errs();
190191 }
191192
192193 foundErrors = 0;
211212 }
212213 visitMachineFunctionAfter();
213214
214 if (OutFileName)
215 OutFile.close();
216 else if (foundErrors) {
217 std::string msg;
218 raw_string_ostream Msg(msg);
219 Msg << "Found " << foundErrors << " machine code errors.";
220 llvm_report_error(Msg.str());
221 }
215 if (OutFile)
216 delete OutFile;
217 else if (foundErrors)
218 llvm_report_error("Found "+Twine(foundErrors)+" machine code errors.");
222219
223220 // Clean up.
224221 regsLive.clear();
233230
234231 void MachineVerifier::report(const char *msg, const MachineFunction *MF) {
235232 assert(MF);
236 *OS << "\n";
233 *OS << '\n';
237234 if (!foundErrors++)
238235 MF->print(*OS);
239236 *OS << "*** Bad machine code: " << msg << " ***\n"
321321 /// occurs, information about the error is put into ErrorInfo, and the
322322 /// stream should be immediately destroyed; the string will be empty
323323 /// if no error occurred.
324 raw_fd_ostream::raw_fd_ostream(const char *Filename, bool Binary, bool Force,
325 std::string &ErrorInfo) : pos(0) {
324 raw_fd_ostream::raw_fd_ostream(const char *Filename, std::string &ErrorInfo,
325 unsigned Flags) : pos(0) {
326 // Verify that we don't have both "append" and "force".
327 assert((!(Flags & F_Force) || !(Flags & F_Append)) &&
328 "Cannot specify both 'force' and 'append' file creation flags!");
329
326330 ErrorInfo.clear();
327331
328332 // Handle "-" as stdout.
330334 FD = STDOUT_FILENO;
331335 // If user requested binary then put stdout into binary mode if
332336 // possible.
333 if (Binary)
337 if (Flags & F_Binary)
334338 sys::Program::ChangeStdoutToBinary();
335339 ShouldClose = false;
336340 return;
337341 }
338342
339 int Flags = O_WRONLY|O_CREAT|O_TRUNC;
343 int OpenFlags = O_WRONLY|O_CREAT;
340344 #ifdef O_BINARY
341345 if (Binary)
342 Flags |= O_BINARY;
343 #endif
344 if (!Force)
345 Flags |= O_EXCL;
346 FD = open(Filename, Flags, 0664);
346 OpenFlags |= O_BINARY;
347 #endif
348
349 if (Flags & F_Force)
350 OpenFlags |= O_TRUNC;
351 else if (Flags & F_Append)
352 OpenFlags |= O_APPEND;
353 else
354 OpenFlags |= O_EXCL;
355
356 FD = open(Filename, OpenFlags, 0664);
347357 if (FD < 0) {
348358 ErrorInfo = "Error opening output file '" + std::string(Filename) + "'";
349359 ShouldClose = false;
353363 }
354364
355365 raw_fd_ostream::~raw_fd_ostream() {
356 if (FD >= 0) {
357 flush();
358 if (ShouldClose)
359 if (::close(FD) != 0)
360 error_detected();
361 }
362 }
366 if (FD < 0) return;
367 flush();
368 if (ShouldClose)
369 if (::close(FD) != 0)
370 error_detected();
371 }
372
363373
364374 void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) {
365375 assert (FD >= 0 && "File already closed.");
335335 sys::RemoveFileOnSignal(uniqueFilename);
336336
337337 std::string ErrorInfo;
338 raw_fd_ostream BlocksToNotExtractFile(uniqueFilename.c_str(),
339 /*Binary=*/false, /*Force=*/true,
340 ErrorInfo);
338 raw_fd_ostream BlocksToNotExtractFile(uniqueFilename.c_str(), ErrorInfo,
339 raw_fd_ostream::F_Force);
341340 if (!ErrorInfo.empty()) {
342341 outs() << "*** Basic Block extraction failed!\n";
343342 errs() << "Error writing list of blocks to not extract: " << ErrorInfo
361361 (*message)(LDPL_ERROR, "%s", ErrMsg.c_str());
362362 return LDPS_ERR;
363363 }
364 raw_fd_ostream *objFile = new raw_fd_ostream(uniqueObjPath.c_str(),
365 /*Binary=*/true,
366 /*Force=*/true,
367 ErrMsg);
364 raw_fd_ostream *objFile =
365 new raw_fd_ostream(uniqueObjPath.c_str(), ErrMsg,
366 raw_fd_ostream::F_Force|raw_fd_ostream::F_Binary);
368367 if (!ErrMsg.empty()) {
369368 delete objFile;
370369 (*message)(LDPL_ERROR, "%s", ErrMsg.c_str());
136136 sys::RemoveFileOnSignal(sys::Path(OutputFilename));
137137
138138 std::string error;
139 raw_fd_ostream *FDOut = new raw_fd_ostream(OutputFilename.c_str(),
140 /*Binary=*/true, Force, error);
139 raw_fd_ostream *FDOut =
140 new raw_fd_ostream(OutputFilename.c_str(), error,
141 (Force ? raw_fd_ostream::F_Force : 0)|
142 raw_fd_ostream::F_Binary);
141143 if (!error.empty()) {
142144 errs() << error << '\n';
143145 if (!Force)
186188 sys::RemoveFileOnSignal(sys::Path(OutputFilename));
187189
188190 std::string error;
189 raw_fd_ostream *FDOut = new raw_fd_ostream(OutputFilename.c_str(),
190 Binary, Force, error);
191 unsigned OpenFlags = 0;
192 if (Force) OpenFlags |= raw_fd_ostream::F_Force;
193 if (Binary) OpenFlags |= raw_fd_ostream::F_Binary;
194 raw_fd_ostream *FDOut = new raw_fd_ostream(OutputFilename.c_str(), error,
195 OpenFlags);
191196 if (!error.empty()) {
192197 errs() << error << '\n';
193198 if (!Force)
5757 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
5858 cl::ParseCommandLineOptions(argc, argv, "llvm .ll -> .bc assembler\n");
5959
60 int exitCode = 0;
61 raw_ostream *Out = 0;
62 try {
63 // Parse the file now...
64 SMDiagnostic Err;
65 std::auto_ptr M(ParseAssemblyFile(InputFilename, Err, Context));
66 if (M.get() == 0) {
67 Err.Print(argv[0], errs());
68 return 1;
69 }
70
71 if (!DisableVerify) {
72 std::string Err;
73 if (verifyModule(*M.get(), ReturnStatusAction, &Err)) {
74 errs() << argv[0]
75 << ": assembly parsed, but does not verify as correct!\n";
76 errs() << Err;
77 return 1;
78 }
79 }
80
81 if (DumpAsm) errs() << "Here's the assembly:\n" << *M.get();
82
83 if (OutputFilename != "") { // Specified an output filename?
84 if (OutputFilename != "-") { // Not stdout?
85 std::string ErrorInfo;
86 Out = new raw_fd_ostream(OutputFilename.c_str(), /*Binary=*/true,
87 Force, ErrorInfo);
88 if (!ErrorInfo.empty()) {
89 errs() << ErrorInfo << '\n';
90 if (!Force)
91 errs() << "Use -f command line argument to force output\n";
92 delete Out;
93 return 1;
94 }
95 } else { // Specified stdout
96 // FIXME: outs() is not binary!
97 Out = &outs();
98 }
99 } else {
100 if (InputFilename == "-") {
101 OutputFilename = "-";
102 Out = &outs();
103 } else {
104 std::string IFN = InputFilename;
105 int Len = IFN.length();
106 if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') {
107 // Source ends in .ll
108 OutputFilename = std::string(IFN.begin(), IFN.end()-3);
109 } else {
110 OutputFilename = IFN; // Append a .bc to it
111 }
112 OutputFilename += ".bc";
113
114 std::string ErrorInfo;
115 Out = new raw_fd_ostream(OutputFilename.c_str(), /*Binary=*/true,
116 Force, ErrorInfo);
117 if (!ErrorInfo.empty()) {
118 errs() << ErrorInfo << '\n';
119 if (!Force)
120 errs() << "Use -f command line argument to force output\n";
121 delete Out;
122 return 1;
123 }
124 // Make sure that the Out file gets unlinked from the disk if we get a
125 // SIGINT
126 sys::RemoveFileOnSignal(sys::Path(OutputFilename));
127 }
128 }
129
130 if (!DisableOutput)
131 if (Force || !CheckBitcodeOutputToConsole(Out,true))
132 WriteBitcodeToFile(M.get(), *Out);
133 } catch (const std::string& msg) {
134 errs() << argv[0] << ": " << msg << "\n";
135 exitCode = 1;
136 } catch (...) {
137 errs() << argv[0] << ": Unexpected unknown exception occurred.\n";
138 exitCode = 1;
60 // Parse the file now...
61 SMDiagnostic Err;
62 std::auto_ptr M(ParseAssemblyFile(InputFilename, Err, Context));
63 if (M.get() == 0) {
64 Err.Print(argv[0], errs());
65 return 1;
13966 }
14067
141 if (Out != &outs()) delete Out;
142 return exitCode;
68 if (!DisableVerify) {
69 std::string Err;
70 if (verifyModule(*M.get(), ReturnStatusAction, &Err)) {
71 errs() << argv[0]
72 << ": assembly parsed, but does not verify as correct!\n";
73 errs() << Err;
74 return 1;
75 }
76 }
77
78 if (DumpAsm) errs() << "Here's the assembly:\n" << *M.get();
79
80 // Infer the output filename if needed.
81 if (OutputFilename.empty()) {
82 if (InputFilename == "-") {
83 OutputFilename = "-";
84 } else {
85 std::string IFN = InputFilename;
86 int Len = IFN.length();
87 if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') {
88 // Source ends in .ll
89 OutputFilename = std::string(IFN.begin(), IFN.end()-3);
90 } else {
91 OutputFilename = IFN; // Append a .bc to it
92 }
93 OutputFilename += ".bc";
94 }
95 }
96
97 std::string ErrorInfo;
98 std::auto_ptr Out
99 (new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo,
100 (Force?raw_fd_ostream::F_Force : 0) |
101 raw_fd_ostream::F_Binary));
102 if (!ErrorInfo.empty()) {
103 errs() << ErrorInfo << '\n';
104 if (!Force)
105 errs() << "Use -f command line argument to force output\n";
106 return 1;
107 }
108
109
110 // Make sure that the Out file gets unlinked from the disk if we get a
111 // SIGINT.
112 if (OutputFilename != "-")
113 sys::RemoveFileOnSignal(sys::Path(OutputFilename));
114
115 if (!DisableOutput)
116 if (Force || !CheckBitcodeOutputToConsole(Out.get(), true))
117 WriteBitcodeToFile(M.get(), *Out);
118 return 0;
143119 }
144120
4949
5050 LLVMContext &Context = getGlobalContext();
5151 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
52 try {
53 cl::ParseCommandLineOptions(argc, argv, "llvm .bc -> .ll disassembler\n");
52
53
54 cl::ParseCommandLineOptions(argc, argv, "llvm .bc -> .ll disassembler\n");
5455
55 raw_ostream *Out = &outs(); // Default to printing to stdout.
56 std::string ErrorMessage;
57
58 std::auto_ptr M;
59
60 if (MemoryBuffer *Buffer
61 = MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)) {
62 M.reset(ParseBitcodeFile(Buffer, Context, &ErrorMessage));
63 delete Buffer;
64 }
65
66 if (M.get() == 0) {
67 errs() << argv[0] << ": ";
68 if (ErrorMessage.size())
69 errs() << ErrorMessage << "\n";
70 else
71 errs() << "bitcode didn't read correctly.\n";
72 return 1;
73 }
74
75 if (DontPrint) {
76 // Just use stdout. We won't actually print anything on it.
77 } else if (OutputFilename != "") { // Specified an output filename?
78 if (OutputFilename != "-") { // Not stdout?
79 std::string ErrorInfo;
80 Out = new raw_fd_ostream(OutputFilename.c_str(), /*Binary=*/false,
81 Force, ErrorInfo);
82 if (!ErrorInfo.empty()) {
83 errs() << ErrorInfo << '\n';
84 if (!Force)
85 errs() << "Use -f command line argument to force output\n";
86 delete Out;
87 return 1;
88 }
89 }
90 } else {
91 if (InputFilename == "-") {
92 OutputFilename = "-";
93 } else {
94 std::string IFN = InputFilename;
95 int Len = IFN.length();
96 if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') {
97 // Source ends in .bc
98 OutputFilename = std::string(IFN.begin(), IFN.end()-3)+".ll";
99 } else {
100 OutputFilename = IFN+".ll";
101 }
102
103 std::string ErrorInfo;
104 Out = new raw_fd_ostream(OutputFilename.c_str(), /*Binary=*/false,
105 Force, ErrorInfo);
106 if (!ErrorInfo.empty()) {
107 errs() << ErrorInfo << '\n';
108 if (!Force)
109 errs() << "Use -f command line argument to force output\n";
110 delete Out;
111 return 1;
112 }
113
114 // Make sure that the Out file gets unlinked from the disk if we get a
115 // SIGINT
116 sys::RemoveFileOnSignal(sys::Path(OutputFilename));
117 }
118 }
119
120 // All that llvm-dis does is write the assembly to a file.
121 if (!DontPrint) {
122 PassManager Passes;
123 Passes.add(createPrintModulePass(Out));
124 Passes.run(*M.get());
125 }
126
127 if (Out != &outs())
128 delete Out;
129 return 0;
130 } catch (const std::string& msg) {
131 errs() << argv[0] << ": " << msg << "\n";
132 } catch (...) {
133 errs() << argv[0] << ": Unexpected unknown exception occurred.\n";
56 std::string ErrorMessage;
57 std::auto_ptr M;
58
59 if (MemoryBuffer *Buffer
60 = MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)) {
61 M.reset(ParseBitcodeFile(Buffer, Context, &ErrorMessage));
62 delete Buffer;
13463 }
13564
136 return 1;
65 if (M.get() == 0) {
66 errs() << argv[0] << ": ";
67 if (ErrorMessage.size())
68 errs() << ErrorMessage << "\n";
69 else
70 errs() << "bitcode didn't read correctly.\n";
71 return 1;
72 }
73
74 // Just use stdout. We won't actually print anything on it.
75 if (DontPrint)
76 OutputFilename = "-";
77
78 if (OutputFilename.empty()) { // Unspecified output, infer it.
79 if (InputFilename == "-") {
80 OutputFilename = "-";
81 } else {
82 const std::string &IFN = InputFilename;
83 int Len = IFN.length();
84 // If the source ends in .bc, strip it off.
85 if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c')
86 OutputFilename = std::string(IFN.begin(), IFN.end()-3)+".ll";
87 else
88 OutputFilename = IFN+".ll";
89 }
90 }
91
92 std::string ErrorInfo;
93 std::auto_ptr
94 Out(new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo,
95 (Force?raw_fd_ostream::F_Force : 0) |
96 raw_fd_ostream::F_Binary));
97 if (!ErrorInfo.empty()) {
98 errs() << ErrorInfo << '\n';
99 if (!Force)
100 errs() << "Use -f command line argument to force output\n";
101 return 1;
102 }
103
104 // Make sure that the Out file gets unlinked from the disk if we get a
105 // SIGINT.
106 if (OutputFilename != "-")
107 sys::RemoveFileOnSignal(sys::Path(OutputFilename));
108
109 // All that llvm-dis does is write the assembly to a file.
110 if (!DontPrint) {
111 PassManager Passes;
112 Passes.add(createPrintModulePass(Out.get()));
113 Passes.run(*M.get());
114 }
115
116 return 0;
137117 }
138118
113113
114114 if (OutputFilename != "-") { // Not stdout?
115115 std::string ErrorInfo;
116 Out = new raw_fd_ostream(OutputFilename.c_str(), /*Binary=*/true,
117 Force, ErrorInfo);
116 Out = new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo,
117 raw_fd_ostream::F_Binary |
118 (Force ? raw_fd_ostream::F_Force : 0));
118119 if (!ErrorInfo.empty()) {
119120 errs() << ErrorInfo << '\n';
120121 if (!Force)
228228
229229 // Create the output file.
230230 std::string ErrorInfo;
231 raw_fd_ostream Out(FileName.c_str(), /*Binary=*/true, /*Force=*/true,
232 ErrorInfo);
231 raw_fd_ostream Out(FileName.c_str(), ErrorInfo,
232 raw_fd_ostream::F_Force | raw_fd_ostream::F_Binary);
233233 if (!ErrorInfo.empty())
234234 PrintAndExit(ErrorInfo);
235235
426426
427427 // Output the script to start the program...
428428 std::string ErrorInfo;
429 raw_fd_ostream Out2(OutputFilename.c_str(), /*Binary=*/false, /*Force=*/true,
430 ErrorInfo);
429 raw_fd_ostream Out2(OutputFilename.c_str(), ErrorInfo,
430 llvm::raw_fd_ostream::F_Force);
431431 if (!ErrorInfo.empty())
432432 PrintAndExit(ErrorInfo);
433433
121121 raw_ostream *Out = &outs(); // Default to printing to stdout...
122122 if (OutputFilename != "-") {
123123 std::string ErrorInfo;
124 Out = new raw_fd_ostream(OutputFilename.c_str(), /*Binary=*/true,
125 Force, ErrorInfo);
124 Out = new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo,
125 raw_fd_ostream::F_Binary |
126 (Force ? raw_fd_ostream::F_Force : 0));
126127 if (!ErrorInfo.empty()) {
127128 errs() << ErrorInfo << '\n';
128129 if (!Force)
173173 }
174174
175175 static formatted_raw_ostream *GetOutputStream() {
176 if (OutputFilename == "" || OutputFilename == "-")
177 return &fouts();
176 if (OutputFilename == "")
177 OutputFilename = "-";
178178
179179 // Make sure that the Out file gets unlinked from the disk if we get a
180 // SIGINT
181 sys::RemoveFileOnSignal(sys::Path(OutputFilename));
180 // SIGINT.
181 if (OutputFilename != "-")
182 sys::RemoveFileOnSignal(sys::Path(OutputFilename));
182183
183184 std::string Err;
184 raw_fd_ostream *Out = new raw_fd_ostream(OutputFilename.c_str(),
185 /*Binary=*/false, Force, Err);
185 raw_fd_ostream *Out = new raw_fd_ostream(OutputFilename.c_str(), Err,
186 raw_fd_ostream::F_Binary |
187 (Force ? raw_fd_ostream::F_Force : 0));
186188 if (!Err.empty()) {
187189 errs() << Err << '\n';
188190 if (!Force)
177177 // generate assembly code
178178 bool genResult = false;
179179 {
180 raw_fd_ostream asmFD(uniqueAsmPath.c_str(),
181 /*Binary=*/false, /*Force=*/true,
182 errMsg);
180 raw_fd_ostream asmFD(uniqueAsmPath.c_str(), errMsg,
181 raw_fd_ostream::F_Force);
183182 formatted_raw_ostream asmFile(asmFD);
184183 if (!errMsg.empty())
185184 return NULL;
375375 raw_ostream *Out = &outs(); // Default to printing to stdout...
376376 if (OutputFilename != "-") {
377377 std::string ErrorInfo;
378 Out = new raw_fd_ostream(OutputFilename.c_str(), /*Binary=*/true,
379 Force, ErrorInfo);
378 Out = new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo,
379 raw_fd_ostream::F_Binary |
380 (Force ? raw_fd_ostream::F_Force : 0));
380381 if (!ErrorInfo.empty()) {
381382 errs() << ErrorInfo << '\n';
382383 if (!Force)
6464 if (!Quiet)
6565 outs() << argv[0] << ": Updating '" << OutputFilename
6666 << "', contents changed.\n";
67 raw_fd_ostream OutStream(OutputFilename.c_str(), /*Binary=*/true,
68 /*Force=*/true, ErrorStr);
67 raw_fd_ostream OutStream(OutputFilename.c_str(), ErrorStr,
68 raw_fd_ostream::F_Force|raw_fd_ostream::F_Binary);
6969 if (!ErrorStr.empty()) {
7070 errs() << argv[0] << ": Unable to write output '"
7171 << OutputFilename << "': " << ErrorStr << '\n';
170170 raw_ostream *Out = &outs();
171171 if (OutputFilename != "-") {
172172 std::string Error;
173 Out = new raw_fd_ostream(OutputFilename.c_str(), /*Binary=*/false,
174 /*Force=*/true, Error);
173 Out = new raw_fd_ostream(OutputFilename.c_str(), Error,
174 raw_fd_ostream::F_Force);
175175
176176 if (!Error.empty()) {
177177 errs() << argv[0] << ": error opening " << OutputFilename