- if (DumpAsm) cerr << "Here's the assembly:\n" << *M.get();
-
- if (OutputFilename != "") { // Specified an output filename?
- if (OutputFilename != "-") { // Not stdout?
- std::string ErrorInfo;
- Out = new raw_fd_ostream(OutputFilename.c_str(), /*Binary=*/true,
- Force, ErrorInfo);
- if (!ErrorInfo.empty()) {
- errs() << ErrorInfo << '\n';
- if (!Force)
- errs() << "Use -f command line argument to force output\n";
- delete Out;
- return 1;
- }
- } else { // Specified stdout
- // FIXME: outs() is not binary!
- Out = &outs();
- }
- } else {
- if (InputFilename == "-") {
- OutputFilename = "-";
- Out = &outs();
- } else {
- std::string IFN = InputFilename;
- int Len = IFN.length();
- if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') {
- // Source ends in .ll
- OutputFilename = std::string(IFN.begin(), IFN.end()-3);
- } else {
- OutputFilename = IFN; // Append a .bc to it
- }
- OutputFilename += ".bc";
-
- std::string ErrorInfo;
- Out = new raw_fd_ostream(OutputFilename.c_str(), /*Binary=*/true,
- Force, ErrorInfo);
- if (!ErrorInfo.empty()) {
- errs() << ErrorInfo << '\n';
- if (!Force)
- errs() << "Use -f command line argument to force output\n";
- delete Out;
- return 1;
- }
- // Make sure that the Out file gets unlinked from the disk if we get a
- // SIGINT
- sys::RemoveFileOnSignal(sys::Path(OutputFilename));
- }
- }