[PATCH] D15169: [SemaCXX] Fix handling of C-style casts from void pointers to pointers in different address space.

Manuel Jacob via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 2 17:51:36 PST 2015


mjacob added inline comments.

================
Comment at: lib/Sema/SemaCast.cpp:1081-1083
@@ -1080,3 +1080,5 @@
           }
-          Kind = CK_BitCast;
+          unsigned SrcAS = SrcPointee.getAddressSpace();
+          unsigned DestAS = DestPointee.getAddressSpace();
+          Kind = SrcAS != DestAS ? CK_AddressSpaceConversion : CK_BitCast;
           return TC_Success;
----------------
rsmith wrote:
> I would expect to get both a `CK_BitCast` *and* a `CK_AddressSpaceCast` created for this case. Note that by not returning `CK_BitCast`, you lose the `checkCastAlign` call in the caller.
> 
> Instead, can you push this check down into wherever we're building the conversion, so that if we try to create a `CK_BitCast` that crosses address spaces, we additionally create a `CK_AddressSpaceCast`?
I'm not sure what you mean by "**additionally** create a `CK_AddressSpaceCast`". Please clarify.

Would it also be possible to extend all places which call `checkCastAlign()` to also call it for `CK_AddressSpaceCast`?


http://reviews.llvm.org/D15169





More information about the cfe-commits mailing list