[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGenCoroutines / coro-alloc-2.cpp
blob9c60c32a5c5440ddc0d6c354479e448c2f960f8c
1 // Tests that we wouldn't generate an allocation call in global scope with (std::size_t, p0, ..., pn)
2 // RUN: %clang_cc1 %s -std=c++20 -triple x86_64 -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s
3 #include "Inputs/coroutine.h"
5 namespace std {
6 typedef decltype(sizeof(int)) size_t;
9 struct Allocator {};
11 struct resumable {
12 struct promise_type {
14 resumable get_return_object() { return {}; }
15 auto initial_suspend() { return std::suspend_always(); }
16 auto final_suspend() noexcept { return std::suspend_always(); }
17 void unhandled_exception() {}
18 void return_void(){};
22 void *operator new(std::size_t, void *);
24 resumable f1(void *) {
25 co_return;
28 // CHECK: coro.alloc:
29 // CHECK-NEXT: [[SIZE:%.+]] = call [[BITWIDTH:.+]] @llvm.coro.size.[[BITWIDTH]]()
30 // CHECK-NEXT: call {{.*}} ptr @_Znwm([[BITWIDTH]] noundef [[SIZE]])