brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · d322bc3 Raw
67 lines · cpp
1// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple x86_64-unknown-linux-gnu -std=c++20 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s -o - | FileCheck %s2 3namespace std {4template <typename... T>5struct coroutine_traits;6 7template <class Promise = void>8struct coroutine_handle {9  coroutine_handle() = default;10  static coroutine_handle from_address(void *) noexcept { return {}; }11};12template <>13struct coroutine_handle<void> {14  static coroutine_handle from_address(void *) { return {}; }15  coroutine_handle() = default;16  template <class PromiseType>17  coroutine_handle(coroutine_handle<PromiseType>) noexcept {}18};19} // namespace std20 21struct suspend_always {22  bool await_ready() noexcept;23  void await_suspend(std::coroutine_handle<>) noexcept;24  void await_resume() noexcept;25};26 27template <>28struct std::coroutine_traits<int, int> {29  struct promise_type {30    int get_return_object();31    suspend_always initial_suspend();32    suspend_always final_suspend() noexcept;33    void unhandled_exception() noexcept;34    void return_value(int);35    suspend_always yield_value(int);36  };37};38 39// CHECK-LABEL: _Z2f1i:40int f1(int x) {       // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+8]]:2 = #041  if (x > 42) {       // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #042                      // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:7 -> [[@LINE-1]]:13 = #1, (#0 - #1)43    ++x;              // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:14 -> [[@LINE-2]]:15 = #144  } else {            // CHECK-NEXT: File 0, [[@LINE-3]]:15 -> [[@LINE]]:4 = #145    co_return x + 42; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE-1]]:10 = (#0 - #1)46  }                   // CHECK-NEXT: File 0, [[@LINE-2]]:10 -> [[@LINE]]:4 = (#0 - #1)47  co_return x;        // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 = #148} // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE-1]]:14 = #149 50// CHECK-LABEL: _Z2f2i:51// CHECK-NEXT: File 0, [[@LINE+1]]:15 -> [[@LINE+15]]:2 = #052int f2(int x) {53// CHECK-NEXT: File 0, [[@LINE+5]]:13 -> [[@LINE+5]]:18 = #054// CHECK-NEXT: Branch,File 0, [[@LINE+4]]:13 -> [[@LINE+4]]:18 = #1, (#0 - #1)55// CHECK-NEXT: Gap,File 0, [[@LINE+3]]:20 -> [[@LINE+3]]:21 = #156// CHECK-NEXT: File 0, [[@LINE+2]]:21 -> [[@LINE+2]]:37 = #157// CHECK-NEXT: File 0, [[@LINE+1]]:40 -> [[@LINE+1]]:56 = (#0 - #1)58  co_await (x > 0 ? suspend_always{} : suspend_always{});59// CHECK-NEXT: File 0, [[@LINE+5]]:12 -> [[@LINE+5]]:17 = #060// CHECK-NEXT: Branch,File 0, [[@LINE+4]]:12 -> [[@LINE+4]]:17 = #2, (#0 - #2)61// CHECK-NEXT: Gap,File 0, [[@LINE+3]]:19 -> [[@LINE+3]]:20 = #262// CHECK-NEXT: File 0, [[@LINE+2]]:20 -> [[@LINE+2]]:21 = #263// CHECK-NEXT: File 0, [[@LINE+1]]:24 -> [[@LINE+1]]:25 = (#0 - #2)64  co_yield x > 0 ? 1 : 2;65  co_return 0;66}67