For a static object with a nontrivial destructor, clang generates an
initializer function (__cxx_global_var_init) which registers that
object's destructor using __cxa_atexit. However some ABIs (ARM,
WebAssembly) use destructors that return 'this' instead of having void
return (which does not match the signature of function pointers passed
to __cxa_atexit). WebAssembly requires that all function signatures
of indirect calls exactly match the called function, so it raises an error
when the destructors are called.
This patch introduces CGCXXABI::canCalMismatchedFunctionType()
to specify whether this mismatch is allowed, and disables the direct
registration of destructors for ABIs that have this-returning destructors
on platforms which cannot tolerate the mismatch.
This assignment is looking pretty ugly now, would be better to move out of line.