File tree 3 files changed +21
-4
lines changed
3 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -1699,11 +1699,18 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
1699
1699
llvm::Value *EmitIvarOffset (CodeGenFunction &CGF,
1700
1700
const ObjCInterfaceDecl *Interface,
1701
1701
const ObjCIvarDecl *Ivar) override {
1702
- const std::string Name = GetIVarOffsetVariableName (Ivar->getContainingInterface (), Ivar);
1702
+ const ObjCInterfaceDecl *ContainingInterface =
1703
+ Ivar->getContainingInterface ();
1704
+ const std::string Name =
1705
+ GetIVarOffsetVariableName (ContainingInterface, Ivar);
1703
1706
llvm::GlobalVariable *IvarOffsetPointer = TheModule.getNamedGlobal (Name);
1704
- if (!IvarOffsetPointer)
1707
+ if (!IvarOffsetPointer) {
1705
1708
IvarOffsetPointer = new llvm::GlobalVariable (TheModule, IntTy, false ,
1706
1709
llvm::GlobalValue::ExternalLinkage, nullptr , Name);
1710
+ if (Ivar->getAccessControl () != ObjCIvarDecl::Private &&
1711
+ Ivar->getAccessControl () != ObjCIvarDecl::Package)
1712
+ CGM.setGVProperties (IvarOffsetPointer, ContainingInterface);
1713
+ }
1707
1714
CharUnits Align = CGM.getIntAlign ();
1708
1715
llvm::Value *Offset =
1709
1716
CGF.Builder .CreateAlignedLoad (IntTy, IvarOffsetPointer, Align);
Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ @interface M : I {
112
112
// CHECK-IR-DAG: @"OBJC_IVAR_$_M._ivar" = external dllimport global i32
113
113
114
114
// CHECK-NF-DAG: @"$_OBJC_REF_CLASS_M" = external dllimport global ptr
115
- // CHECK-NF-DAG: @"__objc_ivar_offset_M._ivar.@" = external global i32
115
+ // CHECK-NF-DAG: @"__objc_ivar_offset_M._ivar.@" = external dllimport global i32
116
116
117
117
__declspec (dllexport)
118
118
__attribute__((__objc_exception__))
@@ -151,7 +151,7 @@ id f(Q *q) {
151
151
152
152
// CHECK-IR-DAG: @"OBJC_IVAR_$_M._ivar" = external dllimport global i32
153
153
154
- // CHECK-NF-DAG: @"__objc_ivar_offset_M._ivar.@" = external global i32
154
+ // CHECK-NF-DAG: @"__objc_ivar_offset_M._ivar.@" = external dllimport global i32
155
155
156
156
int g (void ) {
157
157
@autoreleasepool {
Original file line number Diff line number Diff line change 2
2
3
3
@interface MySuperClass
4
4
{
5
+ int unmarked;
6
+
5
7
@private
6
8
int private;
7
9
@@ -17,6 +19,7 @@ @implementation MySuperClass
17
19
- (void ) test {
18
20
int access ;
19
21
MySuperClass *s = 0 ;
22
+ access = s->unmarked ;
20
23
access = s->private ;
21
24
access = s->protected ;
22
25
}
@@ -30,9 +33,11 @@ @implementation MyClass
30
33
- (void ) test {
31
34
int access ;
32
35
MySuperClass *s = 0 ;
36
+ access = s->unmarked ;
33
37
access = s->private ; // expected-error {{instance variable 'private' is private}}
34
38
access = s->protected ;
35
39
MyClass *m=0 ;
40
+ access = m->unmarked ;
36
41
access = m->private ; // expected-error {{instance variable 'private' is private}}
37
42
access = m->protected ;
38
43
}
@@ -46,9 +51,11 @@ @implementation Deeper
46
51
- (void ) test {
47
52
int access ;
48
53
MySuperClass *s = 0 ;
54
+ access = s->unmarked ;
49
55
access = s->private ; // expected-error {{instance variable 'private' is private}}
50
56
access = s->protected ;
51
57
MyClass *m=0 ;
58
+ access = m->unmarked ;
52
59
access = m->private ; // expected-error {{instance variable 'private' is private}}
53
60
access = m->protected ;
54
61
}
@@ -61,9 +68,11 @@ @implementation Unrelated
61
68
- (void ) test {
62
69
int access ;
63
70
MySuperClass *s = 0 ;
71
+ access = s->unmarked ; // expected-error {{instance variable 'unmarked' is protected}}
64
72
access = s->private ; // expected-error {{instance variable 'private' is private}}
65
73
access = s->protected ; // expected-error {{instance variable 'protected' is protected}}
66
74
MyClass *m=0 ;
75
+ access = m->unmarked ; // expected-error {{instance variable 'unmarked' is protected}}
67
76
access = m->private ; // expected-error {{instance variable 'private' is private}}
68
77
access = m->protected ; // expected-error {{instance variable 'protected' is protected}}
69
78
}
@@ -73,6 +82,7 @@ int main (void)
73
82
{
74
83
MySuperClass *s = 0 ;
75
84
int access ;
85
+ access = s->unmarked ; // expected-error {{instance variable 'unmarked' is protected}}
76
86
access = s->private ; // expected-error {{instance variable 'private' is private}}
77
87
access = s->protected ; // expected-error {{instance variable 'protected' is protected}}
78
88
return 0 ;
You can’t perform that action at this time.
0 commit comments