llvm.org GIT mirror llvm / 9754b3b
[lli] Factor out error handling. NFCI. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287276 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 2 years ago
1 changed file(s) with 15 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
356356 llvm_unreachable("Unrecognized opt level.");
357357 }
358358
359 LLVM_ATTRIBUTE_NORETURN
360 static void reportError(SMDiagnostic Err, const char *ProgName) {
361 Err.print(ProgName, errs());
362 exit(1);
363 }
364
359365 //===----------------------------------------------------------------------===//
360366 // main Driver function
361367 //
387393 SMDiagnostic Err;
388394 std::unique_ptr Owner = parseIRFile(InputFile, Err, Context);
389395 Module *Mod = Owner.get();
390 if (!Mod) {
391 Err.print(argv[0], errs());
392 return 1;
393 }
396 if (!Mod)
397 reportError(Err, argv[0]);
394398
395399 if (UseJITKind == JITKind::OrcLazy) {
396400 std::vector> Ms;
397401 Ms.push_back(std::move(Owner));
398402 for (auto &ExtraMod : ExtraModules) {
399403 Ms.push_back(parseIRFile(ExtraMod, Err, Context));
400 if (!Ms.back()) {
401 Err.print(argv[0], errs());
402 return 1;
403 }
404 if (!Ms.back())
405 reportError(Err, argv[0]);
404406 }
405407 std::vector Args;
406408 Args.push_back(InputFile);
485487 // Load any additional modules specified on the command line.
486488 for (unsigned i = 0, e = ExtraModules.size(); i != e; ++i) {
487489 std::unique_ptr XMod = parseIRFile(ExtraModules[i], Err, Context);
488 if (!XMod) {
489 Err.print(argv[0], errs());
490 return 1;
491 }
490 if (!XMod)
491 reportError(Err, argv[0]);
492492 if (EnableCacheManager) {
493493 std::string CacheName("file:");
494494 CacheName.append(ExtraModules[i]);
503503 if (!Obj) {
504504 // TODO: Actually report errors helpfully.
505505 consumeError(Obj.takeError());
506 Err.print(argv[0], errs());
507 return 1;
506 reportError(Err, argv[0]);
508507 }
509508 object::OwningBinary &O = Obj.get();
510509 EE->addObjectFile(std::move(O));
513512 for (unsigned i = 0, e = ExtraArchives.size(); i != e; ++i) {
514513 ErrorOr> ArBufOrErr =
515514 MemoryBuffer::getFileOrSTDIN(ExtraArchives[i]);
516 if (!ArBufOrErr) {
517 Err.print(argv[0], errs());
518 return 1;
519 }
515 if (!ArBufOrErr)
516 reportError(Err, argv[0]);
520517 std::unique_ptr &ArBuf = ArBufOrErr.get();
521518
522519 Expected> ArOrErr =