diff --git a/lld/ELF/Error.h b/lld/ELF/Error.h index d0c22f6a5c5e..c5c5df774cbb 100644 --- a/lld/ELF/Error.h +++ b/lld/ELF/Error.h @@ -47,13 +47,6 @@ template void error(const ErrorOr &V, const Twine &Prefix) { LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg); LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg, const Twine &Prefix); -inline void check(Error E) { - handleAllErrors(std::move(E), [&](llvm::ErrorInfoBase &EIB) { - error(EIB.message()); - return Error::success(); - }); -} - template T check(ErrorOr E) { if (auto EC = E.getError()) fatal(EC.message()); diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp index 6b1192022a56..fc68d4f462fd 100644 --- a/lld/ELF/LTO.cpp +++ b/lld/ELF/LTO.cpp @@ -40,6 +40,13 @@ static void diagnosticHandler(const DiagnosticInfo &DI) { warn(ErrStorage); } +static void checkError(Error E) { + handleAllErrors(std::move(E), [&](ErrorInfoBase &EIB) { + error(EIB.message()); + return Error::success(); + }); +} + static std::unique_ptr createLTO() { lto::Config Conf; lto::ThinBackend Backend; @@ -58,7 +65,7 @@ static std::unique_ptr createLTO() { Conf.AAPipeline = Config->LtoAAPipeline; if (Config->SaveTemps) - check(Conf.addSaveTemps(std::string(Config->OutputFile) + ".", + checkError(Conf.addSaveTemps(std::string(Config->OutputFile) + ".", /*UseInputModulePath*/ true)); return llvm::make_unique(std::move(Conf), Backend, Config->LtoJobs); @@ -103,7 +110,7 @@ void BitcodeCompiler::add(BitcodeFile &F) { if (R.Prevailing) undefine(Sym); } - check(LtoObj->add(std::move(F.Obj), Resols)); + checkError(LtoObj->add(std::move(F.Obj), Resols)); } // Merge all the bitcode files we have seen, codegen the result @@ -119,7 +126,7 @@ std::vector BitcodeCompiler::compile() { llvm::make_unique(Buff[Task])); }; - check(LtoObj->run(AddStream)); + checkError(LtoObj->run(AddStream)); if (HasError) return Ret;