[lld] r287136 - Export fewer functions from Error.h.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 16 10:54:37 PST 2016
Author: ruiu
Date: Wed Nov 16 12:54:37 2016
New Revision: 287136
URL: http://llvm.org/viewvc/llvm-project?rev=287136&view=rev
Log:
Export fewer functions from Error.h.
Also add a comment saying that check() returns a value.
Modified:
lld/trunk/ELF/Error.h
Modified: lld/trunk/ELF/Error.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.h?rev=287136&r1=287135&r2=287136&view=diff
==============================================================================
--- lld/trunk/ELF/Error.h (original)
+++ lld/trunk/ELF/Error.h Wed Nov 16 12:54:37 2016
@@ -45,24 +45,22 @@ LLVM_ATTRIBUTE_NORETURN void exitLld(int
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 {
- 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();
+ if (!E)
+ handleAllErrors(std::move(E.takeError()),
+ [](llvm::ErrorInfoBase &EIB) -> Error {
+ fatal(EIB.message());
+ return Error::success();
+ });
+ return std::move(*E);
}
template <class T> T check(ErrorOr<T> E, const Twine &Prefix) {
More information about the llvm-commits
mailing list