When for example handling C-style casts from void * to `int
attribute((address_space(1))) *` in C++ code, Sema previously set the cast
kind to CK_BitCast incorrectly, which caused an assert to fail in CodeGen. This
patch changes Sema to set the cast kind to CK_AddressSpaceConversion if source
and destination point to different address spaces.
Details
- Reviewers
aaron.ballman rsmith
Diff Detail
Event Timeline
lib/Sema/SemaCast.cpp | ||
---|---|---|
1081–1083 | 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? |
lib/Sema/SemaCast.cpp | ||
---|---|---|
1081–1083 | 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? |
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?