xref: /llvm-project/clang/test/CoverageMapping/templates.cpp (revision 6be1a1535ef4ea30f301586e4960bebbfccfe851)
1 // RUN: %clang_cc1 -std=c++20 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name templates.cpp %s | FileCheck %s
2 
3 template<typename T>
unused(T x)4 void unused(T x) {
5   return;
6 }
7 
8 template<typename T>
func(T x)9 int func(T x) {  // CHECK: func
10   if(x)          // CHECK: func
11     return 0;
12   else
13     return 1;
14   int j = 1;
15 }
16 
main()17 int main() {
18   func<int>(0);
19   func<bool>(true);
20   return 0;
21 }
22 
23 namespace structural_value_crash {
24   template <int* p>
tpl_fn()25   void tpl_fn() {
26     (void)p;
27   }
28 
29   int arr[] = {1, 2, 3};
30 
test()31   void test() {
32     tpl_fn<arr>();
33     tpl_fn<&arr[1]>();
34   }
35 }
36