xref: /minix3/external/bsd/llvm/dist/clang/test/Rewriter/rewrite-cast-ivar-access.mm (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp
2*f4a2713aSLionel Sambuc// RUN: FileCheck -check-prefix CHECK-LP --input-file=%t-rw.cpp %s
3*f4a2713aSLionel Sambuc// radar 7575882
4*f4a2713aSLionel Sambuc
5*f4a2713aSLionel Sambuc@interface F {
6*f4a2713aSLionel Sambuc  int supervar;
7*f4a2713aSLionel Sambuc}
8*f4a2713aSLionel Sambuc@end
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambuc@interface G : F {
11*f4a2713aSLionel Sambuc@public
12*f4a2713aSLionel Sambuc  int ivar;
13*f4a2713aSLionel Sambuc}
14*f4a2713aSLionel Sambuc@end
15*f4a2713aSLionel Sambuc
16*f4a2713aSLionel Sambuc@implementation G
17*f4a2713aSLionel Sambuc- (void)foo:(F *)arg {
18*f4a2713aSLionel Sambuc        int q = arg->supervar;
19*f4a2713aSLionel Sambuc        int v = ((G *)arg)->ivar;
20*f4a2713aSLionel Sambuc}
21*f4a2713aSLionel Sambuc@end
22*f4a2713aSLionel Sambuc
23*f4a2713aSLionel Sambucvoid objc_assign_strongCast(id);
24*f4a2713aSLionel Sambucvoid __CFAssignWithWriteBarrier(void **location, void *value) {
25*f4a2713aSLionel Sambuc        objc_assign_strongCast((id)value);
26*f4a2713aSLionel Sambuc}
27*f4a2713aSLionel Sambuc
28*f4a2713aSLionel Sambuc// radar 7607605
29*f4a2713aSLionel Sambuc@interface RealClass {
30*f4a2713aSLionel Sambuc        @public
31*f4a2713aSLionel Sambuc        int f;
32*f4a2713aSLionel Sambuc}
33*f4a2713aSLionel Sambuc@end
34*f4a2713aSLionel Sambuc
35*f4a2713aSLionel Sambuc@implementation RealClass
36*f4a2713aSLionel Sambuc@end
37*f4a2713aSLionel Sambuc
38*f4a2713aSLionel Sambuc@interface Foo {
39*f4a2713aSLionel Sambuc        id reserved;
40*f4a2713aSLionel Sambuc}
41*f4a2713aSLionel Sambuc@end
42*f4a2713aSLionel Sambuc
43*f4a2713aSLionel Sambuc@implementation Foo
44*f4a2713aSLionel Sambuc- (void)bar {
45*f4a2713aSLionel Sambuc        ((RealClass*)reserved)->f = 99;
46*f4a2713aSLionel Sambuc}
47*f4a2713aSLionel Sambuc@end
48*f4a2713aSLionel Sambuc
49*f4a2713aSLionel Sambuc// CHECK-LP: ((struct G_IMPL *)arg)->ivar
50*f4a2713aSLionel Sambuc
51*f4a2713aSLionel Sambuc// CHECK-LP: objc_assign_strongCast((id)value)
52*f4a2713aSLionel Sambuc
53*f4a2713aSLionel Sambuc// CHECK-LP: ((struct RealClass_IMPL *)((RealClass *)((struct Foo_IMPL *)self)->reserved))->f
54