summaryrefslogtreecommitdiffstats
path: root/test/CodeGenObjCXX
diff options
context:
space:
mode:
Diffstat (limited to 'test/CodeGenObjCXX')
-rw-r--r--test/CodeGenObjCXX/encode.mm52
-rw-r--r--test/CodeGenObjCXX/mangle-blocks.mm50
-rw-r--r--test/CodeGenObjCXX/property-objects.mm51
3 files changed, 153 insertions, 0 deletions
diff --git a/test/CodeGenObjCXX/encode.mm b/test/CodeGenObjCXX/encode.mm
new file mode 100644
index 0000000..83fb31e
--- /dev/null
+++ b/test/CodeGenObjCXX/encode.mm
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// CHECK: v17@0:8{vector<float, float, float>=}16
+// CHECK: {vector<float, float, float>=}
+// CHECK: v24@0:816
+
+template <typename T1, typename T2, typename T3> struct vector {
+ vector();
+ vector(T1,T2,T3);
+};
+
+typedef vector< float, float, float > vector3f;
+
+@interface SceneNode
+{
+ vector3f position;
+}
+
+@property (assign, nonatomic) vector3f position;
+
+@end
+
+@interface MyOpenGLView
+{
+@public
+ vector3f position;
+}
+@property vector3f position;
+@end
+
+@implementation MyOpenGLView
+
+@synthesize position;
+
+-(void)awakeFromNib {
+ SceneNode *sn;
+ vector3f VF3(1.0, 1.0, 1.0);
+ [sn setPosition:VF3];
+}
+@end
+
+
+class Int3 { int x, y, z; };
+
+// Enforce @encoding for member pointers.
+@interface MemPtr {}
+- (void) foo: (int (Int3::*)) member;
+@end
+@implementation MemPtr
+- (void) foo: (int (Int3::*)) member {
+}
+@end
diff --git a/test/CodeGenObjCXX/mangle-blocks.mm b/test/CodeGenObjCXX/mangle-blocks.mm
new file mode 100644
index 0000000..9f57557
--- /dev/null
+++ b/test/CodeGenObjCXX/mangle-blocks.mm
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 %s | FileCheck %s
+
+// CHECK: @_ZGVN3foo20__foo_block_invoke_05valueE = internal global i64 0
+
+int f();
+
+void foo() {
+ // CHECK: define internal i32 @__foo_block_invoke_0
+ // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVN3foo20__foo_block_invoke_05value
+ (void)^(int x) {
+ static int value = f();
+ return x + value;
+ };
+}
+
+// CHECK: define internal i32 @__block_global_0
+int i = ^(int x) { return x;}(i);
+
+@interface A
+- (void)method;
+@end
+
+@implementation A
+- (void)method {
+ // CHECK: define internal signext i8 @"__11-[A method]_block_invoke_0"
+ (void)^(int x) {
+ // CHECK: @"_ZN11-[A method]30__11-[A method]_block_invoke_04nameE"
+ static const char *name = "hello";
+ return name[x];
+ };
+}
+@end
+
+void foo(int) {
+ (void)^(int x) {
+ static const char *name = "hello";
+ return name[x];
+ };
+}
+
+namespace N {
+ // CHECK: define internal signext i8 @__bar_block_invoke_0
+ void bar() {
+ (void)^(int x) {
+ // CHECK: @_ZN1N3bar20__bar_block_invoke_04nameE
+ static const char *name = "hello";
+ return name[x];
+ };
+ }
+}
diff --git a/test/CodeGenObjCXX/property-objects.mm b/test/CodeGenObjCXX/property-objects.mm
new file mode 100644
index 0000000..662dacc
--- /dev/null
+++ b/test/CodeGenObjCXX/property-objects.mm
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -o - | FileCheck %s
+// CHECK-NOT: callq _objc_msgSend_stret
+// CHECK: call void @_ZN1SC1ERKS_
+// CHECK: call %class.S* @_ZN1SaSERKS_
+// CHECK: call %class.S* @_ZN6CGRectaSERKS_
+
+class S {
+public:
+ S& operator = (const S&);
+ S (const S&);
+ S ();
+};
+
+struct CGRect {
+ CGRect & operator = (const CGRect &);
+};
+
+@interface I {
+ S position;
+ CGRect bounds;
+}
+@property(assign, nonatomic) S position;
+@property CGRect bounds;
+@property CGRect frame;
+- (void)setFrame:(CGRect)frameRect;
+- (CGRect)frame;
+- (void) initWithOwner;
+@end
+
+@implementation I
+@synthesize position;
+@synthesize bounds;
+@synthesize frame;
+- (void)setFrame:(CGRect)frameRect {}
+- (CGRect)frame {return bounds;}
+
+- (void)initWithOwner {
+ I* _labelLayer;
+ CGRect labelLayerFrame = self.bounds;
+ labelLayerFrame = self.bounds;
+ _labelLayer.frame = labelLayerFrame;
+}
+@end
+
+int main() {
+ I *i;
+ S s1;
+ i.position = s1;
+ return 0;
+}
+
OpenPOWER on IntegriCloud