summaryrefslogtreecommitdiff
path: root/clang/test/CodeGenObjCXX/literals.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/literals.mm
parentc4626a62754862d20b41e8a46a3574264ea80e6d (diff)
parentf1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff)
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/CodeGenObjCXX/literals.mm')
-rw-r--r--clang/test/CodeGenObjCXX/literals.mm111
1 files changed, 111 insertions, 0 deletions
diff --git a/clang/test/CodeGenObjCXX/literals.mm b/clang/test/CodeGenObjCXX/literals.mm
new file mode 100644
index 0000000..b8946fa
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/literals.mm
@@ -0,0 +1,111 @@
+// RUN: %clang_cc1 -I %S/Inputs -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-arc-exceptions -O2 -disable-llvm-optzns -o - %s | FileCheck %s
+
+#include "literal-support.h"
+
+struct X {
+ X();
+ ~X();
+ operator id() const;
+};
+
+struct Y {
+ Y();
+ ~Y();
+ operator id() const;
+};
+
+// CHECK: define void @_Z10test_arrayv
+void test_array() {
+ // CHECK: [[OBJECTS:%[a-zA-Z0-9.]+]] = alloca [2 x i8*]
+
+ // Initializing first element
+ // CHECK: [[ELEMENT0:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x i8*]* [[OBJECTS]], i32 0, i32 0
+ // CHECK-NEXT: call void @_ZN1XC1Ev
+ // CHECK-NEXT: [[OBJECT0:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1XcvP11objc_objectEv
+ // CHECK: [[RET0:%[a-zA-Z0-9.]+]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[OBJECT0]])
+ // CHECK: store i8* [[RET0]], i8** [[ELEMENT0]]
+
+ // Initializing the second element
+ // CHECK: [[ELEMENT1:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x i8*]* [[OBJECTS]], i32 0, i32 1
+ // CHECK-NEXT: invoke void @_ZN1YC1Ev
+ // CHECK: [[OBJECT1:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1YcvP11objc_objectEv
+ // CHECK: [[RET1:%[a-zA-Z0-9.]+]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[OBJECT1]])
+ // CHECK: store i8* [[RET1]], i8** [[ELEMENT1]]
+
+ // Build the array
+ // CHECK: {{invoke.*@objc_msgSend}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id arr = @[ X(), Y() ];
+
+ // Destroy temporaries
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NOT: ret void
+ // CHECK: invoke void @_ZN1YD1Ev
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: call void @_ZN1XD1Ev
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+
+ // Check cleanups
+ // CHECK: call void @objc_release
+ // CHECK-NOT: call void @objc_release
+ // CHECK: invoke void @_ZN1YD1Ev
+ // CHECK: call void @objc_release
+ // CHECK-NOT: call void @objc_release
+ // CHECK: invoke void @_ZN1XD1Ev
+ // CHECK-NOT: call void @objc_release
+ // CHECK: unreachable
+}
+
+// CHECK: define weak_odr void @_Z24test_array_instantiationIiEvv
+template<typename T>
+void test_array_instantiation() {
+ // CHECK: [[OBJECTS:%[a-zA-Z0-9.]+]] = alloca [2 x i8*]
+
+ // Initializing first element
+ // CHECK: [[ELEMENT0:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x i8*]* [[OBJECTS]], i32 0, i32 0
+ // CHECK-NEXT: call void @_ZN1XC1Ev
+ // CHECK-NEXT: [[OBJECT0:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1XcvP11objc_objectEv
+ // CHECK: [[RET0:%[a-zA-Z0-9.]+]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[OBJECT0]])
+ // CHECK: store i8* [[RET0]], i8** [[ELEMENT0]]
+
+ // Initializing the second element
+ // CHECK: [[ELEMENT1:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x i8*]* [[OBJECTS]], i32 0, i32 1
+ // CHECK-NEXT: invoke void @_ZN1YC1Ev
+ // CHECK: [[OBJECT1:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1YcvP11objc_objectEv
+ // CHECK: [[RET1:%[a-zA-Z0-9.]+]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[OBJECT1]])
+ // CHECK: store i8* [[RET1]], i8** [[ELEMENT1]]
+
+ // Build the array
+ // CHECK: {{invoke.*@objc_msgSend}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id arr = @[ X(), Y() ];
+
+ // Destroy temporaries
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NOT: ret void
+ // CHECK: invoke void @_ZN1YD1Ev
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: call void @_ZN1XD1Ev
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+
+ // Check cleanups
+ // CHECK: call void @objc_release
+ // CHECK-NOT: call void @objc_release
+ // CHECK: invoke void @_ZN1YD1Ev
+ // CHECK: call void @objc_release
+ // CHECK-NOT: call void @objc_release
+ // CHECK: invoke void @_ZN1XD1Ev
+ // CHECK-NOT: call void @objc_release
+ // CHECK: unreachable
+}
+
+template void test_array_instantiation<int>();
+