1 // fixme: the following line is added to cleanup bots, will be removed in weeks. 2 // RUN: rm -f %S/coroutine.ll 3 // RUN: %strip_comments > %t.stripped.cpp 4 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %t.stripped.cpp -o - | FileCheck %s 5 6 namespace std::experimental { 7 template <typename... T> 8 struct coroutine_traits; 9 10 template <class Promise = void> 11 struct coroutine_handle { 12 coroutine_handle() = default; 13 static coroutine_handle from_address(void *) noexcept { return {}; } 14 }; 15 template <> 16 struct coroutine_handle<void> { 17 static coroutine_handle from_address(void *) { return {}; } 18 coroutine_handle() = default; 19 template <class PromiseType> 20 coroutine_handle(coroutine_handle<PromiseType>) noexcept {} 21 }; 22 } // namespace std::experimental 23 24 struct suspend_always { 25 bool await_ready() noexcept; 26 void await_suspend(std::experimental::coroutine_handle<>) noexcept; 27 void await_resume() noexcept; 28 }; 29 30 template <> 31 struct std::experimental::coroutine_traits<int, int> { 32 struct promise_type { 33 int get_return_object(); 34 suspend_always initial_suspend(); 35 suspend_always final_suspend() noexcept; 36 void return_value(int); 37 }; 38 }; 39 40 // CHECK-LABEL: _Z2f1i: 41 int f1(int x) { // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+7]]:2 = #0 42 if (x > 42) { // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0 43 ++x; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE-1]]:15 = #1 44 } else { // CHECK-NEXT: File 0, [[@LINE-2]]:15 -> [[@LINE]]:4 = #1 45 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 = #1 48 } // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE]]:2 = #1 49