2015-10-08 12:24:12 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -debug-info-kind=limited -o - | FileCheck %s
|
2010-05-06 23:45:36 +08:00
|
|
|
|
|
|
|
class S {
|
|
|
|
public:
|
|
|
|
S& operator = (const S&);
|
|
|
|
S (const S&);
|
|
|
|
S ();
|
|
|
|
};
|
|
|
|
|
2010-05-11 06:57:35 +08:00
|
|
|
struct CGRect {
|
|
|
|
CGRect & operator = (const CGRect &);
|
|
|
|
};
|
|
|
|
|
2010-05-06 23:45:36 +08:00
|
|
|
@interface I {
|
|
|
|
S position;
|
2010-05-11 06:57:35 +08:00
|
|
|
CGRect bounds;
|
2010-05-06 23:45:36 +08:00
|
|
|
}
|
2012-11-14 07:16:33 +08:00
|
|
|
|
2010-05-06 23:45:36 +08:00
|
|
|
@property(assign, nonatomic) S position;
|
2010-05-11 06:57:35 +08:00
|
|
|
@property CGRect bounds;
|
2010-05-16 07:05:52 +08:00
|
|
|
@property CGRect frame;
|
|
|
|
- (void)setFrame:(CGRect)frameRect;
|
|
|
|
- (CGRect)frame;
|
2010-05-11 06:57:35 +08:00
|
|
|
- (void) initWithOwner;
|
2012-11-14 07:16:33 +08:00
|
|
|
- (CGRect)extent;
|
2010-09-02 03:36:41 +08:00
|
|
|
- (void)dealloc;
|
2010-05-06 23:45:36 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation I
|
|
|
|
@synthesize position;
|
2010-05-11 06:57:35 +08:00
|
|
|
@synthesize bounds;
|
2010-05-16 07:05:52 +08:00
|
|
|
@synthesize frame;
|
2012-11-14 07:16:33 +08:00
|
|
|
|
|
|
|
// CHECK: define internal void @"\01-[I setPosition:]"
|
2014-07-18 23:52:10 +08:00
|
|
|
// CHECK: call dereferenceable({{[0-9]+}}) %class.S* @_ZN1SaSERKS_
|
2012-11-14 07:16:33 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
|
2014-10-15 00:43:46 +08:00
|
|
|
// Don't attach debug locations to the prologue instructions. These were
|
|
|
|
// leaking over from the previous function emission by accident.
|
2015-11-06 06:04:14 +08:00
|
|
|
// CHECK: define internal void @"\01-[I setBounds:]"({{.*}} {
|
2014-10-15 00:43:46 +08:00
|
|
|
// CHECK-NOT: !dbg
|
|
|
|
// CHECK: call void @llvm.dbg.declare
|
2010-05-16 07:05:52 +08:00
|
|
|
- (void)setFrame:(CGRect)frameRect {}
|
|
|
|
- (CGRect)frame {return bounds;}
|
|
|
|
|
2010-05-11 06:57:35 +08:00
|
|
|
- (void)initWithOwner {
|
2010-05-16 07:05:52 +08:00
|
|
|
I* _labelLayer;
|
2010-05-11 06:57:35 +08:00
|
|
|
CGRect labelLayerFrame = self.bounds;
|
|
|
|
labelLayerFrame = self.bounds;
|
2010-05-16 07:05:52 +08:00
|
|
|
_labelLayer.frame = labelLayerFrame;
|
2010-05-11 06:57:35 +08:00
|
|
|
}
|
2012-11-14 07:16:33 +08:00
|
|
|
|
2010-09-02 03:36:41 +08:00
|
|
|
// rdar://8366604
|
|
|
|
- (void)dealloc
|
|
|
|
{
|
|
|
|
CGRect cgrect = self.extent;
|
|
|
|
}
|
|
|
|
- (struct CGRect)extent {return bounds;}
|
2012-11-14 07:16:33 +08:00
|
|
|
|
2010-05-06 23:45:36 +08:00
|
|
|
@end
|
2010-05-08 02:56:13 +08:00
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define i32 @main
|
2014-07-18 23:52:10 +08:00
|
|
|
// CHECK: call void @_ZN1SC1ERKS_(%class.S* [[AGGTMP:%[a-zA-Z0-9\.]+]], %class.S* dereferenceable({{[0-9]+}}) {{%[a-zA-Z0-9\.]+}})
|
2012-11-14 07:16:33 +08:00
|
|
|
// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, %class.S*)*)(i8* {{%[a-zA-Z0-9\.]+}}, i8* {{%[a-zA-Z0-9\.]+}}, %class.S* [[AGGTMP]])
|
|
|
|
// CHECK-NEXT: ret i32 0
|
2010-05-08 02:56:13 +08:00
|
|
|
int main() {
|
|
|
|
I *i;
|
|
|
|
S s1;
|
|
|
|
i.position = s1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-09-10 07:01:10 +08:00
|
|
|
// rdar://8379892
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @_Z1fP1A
|
2012-11-14 07:16:33 +08:00
|
|
|
// CHECK: call void @_ZN1XC1Ev(%struct.X* [[LVTEMP:%[a-zA-Z0-9\.]+]])
|
2014-07-18 23:52:10 +08:00
|
|
|
// CHECK: call void @_ZN1XC1ERKS_(%struct.X* [[AGGTMP:%[a-zA-Z0-9\.]+]], %struct.X* dereferenceable({{[0-9]+}}) [[LVTEMP]])
|
2012-11-14 07:16:33 +08:00
|
|
|
// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, %struct.X*)*)({{.*}} %struct.X* [[AGGTMP]])
|
2010-09-10 07:01:10 +08:00
|
|
|
struct X {
|
|
|
|
X();
|
|
|
|
X(const X&);
|
|
|
|
~X();
|
|
|
|
};
|
|
|
|
|
|
|
|
@interface A {
|
|
|
|
X xval;
|
|
|
|
}
|
|
|
|
- (X)x;
|
|
|
|
- (void)setX:(X)x;
|
|
|
|
@end
|
|
|
|
|
|
|
|
void f(A* a) {
|
|
|
|
a.x = X();
|
|
|
|
}
|
When building a pseudo-object assignment, and the RHS is
a contextually-typed expression that semantic analysis will
probably need to invasively rewrite, don't include the
RHS OVE as a separate semantic expression, and check the
operation with the original RHS expression.
There are two contextually-typed expressions that can survive
to here: overloaded function references, which are at least
safe to double-emit, and C++11 initializer list expressions,
which are not at all safe to double-emit and which often
don't update the original syntactic InitListExpr with
implicit conversions to member types, etc.
This means that the original RHS may appear, undecorated by
an OVE, in the semantic expressions. Fortunately, it will
only ever be used in a single place there, and I don't
believe there are clients that rely on being able to pick
out the original RHS from the semantic expressions.
But this could be problematic if there are clients that do
visit the entire tree and rely on not seeing the same
expression multiple times, once in the syntactic and once
in the semantic expressions. This is a very fiddly part
of the compiler.
rdar://21801088
llvm-svn: 245771
2015-08-22 08:35:27 +08:00
|
|
|
|
|
|
|
// rdar://21801088
|
|
|
|
// Ensure that pseudo-objecet expressions that require the RHS to be
|
|
|
|
// rewritten don't result in crashes or redundant emission of code.
|
|
|
|
struct B0 { long long x; };
|
|
|
|
struct B1 { long long x; }; B1 operator+(B1, B1);
|
|
|
|
struct B2 { B1 x; };
|
|
|
|
struct B3 { B3(); B1 x; operator B1(); };
|
|
|
|
@interface B
|
|
|
|
@property B0 b0;
|
|
|
|
@property B1 b1;
|
|
|
|
@property B2 b2;
|
|
|
|
@property B3 b3;
|
|
|
|
@end
|
|
|
|
|
|
|
|
int b_makeInt();
|
|
|
|
|
|
|
|
// Note that there's a promotion from int to long long, so
|
|
|
|
// the syntactic form of the RHS will be bogus.
|
|
|
|
void testB0(B *b) {
|
|
|
|
b.b0 = { b_makeInt() };
|
|
|
|
}
|
|
|
|
void testB1(B *b) {
|
|
|
|
b.b1 += { b_makeInt() };
|
|
|
|
}
|
|
|
|
// CHECK: define void @_Z6testB0P1B([[B:%.*]]*
|
|
|
|
// CHECK: [[BVAR:%.*]] = alloca [[B]]*, align 8
|
|
|
|
// CHECK: [[TEMP:%.*]] = alloca [[B0:%.*]], align 8
|
|
|
|
// CHECK: load [[B]]*, [[B]]** [[BVAR]]
|
|
|
|
// CHECK-NEXT: [[X:%.*]] = getelementptr inbounds [[B0]], [[B0]]* [[TEMP]], i32 0, i32 0
|
|
|
|
// CHECK-NEXT: [[T0:%.*]] = call i32 @_Z9b_makeIntv()
|
|
|
|
// CHECK-NEXT: [[T1:%.*]] = sext i32 [[T0]] to i64
|
|
|
|
// CHECK-NEXT: store i64 [[T1]], i64* [[X]], align 8
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: call void @llvm.memcpy
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: call void bitcast {{.*}} @objc_msgSend
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: ret void
|
|
|
|
|
|
|
|
// CHECK: define void @_Z6testB1P1B([[B]]*
|
|
|
|
// CHECK: [[BVAR:%.*]] = alloca [[B]]*, align 8
|
|
|
|
// CHECK: load [[B]]*, [[B]]** [[BVAR]]
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: [[T0:%.*]] = call i64 bitcast {{.*}} @objc_msgSend
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: store i64 [[T0]],
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: [[T0:%.*]] = call i32 @_Z9b_makeIntv()
|
|
|
|
// CHECK-NEXT: [[T1:%.*]] = sext i32 [[T0]] to i64
|
|
|
|
// CHECK-NEXT: store i64 [[T1]], i64* {{.*}}, align 8
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: [[T0:%.*]] = call i64 @_Zpl2B1S_
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: store i64 [[T0]],
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: call void @llvm.memcpy
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: call void bitcast {{.*}} @objc_msgSend
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: ret void
|
|
|
|
|
|
|
|
// Another example of a conversion that needs to be applied
|
|
|
|
// in the semantic form.
|
|
|
|
void testB2(B *b) {
|
|
|
|
b.b2 = { B3() };
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: define void @_Z6testB2P1B([[B]]*
|
|
|
|
// CHECK: [[BVAR:%.*]] = alloca [[B]]*, align 8
|
|
|
|
// CHECK: load [[B]]*, [[B]]** [[BVAR]]
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: call void @_ZN2B3C1Ev(
|
|
|
|
// CHECK-NEXT: [[T0:%.*]] = call i64 @_ZN2B3cv2B1Ev(
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: store i64 [[T0]],
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: call void @llvm.memcpy
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: call void bitcast {{.*}} @objc_msgSend
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: ret void
|
|
|
|
|
|
|
|
// A similar test to B, but using overloaded function references.
|
|
|
|
struct C1 {
|
|
|
|
int x;
|
|
|
|
friend C1 operator+(C1, void(&)());
|
|
|
|
};
|
|
|
|
@interface C
|
|
|
|
@property void (*c0)();
|
|
|
|
@property C1 c1;
|
|
|
|
@end
|
|
|
|
|
|
|
|
void c_helper();
|
|
|
|
void c_helper(int);
|
|
|
|
|
|
|
|
void testC0(C *c) {
|
|
|
|
c.c0 = c_helper;
|
|
|
|
c.c0 = &c_helper;
|
|
|
|
}
|
|
|
|
// CHECK: define void @_Z6testC0P1C([[C:%.*]]*
|
|
|
|
// CHECK: [[CVAR:%.*]] = alloca [[C]]*, align 8
|
|
|
|
// CHECK: load [[C]]*, [[C]]** [[CVAR]]
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: call void bitcast {{.*}} @objc_msgSend {{.*}} @_Z8c_helperv
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: call void bitcast {{.*}} @objc_msgSend {{.*}} @_Z8c_helperv
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: ret void
|
|
|
|
|
|
|
|
void testC1(C *c) {
|
|
|
|
c.c1 += c_helper;
|
|
|
|
}
|
|
|
|
// CHECK: define void @_Z6testC1P1C([[C]]*
|
|
|
|
// CHECK: [[CVAR:%.*]] = alloca [[C]]*, align 8
|
|
|
|
// CHECK: load [[C]]*, [[C]]** [[CVAR]]
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: [[T0:%.*]] = call i32 bitcast {{.*}} @objc_msgSend
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: store i32 [[T0]],
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: [[T0:%.*]] = call i32 @_Zpl2C1RFvvE({{.*}} @_Z8c_helperv
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: store i32 [[T0]],
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: call void @llvm.memcpy
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: call void bitcast {{.*}} @objc_msgSend
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK: ret void
|