diff --git a/orc-rt/include/orc-rt/Error.h b/orc-rt/include/orc-rt/Error.h index a316e1934f671..a8f411e930223 100644 --- a/orc-rt/include/orc-rt/Error.h +++ b/orc-rt/include/orc-rt/Error.h @@ -9,6 +9,7 @@ #ifndef ORC_RT_ERROR_H #define ORC_RT_ERROR_H +#include "orc-rt/CallableTraitsHelper.h" #include "orc-rt/Compiler.h" #include "orc-rt/RTTI.h" @@ -137,18 +138,15 @@ template Error make_error(ArgTs &&...Args) { return make_error(std::make_unique(std::forward(Args)...)); } -/// Traits class for selecting and applying error handlers. -template -struct ErrorHandlerTraits - : public ErrorHandlerTraits< - decltype(&std::remove_reference_t::operator())> {}; +namespace detail { + +template struct ErrorHandlerTraitsImpl; -// Specialization functions of the form 'Error (const ErrT&)'. -template struct ErrorHandlerTraits { +// Specialization for Error(ErrT&). +template struct ErrorHandlerTraitsImpl { static bool appliesTo(const ErrorInfoBase &E) { return E.template isA(); } - template static Error apply(HandlerT &&H, std::unique_ptr E) { assert(appliesTo(*E) && "Applying incorrect handler"); @@ -156,12 +154,11 @@ template struct ErrorHandlerTraits { } }; -// Specialization functions of the form 'void (const ErrT&)'. -template struct ErrorHandlerTraits { +// Specialization for void(ErrT&). +template struct ErrorHandlerTraitsImpl { static bool appliesTo(const ErrorInfoBase &E) { return E.template isA(); } - template static Error apply(HandlerT &&H, std::unique_ptr E) { assert(appliesTo(*E) && "Applying incorrect handler"); @@ -170,13 +167,12 @@ template struct ErrorHandlerTraits { } }; -/// Specialization for functions of the form 'Error (std::unique_ptr)'. +// Specialization for Error(std::unique_ptr). template -struct ErrorHandlerTraits)> { +struct ErrorHandlerTraitsImpl> { static bool appliesTo(const ErrorInfoBase &E) { return E.template isA(); } - template static Error apply(HandlerT &&H, std::unique_ptr E) { assert(appliesTo(*E) && "Applying incorrect handler"); @@ -185,13 +181,12 @@ struct ErrorHandlerTraits)> { } }; -/// Specialization for functions of the form 'void (std::unique_ptr)'. +// Specialization for void(std::unique_ptr). template -struct ErrorHandlerTraits)> { +struct ErrorHandlerTraitsImpl> { static bool appliesTo(const ErrorInfoBase &E) { return E.template isA(); } - template static Error apply(HandlerT &&H, std::unique_ptr E) { assert(appliesTo(*E) && "Applying incorrect handler"); @@ -201,37 +196,11 @@ struct ErrorHandlerTraits)> { } }; -// Specialization for member functions of the form 'RetT (const ErrT&)'. -template -class ErrorHandlerTraits - : public ErrorHandlerTraits {}; - -// Specialization for member functions of the form 'RetT (const ErrT&) const'. -template -class ErrorHandlerTraits - : public ErrorHandlerTraits {}; - -// Specialization for member functions of the form 'RetT (const ErrT&)'. -template -class ErrorHandlerTraits - : public ErrorHandlerTraits {}; - -// Specialization for member functions of the form 'RetT (const ErrT&) const'. -template -class ErrorHandlerTraits - : public ErrorHandlerTraits {}; - -/// Specialization for member functions of the form -/// 'RetT (std::unique_ptr)'. -template -class ErrorHandlerTraits)> - : public ErrorHandlerTraits)> {}; - -/// Specialization for member functions of the form -/// 'RetT (std::unique_ptr) const'. -template -class ErrorHandlerTraits) const> - : public ErrorHandlerTraits)> {}; +} // namespace detail. + +template +struct ErrorHandlerTraits + : public CallableTraitsHelper {}; inline Error handleErrorsImpl(std::unique_ptr Payload) { return make_error(std::move(Payload));