- std::string ErrorMessage;
- if (Filename.exists()) {
- if (Verbose) errs() << "Loading '" << Filename.c_str() << "'\n";
- Module* Result = 0;
-
- const std::string &FNStr = Filename.str();
- if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(FNStr,
- &ErrorMessage)) {
- Result = ParseBitcodeFile(Buffer, Context, &ErrorMessage);
- delete Buffer;
- }
- if (Result) return std::auto_ptr<Module>(Result); // Load successful!
+// Read the specified bitcode file in and return it. This routine searches the
+// link path for the specified file to try to find it...
+//
+static std::unique_ptr<Module>
+loadFile(const char *argv0, const std::string &FN, LLVMContext &Context) {
+ SMDiagnostic Err;
+ if (Verbose) errs() << "Loading '" << FN << "'\n";
+ std::unique_ptr<Module> Result = getLazyIRFileModule(FN, Err, Context);
+ if (!Result)
+ Err.print(argv0, errs());
+
+ return Result;
+}