[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCoroutines / coro-dealloc.cpp
blob1f7d04b3689eb5a352fba07c90b080017d2ea271
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
2 // RUN: -S -emit-llvm %s -o - -disable-llvm-passes \
3 // RUN: -fsized-deallocation \
4 // RUN: | FileCheck %s
6 #include "Inputs/coroutine.h"
8 namespace std {
9 typedef __SIZE_TYPE__ size_t;
10 enum class align_val_t : size_t {};
13 struct task {
14 struct promise_type {
15 auto initial_suspend() { return std::suspend_always{}; }
16 auto final_suspend() noexcept { return std::suspend_always{}; }
17 auto get_return_object() { return task{}; }
18 void unhandled_exception() {}
19 void return_value(int) {}
23 // Test the compiler will chose sized deallocation correctly.
24 // This is only enabled with `-fsized-deallocation` which is off by default.
25 void operator delete(void *ptr, std::size_t size) noexcept;
27 // CHECK: define{{.*}}@_Z1fv
28 // CHECK: %[[coro_free:.+]] = call{{.*}}@llvm.coro.free
29 // CHECK: coro.free:
30 // CHECK: %[[coro_size:.+]] = call{{.*}}@llvm.coro.size
31 // CHECK: call{{.*}}void @_ZdlPvm(ptr{{.*}}%[[coro_free]], i64{{.*}}%[[coro_size]])
33 task f() {
34 co_return 43;