This patch adds a new diagnostic for mismatching address spaces to be used for C++ casts (TODO: only enabled in C style cast for now, the rest will follow!).
This change extends C-style cast rules to account for address spaces. It also adds a separate function for address space cast checking that can be used to map from a separate address space cast operator addrspace_cast (to be added as a follow up patch).
Note, that after this change clang will no longer allows arbitrary address space conversions in reinterpret_casts because they can lead to accidental errors. The implicit safe conversions would still be allowed.
See RFC for more details: http://lists.llvm.org/pipermail/cfe-dev/2018-December/060546.html
This might not be applicable to this patch, but just something I noticed.
So reinterpret_cast only operates on pointers when dealing with address spaces. What about something like
reinterpret_cast on an lvalue like this is equivalent to *reinterpret_cast<T*>(&a). So for AS code:
This should work, since *reinterpret_cast<__generic T*>(&x) is valid, correct?
What if we have the reference cast case with a different address space like this? Doesn't the IsLValueCast check need to be first?