[llvm-commits] [PATCH] [lld][ErrorOr] Add support for user data.
Michael Spencer
bigcheesegs at gmail.com
Wed Dec 12 16:45:15 PST 2012
Hi jordan_rose, silvas,
This adds support for user data to ErrorOr<T>.
struct InvalidArgError {
InvalidArgError() {}
InvalidArgError(std::string S) : ArgName(S) {}
std::string ArgName;
};
namespace lld {
template<>
struct ErrorOrUserDataTraits<InvalidArgError> : std::true_type {
static error_code error() {
return make_error_code(errc::invalid_argument);
}
};
} // end namespace lld
using namespace lld;
ErrorOr<int> foo() {
return InvalidArgError("adena");
}
int main() {
auto a = foo();
if (!a && error_code(a) == errc::invalid_argument)
llvm::errs() << a.getError<InvalidArgError>().ArgName << "\n";
}
http://llvm-reviews.chandlerc.com/D213
Files:
CMakeLists.txt
include/lld/Core/ErrorOr.h
unittests/CMakeLists.txt
unittests/ErrorOrTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D213.1.patch
Type: text/x-patch
Size: 14199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121212/e5659d4e/attachment.bin>
More information about the llvm-commits
mailing list