1
- // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-linux-gnu %s -fclangir -emit-cir -o %t.cir
1
+ // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu %s -fclangir -emit-cir -o %t.cir
2
2
// RUN: FileCheck --input-file=%t.cir -check-prefix=CIR %s
3
- // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-linux-gnu %s -fclangir -emit-llvm -o %t.ll
3
+ // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu %s -fclangir -emit-llvm -o %t.ll
4
4
// RUN: FileCheck --input-file=%t.ll -check-prefix=LLVM %s
5
5
6
6
// TODO: This file is inspired by clang/test/CodeGenCXX/new.cpp, add all tests from it.
@@ -16,6 +16,8 @@ void *operator new[](size_t);
16
16
17
17
namespace std {
18
18
struct nothrow_t {};
19
+ enum class align_val_t : size_t { __zero = 0 ,
20
+ __max = (size_t )-1 };
19
21
}
20
22
std::nothrow_t nothrow;
21
23
@@ -76,4 +78,45 @@ namespace test15 {
76
78
void test0b (void *p) {
77
79
new (p, true ) A ();
78
80
}
79
- }
81
+ }
82
+
83
+ extern " C" void test_basic () {
84
+ __builtin_operator_delete (__builtin_operator_new (4 ));
85
+ // CIR-LABEL: cir.func @test_basic
86
+ // CIR: [[P:%.*]] = cir.call @_Znwm({{%.*}}) : (!u64i) -> !cir.ptr<!void>
87
+ // CIR: cir.call @_ZdlPv([[P]]) : (!cir.ptr<!void>) -> ()
88
+ // CIR: cir.return
89
+
90
+ // LLVM-LABEL: define{{.*}} void @test_basic()
91
+ // LLVM: [[P:%.*]] = call ptr @_Znwm(i64 4)
92
+ // LLVM: call void @_ZdlPv(ptr [[P]])
93
+ // LLVM: ret void
94
+ }
95
+
96
+ extern " C" void test_aligned_alloc () {
97
+ __builtin_operator_delete (__builtin_operator_new (4 , std::align_val_t (4 )), std::align_val_t (4 ));
98
+
99
+ // CIR-LABEL: cir.func @test_aligned_alloc
100
+ // CIR: [[P:%.*]] = cir.call @_ZnwmSt11align_val_t({{%.*}}, {{%.*}}) : (!u64i, !u64i) -> !cir.ptr<!void>
101
+ // CIR: cir.call @_ZdlPvSt11align_val_t([[P]], {{%.*}}) : (!cir.ptr<!void>, !u64i) -> ()
102
+ // CIR: cir.return
103
+
104
+ // LLVM-LABEL: define{{.*}} void @test_aligned_alloc()
105
+ // LLVM: [[P:%.*]] = call ptr @_ZnwmSt11align_val_t(i64 4, i64 4)
106
+ // LLVM: call void @_ZdlPvSt11align_val_t(ptr [[P]], i64 4)
107
+ // LLVM: ret void
108
+ }
109
+
110
+ extern " C" void test_sized_delete () {
111
+ __builtin_operator_delete (__builtin_operator_new (4 ), 4 );
112
+
113
+ // CIR-LABEL: cir.func @test_sized_delete
114
+ // CIR: [[P:%.*]] = cir.call @_Znwm({{%.*}}) : (!u64i) -> !cir.ptr<!void>
115
+ // CIR: cir.call @_ZdlPvm([[P]], {{%.*}}) : (!cir.ptr<!void>, !u64i) -> ()
116
+ // CIR: cir.return
117
+
118
+ // LLVM-LABEL: define{{.*}} void @test_sized_delete()
119
+ // LLVM: [[P:%.*]] = call ptr @_Znwm(i64 4)
120
+ // LLVM: call void @_ZdlPvm(ptr [[P]], i64 4)
121
+ // LLVM: ret void
122
+ }
0 commit comments