@@ -1818,9 +1818,6 @@ class MetadataReader {
1818
1818
if (!bounds)
1819
1819
return std::nullopt;
1820
1820
1821
- bounds->adjustForSubclass (type->areImmediateMembersNegative (),
1822
- type->NumImmediateMembers );
1823
-
1824
1821
return bounds->ImmediateMembersOffset / sizeof (StoredPointer);
1825
1822
}
1826
1823
@@ -1845,35 +1842,45 @@ class MetadataReader {
1845
1842
std::optional<ClassMetadataBounds>
1846
1843
readMetadataBoundsOfSuperclass (ContextDescriptorRef subclassRef) {
1847
1844
auto subclass = cast<TargetClassDescriptor<Runtime>>(subclassRef);
1848
- if (!subclass->hasResilientSuperclass ())
1849
- return ClassMetadataBounds::forSwiftRootClass ();
1845
+ std::optional<ClassMetadataBounds> bounds;
1850
1846
1851
- auto rawSuperclass =
1852
- resolveRelativeField (subclassRef, subclass->getResilientSuperclass ());
1853
- if (!rawSuperclass) {
1854
- return ClassMetadataBounds::forSwiftRootClass ();
1855
- }
1847
+ if (!subclass->hasResilientSuperclass ()) {
1848
+ bounds = ClassMetadataBounds::forSwiftRootClass ();
1849
+ } else {
1850
+ auto rawSuperclass =
1851
+ resolveRelativeField (subclassRef, subclass->getResilientSuperclass ());
1852
+ if (!rawSuperclass) {
1853
+ return std::nullopt;
1854
+ }
1856
1855
1857
- return forTypeReference<ClassMetadataBounds>(
1858
- subclass->getResilientSuperclassReferenceKind (), rawSuperclass,
1859
- [&](ContextDescriptorRef superclass)
1860
- -> std::optional<ClassMetadataBounds> {
1861
- if (!isa<TargetClassDescriptor<Runtime>>(superclass))
1862
- return std::nullopt;
1863
- return readMetadataBoundsOfSuperclass (superclass);
1864
- },
1865
- [&](MetadataRef metadata) -> std::optional<ClassMetadataBounds> {
1866
- auto cls = dyn_cast<TargetClassMetadata>(metadata);
1867
- if (!cls)
1856
+ bounds = forTypeReference<ClassMetadataBounds>(
1857
+ subclass->getResilientSuperclassReferenceKind (), rawSuperclass,
1858
+ [&](ContextDescriptorRef superclass)
1859
+ -> std::optional<ClassMetadataBounds> {
1860
+ if (!isa<TargetClassDescriptor<Runtime>>(superclass))
1861
+ return std::nullopt;
1862
+ return readMetadataBoundsOfSuperclass (superclass);
1863
+ },
1864
+ [&](MetadataRef metadata) -> std::optional<ClassMetadataBounds> {
1865
+ auto cls = dyn_cast<TargetClassMetadata>(metadata);
1866
+ if (!cls)
1867
+ return std::nullopt;
1868
+
1869
+ return cls->getClassBoundsAsSwiftSuperclass ();
1870
+ },
1871
+ [](StoredPointer objcClassName)
1872
+ -> std::optional<ClassMetadataBounds> {
1873
+ // We have no ability to look up an ObjC class by name.
1874
+ // FIXME: add a query for this; clients may have a way to do it.
1868
1875
return std::nullopt;
1869
-
1870
- return cls-> getClassBoundsAsSwiftSuperclass ();
1871
- },
1872
- [](StoredPointer objcClassName) -> std::optional<ClassMetadataBounds> {
1873
- // We have no ability to look up an ObjC class by name.
1874
- // FIXME: add a query for this; clients may have a way to do it.
1875
- return std::nullopt ;
1876
- }) ;
1876
+ });
1877
+ }
1878
+ if (!bounds) {
1879
+ return std::nullopt;
1880
+ }
1881
+ bounds-> adjustForSubclass (subclass-> areImmediateMembersNegative (),
1882
+ subclass-> NumImmediateMembers ) ;
1883
+ return bounds ;
1877
1884
}
1878
1885
1879
1886
template <class Result , class DescriptorFn , class MetadataFn ,
@@ -1885,11 +1892,12 @@ class MetadataReader {
1885
1892
const ClassNameFn &classNameFn) {
1886
1893
switch (refKind) {
1887
1894
case TypeReferenceKind::IndirectTypeDescriptor: {
1888
- StoredPointer descriptorAddress = 0 ;
1889
- if (!Reader->readInteger (RemoteAddress (ref), &descriptorAddress))
1895
+ StoredSignedPointer descriptorAddress;
1896
+ if (!Reader->readInteger (RemoteAddress (ref), &descriptorAddress)) {
1890
1897
return std::nullopt;
1898
+ }
1891
1899
1892
- ref = descriptorAddress;
1900
+ ref = stripSignedPointer ( descriptorAddress) ;
1893
1901
LLVM_FALLTHROUGH;
1894
1902
}
1895
1903
0 commit comments