xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenObjCXX/property-lvalue-capture.mm (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
2*0a6a1f1dSLionel Sambuc// rdar://15118128
3*0a6a1f1dSLionel Sambuc
4*0a6a1f1dSLionel Sambuctemplate <typename T> struct Quad2 {
5*0a6a1f1dSLionel Sambuc  Quad2() {}
6*0a6a1f1dSLionel Sambuc};
7*0a6a1f1dSLionel Sambuc
8*0a6a1f1dSLionel Sambuctypedef Quad2<double> Quad2d;
9*0a6a1f1dSLionel Sambuc
10*0a6a1f1dSLionel Sambuc@interface Root @end
11*0a6a1f1dSLionel Sambuc
12*0a6a1f1dSLionel Sambuc@interface PAGeometryFrame
13*0a6a1f1dSLionel Sambuc- (const Quad2d &)quad;
14*0a6a1f1dSLionel Sambuc- (void)setQuad:(const Quad2d &)quad;
15*0a6a1f1dSLionel Sambuc@end
16*0a6a1f1dSLionel Sambuc
17*0a6a1f1dSLionel Sambuc@interface PA2DScaleTransform  : Root
18*0a6a1f1dSLionel Sambuc@end
19*0a6a1f1dSLionel Sambuc
20*0a6a1f1dSLionel Sambuc@implementation PA2DScaleTransform
21*0a6a1f1dSLionel Sambuc- (void)transformFrame:(PAGeometryFrame *)frame {
22*0a6a1f1dSLionel Sambuc PAGeometryFrame *result;
23*0a6a1f1dSLionel Sambuc result.quad  = frame.quad;
24*0a6a1f1dSLionel Sambuc}
25*0a6a1f1dSLionel Sambuc@end
26*0a6a1f1dSLionel Sambuc
27*0a6a1f1dSLionel Sambuc// CHECK:   [[TWO:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_, !invariant.load ![[MD_NUM:[0-9]+]]
28*0a6a1f1dSLionel Sambuc// CHECK:   [[THREE:%.*]] = bitcast [[ONET:%.*]]* [[ONE:%.*]] to i8*
29*0a6a1f1dSLionel Sambuc// CHECK:   [[CALL:%.*]] = call nonnull %struct.Quad2* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to %struct.Quad2* (i8*, i8*)*)(i8* [[THREE]], i8* [[TWO]])
30*0a6a1f1dSLionel Sambuc// CHECK:   [[FOUR:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_2, !invariant.load ![[MD_NUM]]
31*0a6a1f1dSLionel Sambuc// CHECK:   [[FIVE:%.*]] = bitcast [[ONET]]* [[ZERO:%.*]] to i8*
32*0a6a1f1dSLionel Sambuc// CHECK:   call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, %struct.Quad2*)*)(i8* [[FIVE]], i8* [[FOUR]], %struct.Quad2* nonnull [[CALL]])
33*0a6a1f1dSLionel Sambuc
34*0a6a1f1dSLionel Sambuc
35*0a6a1f1dSLionel Sambucstruct A {
36*0a6a1f1dSLionel Sambuc void *ptr;
37*0a6a1f1dSLionel Sambuc A();
38*0a6a1f1dSLionel Sambuc A(const A &);
39*0a6a1f1dSLionel Sambuc ~A();
40*0a6a1f1dSLionel Sambuc};
41*0a6a1f1dSLionel Sambuc
42*0a6a1f1dSLionel Sambuc@interface C
43*0a6a1f1dSLionel Sambuc- (void) setProp: (const A&) value;
44*0a6a1f1dSLionel Sambuc@end
45*0a6a1f1dSLionel Sambucvoid test(C *c, const A &a) {
46*0a6a1f1dSLionel Sambuc const A &result = c.prop = a;
47*0a6a1f1dSLionel Sambuc}
48*0a6a1f1dSLionel Sambuc
49*0a6a1f1dSLionel Sambuc// CHECK:   [[ONE1:%.*]] = load %struct.A** [[AADDR:%.*]], align 8
50*0a6a1f1dSLionel Sambuc// CHECK:   [[TWO1:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_5, !invariant.load ![[MD_NUM]]
51*0a6a1f1dSLionel Sambuc// CHECK:   [[THREE1:%.*]] = bitcast [[TWOT:%.*]]* [[ZERO1:%.*]] to i8*
52*0a6a1f1dSLionel Sambuc// CHECK:   call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, %struct.A*)*)(i8* [[THREE1]], i8* [[TWO1]], %struct.A* dereferenceable({{[0-9]+}}) [[ONE1]])
53*0a6a1f1dSLionel Sambuc// CHECK:   store %struct.A* [[ONE1]], %struct.A** [[RESULT:%.*]], align 8
54