|
1 | 1 | // RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -o - %s | FileCheck -check-prefixes=CHECK,NODEBUG,DARWIN %s
|
| 2 | +// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++17 -O1 -disable-llvm-passes -o - %s | FileCheck -check-prefixes=CHECK,NODEBUG,DARWIN,CXX17 %s |
2 | 3 | // RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -debug-info-kind=limited -o - %s | FileCheck -check-prefixes=CHECK,DARWIN %s
|
3 | 4 | // RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -stack-protector 1 -o - %s | FileCheck %s -check-prefix=STACK-PROT
|
4 | 5 | // RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -stack-protector 2 -o - %s | FileCheck %s -check-prefix=STACK-PROT
|
5 | 6 | // RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -stack-protector 3 -o - %s | FileCheck %s -check-prefix=STACK-PROT
|
6 | 7 |
|
7 | 8 | // RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -o - %s | FileCheck -check-prefixes=CHECK,NODEBUG,ELF %s
|
| 9 | +// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++17 -O1 -disable-llvm-passes -o - %s | FileCheck -check-prefixes=CHECK,NODEBUG,ELF,CXX17 %s |
8 | 10 | // RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -debug-info-kind=limited -o - %s | FileCheck -check-prefixes=CHECK,ELF %s
|
9 | 11 | // RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -stack-protector 1 -o - %s | FileCheck %s -check-prefix=STACK-PROT
|
10 | 12 | // RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -stack-protector 2 -o - %s | FileCheck %s -check-prefix=STACK-PROT
|
|
20 | 22 | // CHECK: @__const._Z13testArrayInitv.c0 = private unnamed_addr constant %struct.Class0 { { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base011nonvirtual0Ev, i32 0, i64 35591) to i64), i64 0 } }, align 8
|
21 | 23 | // CHECK: @__const._Z13testArrayInitv.c1 = private unnamed_addr constant %struct.Class0 { { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, i32 0, i64 35591) to i64), i64 0 } }, align 8
|
22 | 24 |
|
| 25 | +// CHECK: @_ZN22testNoexceptConversion6mfptr1E = global { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN22testNoexceptConversion1S19nonvirtual_noexceptEv, i32 0, i64 [[TYPEDISC3:.*]]) to i64), i64 0 }, |
| 26 | +// CHECK: @_ZN22testNoexceptConversion6mfptr2E = global { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN22testNoexceptConversion1S16virtual_noexceptEv_vfpthunk_, i32 0, i64 [[TYPEDISC3]]) to i64), i64 0 }, |
| 27 | +// CHECK: @_ZN22testNoexceptConversion15mfptr3_noexceptE = global { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN22testNoexceptConversion1S19nonvirtual_noexceptEv, i32 0, i64 [[TYPEDISC3]]) to i64), i64 0 }, |
| 28 | + |
23 | 29 | // CHECK: @_ZTV5Base0 = unnamed_addr constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTI5Base0,
|
24 | 30 | // CHECK-SAME: ptr ptrauth (ptr @_ZN5Base08virtual1Ev, i32 0, i64 55600, ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV5Base0, i32 0, i32 0, i32 2)),
|
25 | 31 | // CHECK-SAME: ptr ptrauth (ptr @_ZN5Base08virtual3Ev, i32 0, i64 53007, ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV5Base0, i32 0, i32 0, i32 3)),
|
@@ -77,6 +83,9 @@ struct Derived1 : Base0, Base1 {
|
77 | 83 | };
|
78 | 84 |
|
79 | 85 | typedef void (Base0::*MethodTy0)();
|
| 86 | +#if __cplusplus >= 201703L |
| 87 | +typedef void (Base0::*NoExceptMethodTy0)() noexcept; |
| 88 | +#endif |
80 | 89 | typedef void (Base0::*VariadicMethodTy0)(int, ...);
|
81 | 90 | typedef void (Derived0::*MethodTy1)();
|
82 | 91 |
|
@@ -293,6 +302,16 @@ void test1(Base0 *a0, MethodTy0 a1) {
|
293 | 302 | (a0->*a1)();
|
294 | 303 | }
|
295 | 304 |
|
| 305 | +// CXX17: define{{.*}} void @_Z14test1_noexceptP5Base0MS_DoFvvE( |
| 306 | +// CXX17: %[[V14:.*]] = phi ptr [ %{{.*}}, {{.*}} ], [ %{{.*}}, {{.*}} ] |
| 307 | +// CXX17: %[[V15:.*]] = phi i64 [ 0, {{.*}} ], [ [[TYPEDISC0]], {{.*}} ] |
| 308 | +// CXX17: call void %[[V14]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) {{.*}}[ "ptrauth"(i32 0, i64 %[[V15]]) ] |
| 309 | +#if __cplusplus >= 201703L |
| 310 | +void test1_noexcept(Base0 *a0, NoExceptMethodTy0 a1) { |
| 311 | + (a0->*a1)(); |
| 312 | +} |
| 313 | +#endif |
| 314 | + |
296 | 315 | // CHECK: define{{.*}} void @_Z15testConversion0M5Base0FvvEM8Derived0FvvE([2 x i64] %[[METHOD0_COERCE:.*]], [2 x i64] %[[METHOD1_COERCE:.*]])
|
297 | 316 | // CHECK: %[[METHOD0:.*]] = alloca { i64, i64 }, align 8
|
298 | 317 | // CHECK: %[[METHOD1:.*]] = alloca { i64, i64 }, align 8
|
@@ -438,3 +457,47 @@ void testArrayInit() {
|
438 | 457 | void testConvertNull() {
|
439 | 458 | VariadicMethodTy0 t = (VariadicMethodTy0)(MethodTy0{});
|
440 | 459 | }
|
| 460 | + |
| 461 | +namespace testNoexceptConversion { |
| 462 | + |
| 463 | +// CHECK-LABEL: define internal void @__cxx_global_var_init() |
| 464 | +// CHECK: %[[V0:.*]] = load { i64, i64 }, ptr @_ZN22testNoexceptConversion15mfptr0_noexceptE, align 8 |
| 465 | +// CHECK: store { i64, i64 } %[[V0]], ptr @_ZN22testNoexceptConversion6mfptr4E, align 8 |
| 466 | + |
| 467 | +// CHECK: define {{.*}}void @_ZN22testNoexceptConversion5test0Ev() |
| 468 | +// CHECK: %[[P0:.*]] = alloca { i64, i64 }, align 8 |
| 469 | +// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN22testNoexceptConversion1S19nonvirtual_noexceptEv, i32 0, i64 [[TYPEDISC3]]) to i64), i64 0 }, ptr %[[P0]], align 8, |
| 470 | + |
| 471 | +// CHECK: define {{.*}}void @_ZN22testNoexceptConversion5test1Ev() |
| 472 | +// CHECK: %[[P0:.*]] = alloca { i64, i64 }, align 8 |
| 473 | +// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN22testNoexceptConversion1S16virtual_noexceptEv_vfpthunk_, i32 0, i64 [[TYPEDISC3]]) to i64), i64 0 }, ptr %[[P0]], align 8, |
| 474 | + |
| 475 | +// CHECK: define {{.*}}void @_ZN22testNoexceptConversion5test2Ev() |
| 476 | +// CHECK: %[[P0:.*]] = alloca { i64, i64 }, align 8 |
| 477 | +// CHECK: %[[V0:.*]] = load { i64, i64 }, ptr @_ZN22testNoexceptConversion15mfptr0_noexceptE, align 8 |
| 478 | +// CHECK: store { i64, i64 } %[[V0]], ptr %[[P0]], align 8, |
| 479 | + |
| 480 | +struct S { |
| 481 | + void nonvirtual_noexcept() noexcept; |
| 482 | + virtual void virtual_noexcept() noexcept; |
| 483 | +}; |
| 484 | + |
| 485 | +void (S::*mfptr0_noexcept)() noexcept; |
| 486 | +void (S::*mfptr1)() = &S::nonvirtual_noexcept; |
| 487 | +void (S::*mfptr2)() = &S::virtual_noexcept; |
| 488 | +void (S::*mfptr3_noexcept)() noexcept = &S::nonvirtual_noexcept; |
| 489 | +void (S::*mfptr4)() = mfptr0_noexcept; |
| 490 | + |
| 491 | +void test0() { |
| 492 | + void (S::*p0)() = &S::nonvirtual_noexcept; |
| 493 | +} |
| 494 | + |
| 495 | +void test1() { |
| 496 | + void (S::*p0)() = &S::virtual_noexcept; |
| 497 | +} |
| 498 | + |
| 499 | +void test2() { |
| 500 | + void (S::*p0)() = mfptr0_noexcept; |
| 501 | +} |
| 502 | + |
| 503 | +} |
0 commit comments