11// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -mllvm -enable-single-byte-coverage=true -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name single-byte-counters.cpp %s | FileCheck %s
22
33// CHECK: testIf
4- int testIf (int x) { // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE+7 ]]:2 = [[C00:#0]]
4+ int testIf (int x) { // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE+8 ]]:2 = [[C00:#0]]
55 int result = 0 ;
66 if (x == 0 ) // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = [[C00]]
7- // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE+1]]:5 = [[C0T:#1]]
7+
8+ // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:14 -> [[@LINE+1]]:5 = [[C0T:#1]]
89 result = -1 ; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:16 = [[C0T]]
910
1011 return result; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:16 = [[C0E:#2]]
1112}
1213
1314// CHECK-NEXT: testIfElse
14- int testIfElse (int x) { // CHECK-NEXT: File 0, [[@LINE]]:23 -> [[@LINE+8 ]]:2 = [[C10:#0]]
15+ int testIfElse (int x) { // CHECK-NEXT: File 0, [[@LINE]]:23 -> [[@LINE+9 ]]:2 = [[C10:#0]]
1516 int result = 0 ;
1617 if (x < 0 ) // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:12 = [[C10]]
17- // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:13 -> [[@LINE+1]]:5 = [[C1T:#1]]
18+
19+ // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:13 -> [[@LINE+1]]:5 = [[C1T:#1]]
1820 result = 0 ; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:15 = [[C1T]]
1921 else // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:16 -> [[@LINE+1]]:5 = [[C1F:#2]]
2022 result = x * x; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:19 = [[C1F]]
2123 return result; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:16 = [[C1E:#3]]
2224}
2325
2426// CHECK-NEXT: testIfElseReturn
25- int testIfElseReturn (int x) { // CHECK-NEXT: File 0, [[@LINE]]:29 -> [[@LINE+9 ]]:2 = [[C20:#0]]
27+ int testIfElseReturn (int x) { // CHECK-NEXT: File 0, [[@LINE]]:29 -> [[@LINE+10 ]]:2 = [[C20:#0]]
2628 int result = 0 ;
2729 if (x > 0 ) // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:12 = [[C20]]
28- // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:13 -> [[@LINE+1]]:5 = [[C2T:#1]]
30+
31+ // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:13 -> [[@LINE+1]]:5 = [[C2T:#1]]
2932 result = x * x; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:19 = [[C2T]]
3033 else // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:20 -> [[@LINE+1]]:5 = [[C2F:#2]]
3134 return 0 ; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:13 = [[C2F]]
@@ -34,10 +37,11 @@ int testIfElseReturn(int x) { // CHECK-NEXT: File 0, [[@LINE]]:29 -> [[@LINE+9]]
3437}
3538
3639// CHECK-NEXT: testIfBothReturn
37- int testIfBothReturn (int x) { // CHECK-NEXT: File 0, [[@LINE]]:29 -> [[@LINE+9 ]]:2 = [[C20:#0]]
40+ int testIfBothReturn (int x) { // CHECK-NEXT: File 0, [[@LINE]]:29 -> [[@LINE+10 ]]:2 = [[C20:#0]]
3841 int result = 0 ;
3942 if (x > 0 ) // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:12 = [[C20]]
40- // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:13 -> [[@LINE+1]]:5 = [[C2T:#1]]
43+
44+ // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:13 -> [[@LINE+1]]:5 = [[C2T:#1]]
4145 return 42 ; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:14 = [[C2T]]
4246 else // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:15 -> [[@LINE+1]]:5 = [[C2F:#2]]
4347 return 0 ; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:13 = [[C2F]]
@@ -46,32 +50,36 @@ int testIfBothReturn(int x) { // CHECK-NEXT: File 0, [[@LINE]]:29 -> [[@LINE+9]]
4650}
4751
4852// CHECK-NEXT: testSwitch
49- int testSwitch (int x) { // CHECK-NEXT: File 0, [[@LINE]]:23 -> [[@LINE+17 ]]:2 = [[C30:#0]]
53+ int testSwitch (int x) { // CHECK-NEXT: File 0, [[@LINE]]:23 -> [[@LINE+20 ]]:2 = [[C30:#0]]
5054 int result;
5155 switch (x) {
52- // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE+10]]:15 = 0
53- case 1 : // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = [[C31:#2]]
56+ // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE+13]]:15 = 0
57+ case 1 : // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = [[C31:#2]]
58+
5459 result = 1 ;
5560 break ;
5661 // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:11 -> [[@LINE+1]]:3 = 0
57- case 2 : // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = [[C32:#3]]
62+ case 2 : // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = [[C32:#3]]
63+
5864 result = 2 ;
5965 break ;
6066 // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:11 -> [[@LINE+1]]:3 = 0
61- default : // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:15 = [[C3D:#4]]
67+ default : // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:15 = [[C3D:#4]]
68+
6269 result = 0 ;
6370 }
6471 // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE+1]]:3 = [[C3E:#1]]
6572 return result; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:16 = [[C3E]]
6673}
6774
6875// CHECK-NEXT: testWhile
69- int testWhile () { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+11 ]]:2 = [[C40:#0]]
76+ int testWhile () { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+12 ]]:2 = [[C40:#0]]
7077 int i = 0 ;
7178 int sum = 0 ;
7279 while (i < 10 ) { // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE]]:16 = [[C4C:#1]]
73- // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:17 -> [[@LINE-1]]:18 = [[C4T:#2]]
74- // CHECK-NEXT: File 0, [[@LINE-2]]:18 -> [[@LINE+3]]:4 = [[C4T]]
80+
81+ // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:17 -> [[@LINE-2]]:18 = [[C4T:#2]]
82+ // CHECK-NEXT: File 0, [[@LINE-3]]:18 -> [[@LINE+3]]:4 = [[C4T]]
7583 sum += i;
7684 i++;
7785 }
@@ -80,19 +88,22 @@ int testWhile() { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+11]]:2 =
8088}
8189
8290// CHECK-NEXT: testContinueBreak
83- int testContinueBreak () { // CHECK-NEXT: File 0, [[@LINE]]:25 -> [[@LINE+20 ]]:2 = #0
91+ int testContinueBreak () { // CHECK-NEXT: File 0, [[@LINE]]:25 -> [[@LINE+23 ]]:2 = #0
8492 int i = 0 ;
8593 int sum = 0 ;
8694 while (i < 10 ) { // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE]]:16 = #1
87- // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:17 -> [[@LINE-1]]:18 = [[C5B:#2]]
88- // CHECK-NEXT: File 0, [[@LINE-2]]:18 -> [[@LINE+12]]:4 = [[C5B]]
95+
96+ // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:17 -> [[@LINE-2]]:18 = [[C5B:#2]]
97+ // CHECK-NEXT: File 0, [[@LINE-3]]:18 -> [[@LINE+14]]:4 = [[C5B]]
8998 if (i == 4 ) // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:15 = [[C5B]]
90- // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:16 -> [[@LINE+1]]:7 = [[C5T:#4]]
99+
100+ // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:16 -> [[@LINE+1]]:7 = [[C5T:#4]]
91101 continue ; // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:15 = [[C5T]]
92102 // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:16 -> [[@LINE+2]]:5 = [[C5F:#5]]
93- // CHECK-NEXT: File 0, [[@LINE+1]]:5 -> [[@LINE+7 ]]:4 = [[C5F]]
103+ // CHECK-NEXT: File 0, [[@LINE+1]]:5 -> [[@LINE+8 ]]:4 = [[C5F]]
94104 if (i == 5 ) // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:15 = [[C5F]]
95- // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:16 -> [[@LINE+1]]:7 = [[C5T1:#6]]
105+
106+ // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:16 -> [[@LINE+1]]:7 = [[C5T1:#6]]
96107 break ; // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:12 = [[C5T1]]
97108 // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:13 -> [[@LINE+1]]:5 = [[C5F1:#7]]
98109 sum += i; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+2]]:4 = [[C5F1]]
@@ -103,10 +114,11 @@ int testContinueBreak() { // CHECK-NEXT: File 0, [[@LINE]]:25 -> [[@LINE+20]]:2
103114}
104115
105116// CHECK-NEXT: testFor
106- int testFor () { // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+12 ]]:2 = [[C60:#0]]
117+ int testFor () { // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+13 ]]:2 = [[C60:#0]]
107118 int i;
108119 int sum = 0 ;
109- // CHECK-NEXT: File 0, [[@LINE+2]]:19 -> [[@LINE+2]]:25 = [[C61:#1]]
120+ // CHECK-NEXT: File 0, [[@LINE+3]]:19 -> [[@LINE+3]]:25 = [[C61:#1]]
121+
110122 // CHECK-NEXT: File 0, [[@LINE+1]]:27 -> [[@LINE+1]]:30 = [[C6C:#2]]
111123 for (int i = 0 ; i < 10 ; i++) {
112124 // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:31 -> [[@LINE-1]]:32 = [[C6B:#3]]
@@ -144,10 +156,11 @@ int testDo() { // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+9]]:2 = [
144156}
145157
146158// CHECK-NEXT: testConditional
147- int testConditional (int x) { // CHECK-NEXT: File 0, [[@LINE]]:28 -> [[@LINE+6 ]]:2 = [[C90:#0]]
159+ int testConditional (int x) { // CHECK-NEXT: File 0, [[@LINE]]:28 -> [[@LINE+7 ]]:2 = [[C90:#0]]
148160 int result = (x > 0 ) ? 1 : -1 ; // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE]]:22 = [[C90]]
149- // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:24 -> [[@LINE-1]]:25 = [[C9T:#2]]
150- // CHECK-NEXT: File 0, [[@LINE-2]]:25 -> [[@LINE-2]]:26 = [[C9T]]
151- // CHECK-NEXT: File 0, [[@LINE-3]]:29 -> [[@LINE-3]]:31 = [[C9F:#3]]
161+
162+ // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:24 -> [[@LINE-2]]:25 = [[C9T:#2]]
163+ // CHECK-NEXT: File 0, [[@LINE-3]]:25 -> [[@LINE-3]]:26 = [[C9T]]
164+ // CHECK-NEXT: File 0, [[@LINE-4]]:29 -> [[@LINE-4]]:31 = [[C9F:#3]]
152165 return result; // CHECK-NEXT: File 0, [[@LINE]]:2 -> [[@LINE]]:15 = [[C9E:#1]]
153166}
0 commit comments