Files
swift-mirror/test/Interop/Cxx/templates/Inputs/class-template-with-function-parameter.h
Egor Zhdan 74c444d688 [cxx-interop] Emit function types as Swift closures in templated params
This is required to make the compiler distinguish between instantiations of `std::function`.

Previously, when generating a Swift type name for a `std::function` instantiation, we would always emit `_` as the template parameter. If someone referenced two different instantiations of `std::function` in a Swift module, they would get mangled with the same name, triggering linker errors later.

rdar://103979602
2024-01-19 21:02:03 +00:00

22 lines
866 B
C++

#ifndef TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_WITH_FUNCTION_ARGUMENT_H
#define TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_WITH_FUNCTION_ARGUMENT_H
template <typename Fn>
class function_wrapper;
template <typename Ret, typename... Params>
class function_wrapper<Ret(Params...)> {
Ret (*fn)(Params... params) = nullptr;
};
typedef function_wrapper<bool(bool)> FuncBoolToBool;
typedef function_wrapper<bool()> FuncVoidToBool;
typedef function_wrapper<void(bool)> FuncBoolToVoid;
typedef function_wrapper<void()> FuncVoidToVoid;
typedef function_wrapper<int(int)> FuncIntToInt;
typedef function_wrapper<int(int, int)> FuncIntIntToInt;
typedef function_wrapper<void(int, int)> FuncIntIntToVoid;
typedef function_wrapper<void(int, int, bool)> FuncIntIntBoolToVoid;
#endif // TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_WITH_FUNCTION_ARGUMENT_H