Rename "void check(Error)".

We have a few "check" functions in Error.h. All of them are to
check for an error and strip an error object if there was no error,
except "void check(Error E)", which doesn't return anything.
This patch renames it and moves it to the .cpp file where it is used.

llvm-svn: 282764
This commit is contained in:
Rui Ueyama 2016-09-29 21:00:26 +00:00
parent d31e13f287
commit 6c5cbff97e
2 changed files with 10 additions and 10 deletions

View File

@ -47,13 +47,6 @@ template <typename T> void error(const ErrorOr<T> &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 <class T> T check(ErrorOr<T> E) {
if (auto EC = E.getError())
fatal(EC.message());

View File

@ -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<lto::LTO> createLTO() {
lto::Config Conf;
lto::ThinBackend Backend;
@ -58,7 +65,7 @@ static std::unique_ptr<lto::LTO> 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<lto::LTO>(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<InputFile *> BitcodeCompiler::compile() {
llvm::make_unique<llvm::raw_svector_ostream>(Buff[Task]));
};
check(LtoObj->run(AddStream));
checkError(LtoObj->run(AddStream));
if (HasError)
return Ret;