mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #29219 from aschwaighofer/irgen_fix_zero_size_field_instanceStart_2
IRGen: Correctly compute instanceStart for a Swift class that starts …
This commit is contained in:
@@ -165,6 +165,8 @@ namespace {
|
||||
|
||||
ClassMetadataOptions Options;
|
||||
|
||||
Size HeaderSize;
|
||||
|
||||
public:
|
||||
ClassLayoutBuilder(IRGenModule &IGM, SILType classType,
|
||||
ReferenceCounting refcounting,
|
||||
@@ -178,11 +180,13 @@ namespace {
|
||||
case ReferenceCounting::Native:
|
||||
// For native classes, place a full object header.
|
||||
addHeapHeader();
|
||||
HeaderSize = CurSize;
|
||||
break;
|
||||
case ReferenceCounting::ObjC:
|
||||
// For ObjC-inheriting classes, we don't reliably know the size of the
|
||||
// base class, but NSObject only has an `isa` pointer at most.
|
||||
addNSObjectHeader();
|
||||
HeaderSize = CurSize;
|
||||
break;
|
||||
case ReferenceCounting::Block:
|
||||
case ReferenceCounting::Unknown:
|
||||
@@ -222,7 +226,7 @@ namespace {
|
||||
auto allElements = IGM.Context.AllocateCopy(Elements);
|
||||
|
||||
return ClassLayout(*this, Options, classTy,
|
||||
allStoredProps, allFieldAccesses, allElements);
|
||||
allStoredProps, allFieldAccesses, allElements, HeaderSize);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user