blob: 21e784e0031de33d52357982086907514039fcf3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Test for PR59181. Tests that no conditional cleanup is created around await_suspend.
//
// REQUIRES: x86-registered-target
//
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - -std=c++20 -disable-llvm-passes -fsanitize-address-use-after-scope | FileCheck %s
#include "Inputs/coroutine.h"
struct Task {
int value_;
struct promise_type {
Task get_return_object() {
return Task{0};
}
std::suspend_never initial_suspend() noexcept {
return {};
}
std::suspend_never final_suspend() noexcept {
return {};
}
void return_value(Task t) noexcept {}
void unhandled_exception() noexcept {}
auto await_transform(Task t) {
struct Suspension {
auto await_ready() noexcept { return false;}
auto await_suspend(std::coroutine_handle<> coro) {
coro.destroy();
}
auto await_resume() noexcept {
return 0;
}
};
return Suspension{};
}
};
};
Task bar(bool cond) {
co_return cond ? Task{ co_await Task{}}: Task{};
}
void foo() {
bar(true);
}
// CHECK: cleanup.cont:{{.*}}
// CHECK-NEXT: load i8
// CHECK-NEXT: trunc
// CHECK-NEXT: store i1 false
// CHECK: await.suspend:{{.*}}
// CHECK-NOT: call void @llvm.lifetime
// CHECK: call void @llvm.coro.await.suspend.void(
// CHECK-NEXT: %{{[0-9]+}} = call i8 @llvm.coro.suspend(
|