Skip to content

Commit 118efad

Browse files
committed
Use Function ptr XI calculations for Thin Func ptrs
1 parent 0ddcf8f commit 118efad

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

include/swift/Reflection/TypeLowering.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,14 @@ class BuiltinTypeInfo : public TypeInfo {
180180
*extraInhabitantIndex = -1;
181181
return true;
182182
}
183-
// XXX Has extra inhabitants, so it must be a pointer?
184-
return reader.readHeapObjectExtraInhabitantIndex(address, extraInhabitantIndex);
183+
// If it has extra inhabitants, it must be a pointer. (The only non-pointer
184+
// data with extra inhabitants is a non-payload enum, which doesn't get here.)
185+
// But there are two different conventions, one for function pointers:
186+
if (self == TypeConverter::getThinFunctionTypeInfo()) {
187+
return reader.readFunctionPointerExtraInhabitantIndex(address, extraInhabitantIndex);
188+
} else {
189+
return reader.readHeapObjectExtraInhabitantIndex(address, extraInhabitantIndex);
190+
}
185191
}
186192

187193
static bool classof(const TypeInfo *TI) {

stdlib/public/Reflection/TypeLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ TypeConverter::getReferenceTypeInfo(ReferenceKind Kind,
746746
return TI;
747747
}
748748

749-
/// Thick functions consist of a function pointer. We do not use
749+
/// Thin functions consist of a function pointer. We do not use
750750
/// Builtin.RawPointer here, since the extra inhabitants differ.
751751
const TypeInfo *
752752
TypeConverter::getThinFunctionTypeInfo() {

0 commit comments

Comments
 (0)