summaryrefslogtreecommitdiff
path: root/clang/test/CodeGenObjCXX/ivar-objects.mm
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
committerCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
commitbe1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch)
tree1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/CodeGenObjCXX/ivar-objects.mm
parentc4626a62754862d20b41e8a46a3574264ea80e6d (diff)
parentf1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff)
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/CodeGenObjCXX/ivar-objects.mm')
-rw-r--r--clang/test/CodeGenObjCXX/ivar-objects.mm104
1 files changed, 104 insertions, 0 deletions
diff --git a/clang/test/CodeGenObjCXX/ivar-objects.mm b/clang/test/CodeGenObjCXX/ivar-objects.mm
new file mode 100644
index 0000000..d05763b
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/ivar-objects.mm
@@ -0,0 +1,104 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// CHECK: -[A .cxx_construct]
+// CHECK: -[A .cxx_destruct]
+// CHECK: -[B .cxx_construct]
+// CHECK-NOT: -[B .cxx_destruct]
+// CHECK-NOT: -[C .cxx_construct]
+// CHECK: -[C .cxx_destruct]
+
+@interface NSObject
+- alloc;
+- init;
+- (void) release;
+@end
+
+extern "C" int printf(const char *, ...);
+
+int count = 17;
+struct X {
+ X() : value(count++) { printf( "X::X()\n"); }
+ ~X() { printf( "X::~X()\n"); }
+ int value;
+};
+
+struct Y {
+ Y() : value(count++) { printf( "Y::Y()\n"); }
+ ~Y() { printf( "Y::~Y()\n"); }
+ int value;
+};
+
+@interface Super : NSObject {
+ Y yvar;
+ Y yvar1;
+ Y ya[3];
+}
+- (void)finalize;
+@end
+
+@interface A : Super {
+ X xvar;
+ X xvar1;
+ X xvar2;
+ X xa[2][2];
+}
+
+- (void)print;
+- (void)finalize;
+@end
+
+@implementation Super
+- (void)print {
+ printf( "yvar.value = %d\n", yvar.value);
+ printf( "yvar1.value = %d\n", yvar1.value);
+ printf( "ya[0..2] = %d %d %d\n", ya[0].value, ya[1].value, ya[2].value);
+}
+- (void)finalize {}
+@end
+
+@implementation A
+- (void)print {
+ printf( "xvar.value = %d\n", xvar.value);
+ printf( "xvar1.value = %d\n", xvar1.value);
+ printf( "xvar2.value = %d\n", xvar2.value);
+ printf( "xa[0..1][0..1] = %d %d %d %d\n",
+ xa[0][0].value, xa[0][1].value, xa[1][0].value, xa[1][1].value);
+ [super print];
+}
+- (void)finalize { [super finalize]; }
+@end
+
+int main() {
+ A *a = [[A alloc] init];
+ [a print];
+ [a release];
+}
+
+// rdar: // 7468090
+class S {
+public:
+ S& operator = (const S&);
+};
+
+@interface I {
+ S position;
+}
+@property(assign, nonatomic) S position;
+@end
+
+@implementation I
+ @synthesize position;
+@end
+
+// This class should have a .cxx_construct but no .cxx_destruct.
+namespace test3 { struct S { S(); }; }
+@implementation B {
+ test3::S s;
+}
+@end
+
+// This class should have a .cxx_destruct but no .cxx_construct.
+namespace test4 { struct S { ~S(); }; }
+@implementation C {
+ test4::S s;
+}
+@end