From 568a5d69172745de29c0b3e7912f20febc81bc8e Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Sun, 14 Sep 2025 11:44:56 +1000 Subject: [PATCH] [orc-rt] Add CallableTraitsHelper, refactor WrapperFunction to use it. CallableTraitsHelper identifies the return type and argument types of a callable type and passes those to an implementation class template to operate on. The CallableArgInfo utility uses CallableTraitsHelper to provide typedefs for the return type and argument types (as a tuple) of a callable type. In WrapperFunction.h, the detail::WFCallableTraits utility is rewritten in terms of CallableTraitsHandler (and renamed to WFHandlerTraits). --- orc-rt/include/orc-rt/CallableTraitsHelper.h | 74 ++++++++++++++++++ orc-rt/include/orc-rt/WrapperFunction.h | 77 ++++++++----------- orc-rt/unittests/CMakeLists.txt | 1 + orc-rt/unittests/CallableTraitsHelperTest.cpp | 69 +++++++++++++++++ 4 files changed, 176 insertions(+), 45 deletions(-) create mode 100644 orc-rt/include/orc-rt/CallableTraitsHelper.h create mode 100644 orc-rt/unittests/CallableTraitsHelperTest.cpp diff --git a/orc-rt/include/orc-rt/CallableTraitsHelper.h b/orc-rt/include/orc-rt/CallableTraitsHelper.h new file mode 100644 index 0000000000000..12d7d5672c73a --- /dev/null +++ b/orc-rt/include/orc-rt/CallableTraitsHelper.h @@ -0,0 +1,74 @@ +//===- CallableTraitsHelper.h - Callable arg/ret type extractor -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// CallableTraitsHelper API. +// +//===----------------------------------------------------------------------===// + +#ifndef ORC_RT_CALLABLETRAITSHELPER_H +#define ORC_RT_CALLABLETRAITSHELPER_H + +#include +#include + +namespace orc_rt { + +/// CallableTraitsHelper takes an implementation class template Impl and some +/// callable type C and passes the return and argument types of C to the Impl +/// class template. +/// +/// This can be used to simplify the implementation of classes that need to +/// operate on callable types. +template