llvm.org GIT mirror llvm / 2df9504
Use tool_output_file in llvm-extract and llvm-link too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111604 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 9 years ago
2 changed file(s) with 13 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
115115 Passes.add(createDeadTypeEliminationPass()); // Remove dead types...
116116 Passes.add(createStripDeadPrototypesPass()); // Remove dead func decls
117117
118 // Make sure that the Output file gets unlinked from the disk if we get a
119 // SIGINT
120 if (OutputFilename != "-")
121 sys::RemoveFileOnSignal(sys::Path(OutputFilename));
122
123118 std::string ErrorInfo;
124 raw_fd_ostream Out(OutputFilename.c_str(), ErrorInfo,
125 raw_fd_ostream::F_Binary);
119 tool_output_file Out(OutputFilename.c_str(), ErrorInfo,
120 raw_fd_ostream::F_Binary);
126121 if (!ErrorInfo.empty()) {
127122 errs() << ErrorInfo << '\n';
128123 return 1;
135130
136131 Passes.run(*M.get());
137132
133 // Declare success.
134 Out.keep();
135
138136 return 0;
139137 }
115115 if (DumpAsm) errs() << "Here's the assembly:\n" << *Composite;
116116
117117 std::string ErrorInfo;
118 std::auto_ptr
119 Out(new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo,
120 raw_fd_ostream::F_Binary));
118 tool_output_file Out(OutputFilename.c_str(), ErrorInfo,
119 raw_fd_ostream::F_Binary);
121120 if (!ErrorInfo.empty()) {
122121 errs() << ErrorInfo << '\n';
123122 return 1;
124123 }
125
126 // Make sure that the Out file gets unlinked from the disk if we get a
127 // SIGINT
128 if (OutputFilename != "-")
129 sys::RemoveFileOnSignal(sys::Path(OutputFilename));
130124
131125 if (verifyModule(*Composite)) {
132126 errs() << argv[0] << ": linked module is broken!\n";
135129
136130 if (Verbose) errs() << "Writing bitcode...\n";
137131 if (OutputAssembly) {
138 *Out << *Composite;
139 } else if (Force || !CheckBitcodeOutputToConsole(*Out, true))
140 WriteBitcodeToFile(Composite.get(), *Out);
132 Out << *Composite;
133 } else if (Force || !CheckBitcodeOutputToConsole(Out, true))
134 WriteBitcodeToFile(Composite.get(), Out);
135
136 // Declare success.
137 Out.keep();
141138
142139 return 0;
143140 }