xref: /minix3/external/bsd/llvm/dist/clang/test/CoverageMapping/label.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name label.cpp %s | FileCheck %s
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc                              // CHECK: func
func()4*0a6a1f1dSLionel Sambuc void func() {                // CHECK-NEXT: File 0, [[@LINE]]:13 -> [[@LINE+18]]:2 = #0 (HasCodeBefore = 0)
5*0a6a1f1dSLionel Sambuc   int i = 0;                 // CHECK-NEXT: File 0, [[@LINE+2]]:14 -> [[@LINE+2]]:20 = (#0 + #3) (HasCodeBefore = 0)
6*0a6a1f1dSLionel Sambuc                              // CHECK-NEXT: File 0, [[@LINE+1]]:22 -> [[@LINE+1]]:25 = #3 (HasCodeBefore = 0)
7*0a6a1f1dSLionel Sambuc   for(i = 0; i < 10; ++i) {  // CHECK-NEXT: File 0, [[@LINE]]:27 -> [[@LINE+10]]:4 = #1 (HasCodeBefore = 0)
8*0a6a1f1dSLionel Sambuc     if(i < 5) {              // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+6]]:6 = #2 (HasCodeBefore = 0)
9*0a6a1f1dSLionel Sambuc       {
10*0a6a1f1dSLionel Sambuc         x:                   // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE+6]]:14 = #3 (HasCodeBefore = 0)
11*0a6a1f1dSLionel Sambuc           int j = 1;
12*0a6a1f1dSLionel Sambuc       }
13*0a6a1f1dSLionel Sambuc       int m = 2;
14*0a6a1f1dSLionel Sambuc     } else
15*0a6a1f1dSLionel Sambuc       goto x;                // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = (#1 - #2) (HasCodeBefore = 0)
16*0a6a1f1dSLionel Sambuc     int k = 3;
17*0a6a1f1dSLionel Sambuc   }
18*0a6a1f1dSLionel Sambuc   static int j = 0;          // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:12 = ((#0 + #3) - #1) (HasCodeBefore = 0)
19*0a6a1f1dSLionel Sambuc   ++j;
20*0a6a1f1dSLionel Sambuc   if(j == 1)
21*0a6a1f1dSLionel Sambuc     goto x;                  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:11 = #4 (HasCodeBefore = 0)
22*0a6a1f1dSLionel Sambuc }
23*0a6a1f1dSLionel Sambuc 
24*0a6a1f1dSLionel Sambuc                              // CHECK-NEXT: test1
test1(int x)25*0a6a1f1dSLionel Sambuc void test1(int x) {          // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE+7]]:2 = #0 (HasCodeBefore = 0)
26*0a6a1f1dSLionel Sambuc   if(x == 0)
27*0a6a1f1dSLionel Sambuc     goto a;                  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:11 = #1 (HasCodeBefore = 0)
28*0a6a1f1dSLionel Sambuc   goto b;                    // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:9 = (#0 - #1) (HasCodeBefore = 0)
29*0a6a1f1dSLionel Sambuc a:                           // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE]]:2 = #2 (HasCodeBefore = 0)
30*0a6a1f1dSLionel Sambuc b:                           // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE+1]]:12 = #3 (HasCodeBefore = 0)
31*0a6a1f1dSLionel Sambuc   x = x + 1;
32*0a6a1f1dSLionel Sambuc }
33*0a6a1f1dSLionel Sambuc 
34*0a6a1f1dSLionel Sambuc                              // CHECK-NEXT: test2
test2(int x)35*0a6a1f1dSLionel Sambuc void test2(int x) {          // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE+8]]:2 = #0 (HasCodeBefore = 0)
36*0a6a1f1dSLionel Sambuc   if(x == 0)
37*0a6a1f1dSLionel Sambuc     goto a;                  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:11 = #1 (HasCodeBefore = 0)
38*0a6a1f1dSLionel Sambuc                              // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> [[@LINE+1]]:17 = (#0 - #1) (HasCodeBefore = 0)
39*0a6a1f1dSLionel Sambuc   else if(x == 1) goto b;    // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE]]:25 = #2 (HasCodeBefore = 0)
40*0a6a1f1dSLionel Sambuc a:                           // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE]]:2 = #3 (HasCodeBefore = 0)
41*0a6a1f1dSLionel Sambuc b:                           // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE+1]]:12 = #4 (HasCodeBefore = 0)
42*0a6a1f1dSLionel Sambuc   x = x + 1;
43*0a6a1f1dSLionel Sambuc }
44*0a6a1f1dSLionel Sambuc 
45*0a6a1f1dSLionel Sambuc                              // CHECK-NEXT: main
main()46*0a6a1f1dSLionel Sambuc int main() {                 // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+17]]:2 = #0 (HasCodeBefore = 0)
47*0a6a1f1dSLionel Sambuc   int j = 0;
48*0a6a1f1dSLionel Sambuc   for(int i = 0; i < 10; ++i) { // CHECK: File 0, [[@LINE]]:31 -> [[@LINE+11]]:4 = #1 (HasCodeBefore = 0)
49*0a6a1f1dSLionel Sambuc   a:                         // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13 = #2 (HasCodeBefore = 0)
50*0a6a1f1dSLionel Sambuc     if(i < 3)
51*0a6a1f1dSLionel Sambuc       goto e;                // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #3 (HasCodeBefore = 0)
52*0a6a1f1dSLionel Sambuc     goto c;                  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:11 = (#2 - #3) (HasCodeBefore = 0)
53*0a6a1f1dSLionel Sambuc   b:                         // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #4 (HasCodeBefore = 0)
54*0a6a1f1dSLionel Sambuc     j = 2;
55*0a6a1f1dSLionel Sambuc   c:                         // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #5 (HasCodeBefore = 0)
56*0a6a1f1dSLionel Sambuc     j = 1;
57*0a6a1f1dSLionel Sambuc                              // CHECK-NEXT: File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:4 = #6 (HasCodeBefore = 0)
58*0a6a1f1dSLionel Sambuc   e: f: ;                    // CHECK-NEXT: File 0, [[@LINE]]:6 -> [[@LINE]]:10 = #7 (HasCodeBefore = 0)
59*0a6a1f1dSLionel Sambuc   }
60*0a6a1f1dSLionel Sambuc   func();                    // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:11 = ((#0 + #7) - #1) (HasCodeBefore = 0)
61*0a6a1f1dSLionel Sambuc   test1(0);
62*0a6a1f1dSLionel Sambuc   test2(2);
63*0a6a1f1dSLionel Sambuc }
64