- if (OutputFilename.getValue() != "") { // Specified an output filename?
- Out = new ofstream(OutputFilename.getValue().c_str(),
- (Force.getValue() ? 0 : ios::noreplace)|ios::out);
+ if (!DisableVerify) {
+ std::string Err;
+ if (verifyModule(*M.get(), ReturnStatusAction, &Err)) {
+ cerr << argv[0]
+ << ": assembly parsed, but does not verify as correct!\n";
+ cerr << Err;
+ return 1;
+ }
+ }
+
+ if (DumpAsm) cerr << "Here's the assembly:\n" << *M.get();
+
+ if (OutputFilename != "") { // Specified an output filename?
+ if (OutputFilename != "-") { // Not stdout?
+ if (!Force && std::ifstream(OutputFilename.c_str())) {
+ // If force is not specified, make sure not to overwrite a file!
+ cerr << argv[0] << ": error opening '" << OutputFilename
+ << "': file exists!\n"
+ << "Use -f command line argument to force output\n";
+ return 1;
+ }
+ Out = new std::ofstream(OutputFilename.c_str(), std::ios::out |
+ std::ios::trunc | std::ios::binary);
+ } else { // Specified stdout
+ // FIXME: cout is not binary!
+ Out = &std::cout;
+ }