Skip to content

Commit 674e9d6

Browse files
committed
Add a comment to canUnsafeCast in SILType.cpp.
I added a FIXME so that no one confuses the current implementation with the ABI's type layout rules. (The implementation was conservative out of paranoia.)
1 parent 9185ef5 commit 674e9d6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/SIL/SILType.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ bool SILType::isPointerSizeAndAligned() {
119119
// struct {A, B, C} -> struct {A, B} is castable
120120
// struct { struct {A, B}, C} -> struct {A, B} is castable
121121
// struct { A, B, C} -> struct { struct {A, B}, C} is NOT castable
122+
//
123+
// FIXME: This is unnecessarily conservative given the current ABI
124+
// (TypeLayout.rst). It would be simpler to flatten both `from` and `to` types,
125+
// exploding all structs and tuples, then trivially check if `to` is a prefix.
122126
static bool canUnsafeCastStruct(SILType fromType, StructDecl *fromStruct,
123127
SILType toType, SILModule &M) {
124128
auto fromRange = fromStruct->getStoredProperties();

0 commit comments

Comments
 (0)