| 1 |
// RUN: %clang_cc1 %s -triple arm64-apple-macosx -fsized-deallocation -faligned-allocation -emit-llvm -fcxx-exceptions -fexceptions -std=c++26 -o - | FileCheck %s |
| 2 |
// RUN: %clang_cc1 %s -triple arm64-apple-macosx -fno-sized-deallocation -faligned-allocation -emit-llvm -fcxx-exceptions -fexceptions -std=c++26 -o - | FileCheck %s |
| 3 |
// RUN: %clang_cc1 %s -triple arm64-apple-macosx -fno-sized-deallocation -fno-aligned-allocation -emit-llvm -fcxx-exceptions -fexceptions -std=c++26 -o - | FileCheck %s |
| 4 |
// RUN: %clang_cc1 %s -triple arm64-apple-macosx -fsized-deallocation -fno-aligned-allocation -emit-llvm -fcxx-exceptions -fexceptions -std=c++26 -o - | FileCheck %s |
| 5 |
// RUN: %clang_cc1 %s -triple arm64-apple-macosx -faligned-allocation -emit-llvm -fcxx-exceptions -fexceptions -std=c++26 -fexperimental-new-constant-interpreter -o - | FileCheck %s |
| 6 |
|
| 7 |
using size_t = __SIZE_TYPE__; |
| 8 |
|
| 9 |
namespace std { |
| 10 |
template <class T> struct type_identity { |
| 11 |
typedef T type; |
| 12 |
}; |
| 13 |
enum class align_val_t : size_t {}; |
| 14 |
} |
| 15 |
|
| 16 |
|
| 17 |
template <typename T> void *operator new(std::type_identity<T>, size_t, std::align_val_t); |
| 18 |
template <typename T> void operator delete(std::type_identity<T>, void *, size_t, std::align_val_t); |
| 19 |
struct S { |
| 20 |
int i = 0; |
| 21 |
constexpr S() __attribute__((noinline)) {} |
| 22 |
}; |
| 23 |
|
| 24 |
constexpr int doSomething() { |
| 25 |
S* s = new S; |
| 26 |
int result = s->i; |
| 27 |
delete s; |
| 28 |
return result; |
| 29 |
} |
| 30 |
|
| 31 |
static constexpr int force_doSomething = doSomething(); |
| 32 |
template <int N> struct Tag {}; |
| 33 |
|
| 34 |
void test1(Tag<force_doSomething>){ |
| 35 |
// CHECK-LABEL: define void @_Z5test13TagILi0EE |
| 36 |
} |
| 37 |
|
| 38 |
void test2(Tag<doSomething() + 1>){ |
| 39 |
// CHECK-LABEL: define void @_Z5test23TagILi1EE |
| 40 |
} |
| 41 |
|
| 42 |
int main() { |
| 43 |
// CHECK-LABEL: define noundef i32 @main() |
| 44 |
return doSomething(); |
| 45 |
// CHECK: call{{.*}}i32 @_Z11doSomethingv() |
| 46 |
} |
| 47 |
|
| 48 |
// CHECK-LABEL: define linkonce_odr noundef i32 @_Z11doSomethingv() |
| 49 |
// CHECK: [[ALLOC:%.*]] = call noundef ptr @_ZnwI1SEPvSt13type_identityIT_Em |
| 50 |
// CHECK: invoke noundef ptr @_ZN1SC1Ev(ptr{{.*}} [[ALLOC]]) |
| 51 |
// CHECK-NEXT: to label %[[CONT:.*]] unwind label %[[LPAD:[a-z0-9]+]] |
| 52 |
// CHECK: [[CONT]]: |
| 53 |
// CHECK: call void @_ZdlI1SEvSt13type_identityIT_EPv |
| 54 |
// CHECK: ret |
| 55 |
// CHECK: [[LPAD]]: |
| 56 |
// call void @_ZdlI1SEvSt13type_identityIT_EPvmSt11align_val_t({{.*}} [[ALLOC]]) |