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