Files
swift-mirror/test/Interop/Cxx/class/inline-function-codegen/Inputs/constructor-calls-function-from-nested-struct.h
Alex 93c4c621b7 [cxx-interop] Walk initializer decls when walking constructor decls (#41584)
This addresses SR-15272.

When you have a function (e.g. 'foo') which is used in a constructor
initializer (e.g. constructor of some class 'Bar'), and you use the
constructor from swift code without directly using the function (e.g.
Bar's ctor is used from swift but foo isn't, foo is used from Bar's ctor),
you will get a link error. My fix is as follows:

When walking the clangAST to be imported, make sure you look at each
CXXCtorInitializer for each CXXConstructorDecl you see.
2022-03-14 09:56:55 -07:00

32 lines
827 B
C

#ifndef TEST_INTEROP_CXX_CLASS_INLINE_FUNCTION_THROUGH_MEMBER_INPUTS_CONSTRUCTOR_CALLS_FUNCTION_FROM_NESTED_STRUCT_H
#define TEST_INTEROP_CXX_CLASS_INLINE_FUNCTION_THROUGH_MEMBER_INPUTS_CONSTRUCTOR_CALLS_FUNCTION_FROM_NESTED_STRUCT_H
inline int increment(int t) { return t + 1; }
struct IncrementUser {
struct Incrementor {
int value;
Incrementor(int v) { value = increment(v); }
};
};
inline int callConstructor(int value) {
return IncrementUser::Incrementor(value).value;
}
inline int get42() { return 42; }
struct HoldMemberThatHolds42 {
struct Hold42 {
int m = get42();
};
Hold42 holder;
};
struct HoldMemberThatHoldsMemberThatHolds42 {
HoldMemberThatHolds42 holder;
};
#endif // TEST_INTEROP_CXX_CLASS_INLINE_FUNCTION_THROUGH_MEMBER_INPUTS_CONSTRUCTOR_CALLS_FUNCTION_FROM_NESTED_STRUCT_H