Debian Codegraph @

clang/test/CodeGenObjCXX/ivar-objects.mm

raw
1 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
2 // CHECK: -[A .cxx_construct]
3 // CHECK: -[A .cxx_destruct]
4 // CHECK: -[B .cxx_construct]
5 // CHECK-NOT: -[B .cxx_destruct]
6 // CHECK-NOT: -[C .cxx_construct]
7 // CHECK: -[C .cxx_destruct]
8
9 @interface NSObject
10 - alloc;
11 - init;
12 - (void) release;
13 @end
14
15 extern "C" int printf(const char *, ...);
16
17 int count = 17;
18 struct X {
19 X() : value(count++) { printf( "X::X()\n"); }
20 ~X() { printf( "X::~X()\n"); }
21 int value;
22 };
23
24 struct Y {
25 Y() : value(count++) { printf( "Y::Y()\n"); }
26 ~Y() { printf( "Y::~Y()\n"); }
27 int value;
28 };
29
30 @interface Super : NSObject {
31 Y yvar;
32 Y yvar1;
33 Y ya[3];
34 }
35 - (void)finalize;
36 @end
37
38 @interface A : Super {
39 X xvar;
40 X xvar1;
41 X xvar2;
42 X xa[2][2];
43 }
44
45 - (void)print;
46 - (void)finalize;
47 @end
48
49 @implementation Super
50 - (void)print {
51 printf( "yvar.value = %d\n", yvar.value);
52 printf( "yvar1.value = %d\n", yvar1.value);
53 printf( "ya[0..2] = %d %d %d\n", ya[0].value, ya[1].value, ya[2].value);
54 }
55 - (void)finalize {}
56 @end
57
58 @implementation A
59 - (void)print {
60 printf( "xvar.value = %d\n", xvar.value);
61 printf( "xvar1.value = %d\n", xvar1.value);
62 printf( "xvar2.value = %d\n", xvar2.value);
63 printf( "xa[0..1][0..1] = %d %d %d %d\n",
64 xa[0][0].value, xa[0][1].value, xa[1][0].value, xa[1][1].value);
65 [super print];
66 }
67 - (void)finalize { [super finalize]; }
68 @end
69
70 int main() {
71 A *a = [[A alloc] init];
72 [a print];
73 [a release];
74 }
75
76 class S {
77 public:
78 S& operator = (const S&);
79 };
80
81 @interface I {
82 S position;
83 }
84 @property(assign, nonatomic) S position;
85 @end
86
87 @implementation I
88 @synthesize position;
89 @end
90
91 // This class should have a .cxx_construct but no .cxx_destruct.
92 namespace test3 { struct S { S(); }; }
93 @implementation B {
94 test3::S s;
95 }
96 @end
97
98 // This class should have a .cxx_destruct but no .cxx_construct.
99 namespace test4 { struct S { ~S(); }; }
100 @implementation C {
101 test4::S s;
102 }
103 @end