xref: /llvm-project/clang/test/CodeGenObjCXX/property-dot-reference.mm (revision 12f78e740c5419f7d1fbcf8f2106e7a40cd1d6f7)
1// RUN: %clang_cc1 -Wno-error=return-type -triple x86_64-apple-darwin10 -emit-llvm -fexceptions -o - %s | FileCheck %s
2
3struct TFENode {
4void GetURL() const;
5};
6
7@interface TNodeIconAndNameCell
8- (const TFENode&) node;
9@end
10
11@implementation TNodeIconAndNameCell
12- (const TFENode&) node {
13// CHECK: call noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @objc_msgSend
14// CHECK-NEXT: call void @_ZNK7TFENode6GetURLEv(ptr {{[^,]*}} %{{.*}})
15	self.node.GetURL();
16}	// expected-warning {{non-void function does not return a value}}
17@end
18
19struct X {
20  int x;
21};
22
23void f0(const X &parent);
24@interface A
25- (const X&) target;
26@end
27void f1(A *a) {
28// CHECK: [[PRP:%.*]] = call noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @objc_msgSend
29// CHECK-NEXT:call void @_Z2f0RK1X(ptr noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[PRP]])
30  f0(a.target);
31
32// CHECK: [[MSG:%.*]] = call noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @objc_msgSend
33// CHECK-NEXT:call void @_Z2f0RK1X(ptr noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[MSG]])
34  f0([a target]);
35}
36
37@interface Test2
38@property (readonly) int myProperty;
39- (int) myProperty;
40- (double) myGetter;
41@end
42void test2() {
43    Test2 *obj;
44    (void) obj.myProperty;
45    (void) obj.myGetter;
46    static_cast<void>(obj.myProperty);
47    static_cast<void>(obj.myGetter);
48    void(obj.myProperty);
49    void(obj.myGetter);
50}
51// CHECK-LABEL: define{{.*}} void @_Z5test2v()
52// CHECK: call noundef i32
53// CHECK: call noundef double
54// CHECK: call noundef i32
55// CHECK: call noundef double
56// CHECK: call noundef i32
57// CHECK: call noundef double
58
59// PR8751
60int test3(Test2 *obj) { return obj.myProperty; }
61