File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -1593,12 +1593,22 @@ class CGObjCNonFragileABIMac : public CGObjCCommonMac {
1593
1593
}
1594
1594
1595
1595
bool isClassLayoutKnownStatically (const ObjCInterfaceDecl *ID) {
1596
- // NSObject is a fixed size. If we can see the @implementation of a class
1597
- // which inherits from NSObject then we know that all it's offsets also must
1598
- // be fixed. FIXME: Can we do this if see a chain of super classes with
1599
- // implementations leading to NSObject?
1600
- return ID->getImplementation () && ID->getSuperClass () &&
1601
- ID->getSuperClass ()->getName () == " NSObject" ;
1596
+ // Test a class by checking its superclasses up to its base class if it has
1597
+ // one
1598
+ while (ID) {
1599
+ // The base class NSObject is a fixed size
1600
+ if (ID->getName () == " NSObject" )
1601
+ return true ;
1602
+
1603
+ // If we cannot see the @implementation of a class, we cannot assume fixed
1604
+ // offsets
1605
+ if (!ID->getImplementation ())
1606
+ return false ;
1607
+
1608
+ // Test superclass
1609
+ ID = ID->getSuperClass ();
1610
+ }
1611
+ return false ;
1602
1612
}
1603
1613
1604
1614
public:
Original file line number Diff line number Diff line change 1
1
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 -emit-llvm %s -o - | FileCheck %s
2
2
3
3
// CHECK: @"OBJC_IVAR_$_StaticLayout.static_layout_ivar" = hidden constant i64 20
4
- // CHECK: @"OBJC_IVAR_$_StaticLayoutSubClass.static_layout_ivar2" = hidden global i64 24
4
+ // CHECK: @"OBJC_IVAR_$_StaticLayoutSubClass.static_layout_ivar2" = hidden constant i64 24
5
5
// CHECK: @"OBJC_IVAR_$_NotStaticLayout.not_static_layout_ivar" = hidden global i64 12
6
6
7
7
@interface NSObject {
@@ -29,7 +29,7 @@ @implementation StaticLayoutSubClass {
29
29
}
30
30
-(void )meth2 {
31
31
static_layout_ivar2 = 0 ;
32
- // CHECK: load i64, ptr @"OBJC_IVAR_$_StaticLayoutSubClass
32
+ // CHECK-NOT : load i64, ptr @"OBJC_IVAR_$_StaticLayoutSubClass
33
33
}
34
34
@end
35
35
You can’t perform that action at this time.
0 commit comments