xref: /minix3/external/bsd/llvm/dist/clang/test/CoverageMapping/test.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name test.c %s | FileCheck %s
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc void bar();
4*0a6a1f1dSLionel Sambuc static void static_func();
5*0a6a1f1dSLionel Sambuc 
6*0a6a1f1dSLionel Sambuc                                  // CHECK: main
main()7*0a6a1f1dSLionel Sambuc int main() {                     // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+7]]:2 = #0 (HasCodeBefore = 0)
8*0a6a1f1dSLionel Sambuc                                  // CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:24 = (#0 + #1) (HasCodeBefore = 0)
9*0a6a1f1dSLionel Sambuc   for(int i = 0; i < 10; ++i) {  // CHECK-NEXT: File 0, [[@LINE]]:26 -> [[@LINE]]:29 = #1 (HasCodeBefore = 0)
10*0a6a1f1dSLionel Sambuc     bar();                       // CHECK-NEXT: File 0, [[@LINE-1]]:31 -> [[@LINE+1]]:4 = #1 (HasCodeBefore = 0)
11*0a6a1f1dSLionel Sambuc   }
12*0a6a1f1dSLionel Sambuc   static_func();
13*0a6a1f1dSLionel Sambuc   return 0;
14*0a6a1f1dSLionel Sambuc }
15*0a6a1f1dSLionel Sambuc 
16*0a6a1f1dSLionel Sambuc                                  // CHECK-NEXT: foo
foo()17*0a6a1f1dSLionel Sambuc void foo() {                     // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+4]]:2 = #0 (HasCodeBefore = 0)
18*0a6a1f1dSLionel Sambuc   if(1) {                        // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE+2]]:4 = #1 (HasCodeBefore = 0)
19*0a6a1f1dSLionel Sambuc     int i = 0;
20*0a6a1f1dSLionel Sambuc   }
21*0a6a1f1dSLionel Sambuc }
22*0a6a1f1dSLionel Sambuc 
23*0a6a1f1dSLionel Sambuc                                  // CHECK-NEXT: bar
bar()24*0a6a1f1dSLionel Sambuc void bar() {                     // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+1]]:2 = #0 (HasCodeBefore = 0)
25*0a6a1f1dSLionel Sambuc }
26*0a6a1f1dSLionel Sambuc 
27*0a6a1f1dSLionel Sambuc                                  // CHECK-NEXT: static_func
static_func()28*0a6a1f1dSLionel Sambuc void static_func() { }           // CHECK: File 0, [[@LINE]]:20 -> [[@LINE]]:23 = #0 (HasCodeBefore = 0)
29*0a6a1f1dSLionel Sambuc 
30*0a6a1f1dSLionel Sambuc                                  // CHECK-NEXT: func
func()31*0a6a1f1dSLionel Sambuc static void func() { }           // CHECK: File 0, [[@LINE]]:20 -> [[@LINE]]:23 = 0 (HasCodeBefore = 0)
32