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