r326307 and r327870 made changes that enable strong and weak fields to be declared in C structs. This patch changes the ObjC++ ABI so that structs with strong or weak pointers can be passed to or returned from functions compiled in C mode.
ObjC and ObjC++ are currently incompatible because of the differences in the way structs are passed and destructed.
For example:
typedef struct {
id f0;
__weak id f1;
} S;
// this code is compiled in c++.
extern “C” {
void foo(S s);
}
void caller(S a) {
foo(a); // clang currently passes 'a' indirectly and the caller destructs 'a'.
}
// this function is compiled in c.
void foo(S a) { // 'a' is passed directly and is destructed in the callee.
}This patch fixes the incompatibility by passing and returning structs with strong or weak fields using the C ABI in C++ mode: strong and weak fields in a struct do not cause the struct to be destructed in the caller and __strong fields do not make the struct to be passed indirectly.
Also, this patch fixes the microsoft ABI bug mentioned here: