Export fewer functions from Error.h.

Also add a comment saying that check() returns a value.

llvm-svn: 287136
This commit is contained in:
Rui Ueyama 2016-11-16 18:54:37 +00:00
parent 000ce9a686
commit 28212d71f6
1 changed files with 9 additions and 11 deletions

View File

@ -45,24 +45,22 @@ LLVM_ATTRIBUTE_NORETURN void exitLld(int Val);
LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg);
LLVM_ATTRIBUTE_NORETURN void fatal(std::error_code EC, const Twine &Prefix);
// check() functions are convenient functions to strip errors
// from error-or-value objects.
template <class T> T check(ErrorOr<T> E) {
if (auto EC = E.getError())
fatal(EC.message());
return std::move(*E);
}
static inline void check(Error E) {
handleAllErrors(std::move(E), [&](llvm::ErrorInfoBase &EIB) -> Error {
template <class T> T check(Expected<T> E) {
if (!E)
handleAllErrors(std::move(E.takeError()),
[](llvm::ErrorInfoBase &EIB) -> Error {
fatal(EIB.message());
return Error::success();
});
}
template <class T> T check(Expected<T> E) {
if (E)
return std::move(*E);
check(E.takeError());
return T();
}
template <class T> T check(ErrorOr<T> E, const Twine &Prefix) {