From e7aad357a95be22a91d4d7d4131fb5fcf49f50ca Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Wed, 23 Mar 2016 23:57:28 +0000 Subject: [Support] Make all Errors convertible to std::error_code. This is a temporary crutch to enable code that currently uses std::error_code to be incrementally moved over to Error. Requiring all Error instances be convertible enables clients to call errorToErrorCode on any error (not just ECErrors created by conversion *from* an error_code). This patch also moves code for Error from ErrorHandling.cpp into a new Error.cpp file. llvm-svn: 264221 --- llvm/unittests/Support/ErrorTest.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'llvm/unittests/Support/ErrorTest.cpp') diff --git a/llvm/unittests/Support/ErrorTest.cpp b/llvm/unittests/Support/ErrorTest.cpp index 788dcd3..1807547 100644 --- a/llvm/unittests/Support/ErrorTest.cpp +++ b/llvm/unittests/Support/ErrorTest.cpp @@ -9,6 +9,7 @@ #include "llvm/Support/Error.h" #include "llvm/Support/Errc.h" +#include "llvm/Support/ErrorHandling.h" #include "gtest/gtest.h" #include @@ -30,6 +31,10 @@ public: OS << "CustomError { " << getInfo() << "}"; } + std::error_code convertToErrorCode() const override { + llvm_unreachable("CustomError doesn't support ECError conversion"); + } + protected: // This error is subclassed below, but we can't use inheriting constructors // yet, so we can't propagate the constructors through ErrorInfo. Instead @@ -57,6 +62,10 @@ public: OS << "CustomSubError { " << getInfo() << ", " << getExtraInfo() << "}"; } + std::error_code convertToErrorCode() const override { + llvm_unreachable("CustomSubError doesn't support ECError conversion"); + } + protected: int ExtraInfo; }; -- cgit v1.1