| 1 |
// RUN: %clang_cc1 %s -triple arm64-apple-macosx -emit-llvm -fcxx-exceptions -fexceptions -std=c++23 -o - | FileCheck %s |
| 2 |
|
| 3 |
class TestClass { |
| 4 |
public: |
| 5 |
TestClass(); |
| 6 |
int field = 0; |
| 7 |
friend class Foo; |
| 8 |
static void * operator new(unsigned long size); |
| 9 |
private: |
| 10 |
static void operator delete(void *p); |
| 11 |
}; |
| 12 |
|
| 13 |
class Foo { |
| 14 |
public: |
| 15 |
int test_method(); |
| 16 |
}; |
| 17 |
|
| 18 |
int Foo::test_method() { |
| 19 |
TestClass *obj = new TestClass() ; |
| 20 |
return obj->field; |
| 21 |
} |
| 22 |
|
| 23 |
// CHECK-LABEL: define noundef i32 @_ZN3Foo11test_methodEv |
| 24 |
// CHECK: [[THIS_ADDR:%.*]] = alloca ptr, align 8 |
| 25 |
// CHECK: [[OBJ:%.*]] = alloca ptr, align 8 |
| 26 |
// CHECK: store ptr %this, ptr [[THIS_ADDR]], align 8 |
| 27 |
// CHECK: [[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8 |
| 28 |
// CHECK: [[ALLOCATION:%.*]] = call noundef ptr @_ZN9TestClassnwEm(i64 noundef 4) |
| 29 |
// CHECK: [[INITIALIZEDOBJ:%.*]] = invoke noundef ptr @_ZN9TestClassC1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[ALLOCATION]]) |
| 30 |
// CHECK-NEXT: to label %[[INVOKE_CONT:.*]] unwind label %[[LPAD:.*]] |
| 31 |
// CHECK: [[INVOKE_CONT]]: |
| 32 |
// CHECK: store ptr [[ALLOCATION]], ptr [[OBJ]], align 8 |
| 33 |
// CHECK: [[OBJPTR:%.*]] = load ptr, ptr [[OBJ]], align 8 |
| 34 |
// CHECK: [[FIELDPTR:%.*]] = getelementptr inbounds nuw %class.TestClass, ptr [[OBJPTR]], i32 0, i32 0 |
| 35 |
// CHECK: [[FIELD:%.*]] = load i32, ptr [[FIELDPTR]], align 4 |
| 36 |
// CHECK: ret i32 [[FIELD]] |
| 37 |
// CHECK: [[LPAD]]: |
| 38 |
// CHECK: call void @_ZN9TestClassdlEPv(ptr noundef [[ALLOCATION]]) #3 |