deferred-region.cpp
2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// RUN: llvm-cov show %S/Inputs/deferred-regions.covmapping -instr-profile %S/Inputs/deferred-regions.profdata -show-line-counts-or-regions -dump -path-equivalence=/tmp,%S %s 2>%t.markers > %t.out && FileCheck %s -input-file %t.out && FileCheck %s -input-file %t.markers -check-prefix=MARKER
void foo(int x) {
if (x == 0) { // CHECK: [[@LINE]]|{{ +}}2|
return; // CHECK-NEXT: [[@LINE]]|{{ +}}1|
}
} // CHECK: [[@LINE]]|{{ +}}1|
void bar() {
return;
} // CHECK: [[@LINE]]|{{ +}}1|
void for_loop() {
if (false)
return; // CHECK: [[@LINE]]|{{ +}}0|
for (int i = 0; i < 10; ++i) { // CHECK: [[@LINE]]|{{ +}}2|
if (i % 2 == 0) // CHECK: [[@LINE]]|{{ +}}2|
continue; // CHECK: [[@LINE]]|{{ +}}1|
if (i % 5 == 0) // CHECK: [[@LINE]]|{{ +}}1|
break; // CHECK: [[@LINE]]|{{ +}}0|
int x = i;
return; // CHECK: [[@LINE]]|{{ +}}1|
} // CHECK: [[@LINE]]|{{ +}}1|
}
struct Error {};
void while_loop() {
if (false)
return; // CHECK: [[@LINE]]|{{ +}}0|
int x = 0;
while (++x < 10) { // CHECK: [[@LINE]]|{{ +}}3|
if (x == 1) // CHECK: [[@LINE]]|{{ +}}2|
continue; // CHECK: [[@LINE]]|{{ +}}1|
while (++x < 4) { // CHECK: [[@LINE]]|{{ +}}1|
if (x == 3) // CHECK: [[@LINE]]|{{ +}}1|
break; // CHECK: [[@LINE]]|{{ +}}1|
// CHECK: [[@LINE]]|{{ +}}0|
while (++x < 5) {} // CHECK: [[@LINE]]|{{ +}}0|
} // CHECK: [[@LINE]]|{{ +}}0|
if (x == 0) // CHECK: [[@LINE]]|{{ +}}1|
throw Error(); // CHECK: [[@LINE]]|{{ +}}0|
// CHECK: [[@LINE]]|{{ +}}1|
while (++x < 9) { // CHECK: [[@LINE]]|{{ +}}6|
if (x == 0) // CHECK: [[@LINE]]|{{ +}}5|
break; // CHECK: [[@LINE]]|{{ +}}0|
}
}
}
void gotos() {
if (false) // CHECK: [[@LINE]]|{{ +}}1|
goto out; // CHECK: [[@LINE]]|{{ +}}0|
// CHECK: [[@LINE]]|{{ +}}1|
return; // CHECK: [[@LINE]]|{{ +}}1|
out: // CHECK: [[@LINE]]|{{ +}}0|
return;
}
void if_else(bool flag) {
if (flag) { // CHECK: [[@LINE]]|{{ +}}2|
return; // CHECK: [[@LINE]]|{{ +}}1|
} else { // CHECK: [[@LINE]]|{{ +}}1|
return; // CHECK: [[@LINE]]|{{ +}}1|
} // CHECK: [[@LINE]]|{{ +}}1|
}
int main() {
foo(0);
foo(1);
bar();
for_loop();
while_loop();
gotos();
if_else(true);
if_else(false);
return 0;
}
// MARKER: Highlighted line 17, 5 -> 11
// MARKER-NEXT: Marker at 19:3 = 1
// MARKER-NEXT: Marker at 19:27 = 1
// MARKER-NEXT: Highlighted line 24, 7 -> 12
// MARKER-NEXT: Highlighted line 36, 5 -> 11
// MARKER-NEXT: Highlighted line 47, 7 -> 14
// MARKER-NEXT: Highlighted line 47, 14 -> 21
// MARKER-NEXT: Highlighted line 47, 21 -> 23
// MARKER-NEXT: Highlighted line 47, 23 -> 25
// MARKER-NEXT: Highlighted line 47, 25 -> ?
// MARKER-NEXT: Highlighted line 48, 1 -> 6
// MARKER-NEXT: Highlighted line 51, 7 -> 20
// MARKER-NEXT: Marker at 53:5 = 1
// MARKER-NEXT: Highlighted line 55, 9 -> 14
// MARKER-NEXT: Highlighted line 63, 5 -> 13
// MARKER-NEXT: Highlighted line 67, 1 -> ?
// MARKER-NEXT: Highlighted line 68, 1 -> 8