- try {
- // Load the first input file.
- Program = ParseInputFile(Filenames[0]);
- if (Program == 0) return true;
- if (!run_as_child)
- std::cout << "Read input file : '" << Filenames[0] << "'\n";
-
- for (unsigned i = 1, e = Filenames.size(); i != e; ++i) {
- std::auto_ptr<Module> M(ParseInputFile(Filenames[i]));
- if (M.get() == 0) return true;
-
- if (!run_as_child)
- std::cout << "Linking in input file: '" << Filenames[i] << "'\n";
- std::string ErrorMessage;
- if (Linker::LinkModules(Program, M.get(), &ErrorMessage)) {
- std::cerr << ToolName << ": error linking in '" << Filenames[i] << "': "
- << ErrorMessage << '\n';
- return true;
- }
- }
- } catch (const std::string &Error) {
- std::cerr << ToolName << ": error reading input '" << Error << "'\n";
- return true;
+ // Load the first input file.
+ Program = parseInputFile(Filenames[0], Context).release();
+ if (!Program) return true;
+
+ outs() << "Read input file : '" << Filenames[0] << "'\n";
+
+ for (unsigned i = 1, e = Filenames.size(); i != e; ++i) {
+ std::unique_ptr<Module> M = parseInputFile(Filenames[i], Context);
+ if (!M.get()) return true;
+
+ outs() << "Linking in input file: '" << Filenames[i] << "'\n";
+ if (Linker::LinkModules(Program, M.get()))
+ return true;