Files
swift-mirror/test/Interop/Cxx/reference/Inputs/reference.h
Egor Zhdan 5b5ffde79e [cxx-interop] Do not crash when passing Bool as const T& parameter
The type bridging logic assumed that if a value of type `Swift.Bool` is passed to a Clang function as an argument, then the type of the parameter must be a Clang built-in type (usually `_Bool`). This is not always correct. For instance, the type might be a templated const reference.

rdar://125508505
2024-05-09 15:28:33 +01:00

51 lines
1.4 KiB
C++

#ifndef TEST_INTEROP_CXX_REFERENCE_INPUTS_REFERENCE_H
#define TEST_INTEROP_CXX_REFERENCE_INPUTS_REFERENCE_H
int getStaticInt();
int &getStaticIntRef();
int &&getStaticIntRvalueRef();
const int &getConstStaticIntRef();
const int &&getConstStaticIntRvalueRef();
void setStaticInt(int);
void setStaticIntRef(int &);
void setStaticIntRvalueRef(int &&);
void setConstStaticIntRef(const int &);
void setConstStaticIntRvalueRef(const int &&);
auto getFuncRef() -> int (&)();
auto getFuncRvalueRef() -> int (&&)();
using ConstIntRefTypealias = const int &;
void setConstStaticIntRefTypealias(ConstIntRefTypealias ref);
using IntRefTypealias = int &;
void setStaticIntRefTypealias(IntRefTypealias ref);
template<class T>
struct ClassTemplate {};
template<class T>
const ClassTemplate<T> &refToDependent() { return ClassTemplate<T>(); }
// We cannot import "_Atomic" types. Make sure we fail gracefully instead of
// crashing when we have an "_Atomic" type or a reference to one.
void dontImportAtomicRef(_Atomic(int)&) { }
void takeConstRef(const int &);
inline bool takeConstRefBool(const bool &b) { return b; }
inline void takeRefBool(bool &b) { b = true; }
template<class T>
T &refToTemplate(T &t) { return t; }
template<class T>
const T &constRefToTemplate(const T &t) { return t; }
template<class T>
void refToDependentParam(ClassTemplate<T> &param) { }
#endif // TEST_INTEROP_CXX_REFERENCE_INPUTS_REFERENCE_H