19caa3fbeSZequan Wu // RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s -o - | FileCheck %s
2565e37c7SXun Li 
3ec117158SChuanqi Xu namespace std {
4565e37c7SXun Li template <typename... T>
5565e37c7SXun Li struct coroutine_traits;
6565e37c7SXun Li 
7565e37c7SXun Li template <class Promise = void>
8565e37c7SXun Li struct coroutine_handle {
9565e37c7SXun Li   coroutine_handle() = default;
from_addressstd::coroutine_handle10565e37c7SXun Li   static coroutine_handle from_address(void *) noexcept { return {}; }
11565e37c7SXun Li };
12565e37c7SXun Li template <>
13565e37c7SXun Li struct coroutine_handle<void> {
from_addressstd::coroutine_handle14565e37c7SXun Li   static coroutine_handle from_address(void *) { return {}; }
15565e37c7SXun Li   coroutine_handle() = default;
16565e37c7SXun Li   template <class PromiseType>
coroutine_handlestd::coroutine_handle17565e37c7SXun Li   coroutine_handle(coroutine_handle<PromiseType>) noexcept {}
18565e37c7SXun Li };
19ec117158SChuanqi Xu } // namespace std
20565e37c7SXun Li 
21565e37c7SXun Li struct suspend_always {
22565e37c7SXun Li   bool await_ready() noexcept;
23ec117158SChuanqi Xu   void await_suspend(std::coroutine_handle<>) noexcept;
24565e37c7SXun Li   void await_resume() noexcept;
25565e37c7SXun Li };
26565e37c7SXun Li 
27565e37c7SXun Li template <>
28ec117158SChuanqi Xu struct std::coroutine_traits<int, int> {
29565e37c7SXun Li   struct promise_type {
30565e37c7SXun Li     int get_return_object();
31565e37c7SXun Li     suspend_always initial_suspend();
32565e37c7SXun Li     suspend_always final_suspend() noexcept;
33*80bebbc7SNathan Sidwell     void unhandled_exception() noexcept;
34565e37c7SXun Li     void return_value(int);
35565e37c7SXun Li   };
36565e37c7SXun Li };
37565e37c7SXun Li 
38565e37c7SXun Li // CHECK-LABEL: _Z2f1i:
f1(int x)399f2967bcSAlan Phipps int f1(int x) {       // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+8]]:2 = #0
40565e37c7SXun Li   if (x > 42) {       // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0
419f2967bcSAlan Phipps                       // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:7 -> [[@LINE-1]]:13 = #1, (#0 - #1)
429f2967bcSAlan Phipps     ++x;              // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:14 -> [[@LINE-2]]:15 = #1
439f2967bcSAlan Phipps   } else {            // CHECK-NEXT: File 0, [[@LINE-3]]:15 -> [[@LINE]]:4 = #1
44565e37c7SXun Li     co_return x + 42; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE-1]]:10 = (#0 - #1)
45565e37c7SXun Li   }                   // CHECK-NEXT: File 0, [[@LINE-2]]:10 -> [[@LINE]]:4 = (#0 - #1)
46565e37c7SXun Li   co_return x;        // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 = #1
479783e209SZequan Wu } // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE-1]]:14 = #1
48