Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CoverageMapping / macroscopes.cpp
blob88a72116fa7dc652cef4bddfe197c4d214867fab
1 // RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroscopes.cpp %s | FileCheck %s
3 #define starts_a_scope for (int i = 0; i < 2; ++i) {
5 #define ends_a_scope \
6 x = x; \
9 #define some_code \
10 x = x; \
11 if (x == 0) { \
12 x = 1; \
13 } else { \
14 x = 2; \
15 } \
16 if (true) { \
17 x = x; \
18 } else { \
19 x = x; \
22 #define starts_a_while while (x < 5)
23 #define simple_stmt ++x
25 #define macro_with_for \
26 x = 3; \
27 for (int i = 0; i < x; ++i) { \
30 #define macro_with_while \
31 x = 4; \
32 while (x < 5) { \
33 ++x; \
36 // CHECK: main
37 // CHECK-NEXT: File 0, [[@LINE+1]]:12 -> {{[0-9]+}}:2 = #0
38 int main() {
39 int x = 0;
40 // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:3 -> [[@LINE+2]]:17 = #0
41 // CHECK-NEXT: File 0, [[@LINE+1]]:17 -> [[@LINE+7]]:15 = #1
42 starts_a_scope
43 x = x;
44 // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:5 -> [[@LINE+1]]:14 = #1
45 some_code
46 x = x;
47 // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:15 = #1
48 ends_a_scope
50 // CHECK-NEXT: Expansion,File 0, [[@LINE+4]]:3 -> [[@LINE+4]]:17 = #0
51 // CHECK-NEXT: File 0, [[@LINE+3]]:17 -> [[@LINE+5]]:15 = #4
52 // CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:5 -> [[@LINE+3]]:14 = #4
53 // CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:3 -> [[@LINE+3]]:15 = #4
54 starts_a_scope
55 some_code
56 ends_a_scope
58 // CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:3 -> [[@LINE+3]]:17 = #0
59 // CHECK-NEXT: File 0, [[@LINE+2]]:17 -> [[@LINE+3]]:15 = #7
60 // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:3 -> [[@LINE+2]]:15 = #7
61 starts_a_scope
62 ends_a_scope
64 // CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:3 -> [[@LINE+3]]:17 = #0
65 // CHECK-NEXT: Gap,File 0, [[@LINE+2]]:17 -> [[@LINE+3]]:5 = #8
66 // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:5 -> [[@LINE+2]]:16 = #8
67 starts_a_while
68 simple_stmt;
70 x = 0;
71 // CHECK-NEXT: Expansion,File 0, [[@LINE+5]]:3 -> [[@LINE+5]]:17 = #0
72 // CHECK-NEXT: Gap,File 0, [[@LINE+4]]:17 -> [[@LINE+4]]:18 = #9
73 // CHECK-NEXT: File 0, [[@LINE+3]]:18 -> [[@LINE+5]]:15 = #9
74 // CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:5 -> [[@LINE+3]]:16 = #9
75 // CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:3 -> [[@LINE+3]]:15 = #9
76 starts_a_while {
77 simple_stmt;
78 ends_a_scope
80 // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:17 = #0
81 macro_with_for
82 // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:19 = #0
83 macro_with_while
85 return 0;
88 // CHECK-NEXT: File 1, 3:24 -> 3:53 = #0
89 // CHECK-NEXT: File 1, 3:40 -> 3:45 = (#0 + #1)
90 // CHECK-NEXT: Branch,File 1, 3:40 -> 3:45 = #1, #0
91 // CHECK-NEXT: File 1, 3:47 -> 3:50 = #1
92 // CHECK-NEXT: File 1, 3:52 -> 3:53 = #1
93 // CHECK-NEXT: File 2, 10:3 -> 20:4 = #1
94 // CHECK-NEXT: File 2, 11:7 -> 11:13 = #1
95 // CHECK: File 2, 11:15 -> 13:4 = #2
96 // CHECK-NEXT: File 2, 13:10 -> 15:4 = (#1 - #2)
97 // CHECK-NEXT: File 2, 16:7 -> 16:11 = #1
98 // CHECK: File 2, 16:13 -> 18:4 = #3
99 // CHECK-NEXT: File 2, 18:10 -> 20:4 = (#1 - #3)
100 // CHECK-NEXT: File 3, 6:3 -> 7:4 = #1
101 // CHECK-NEXT: File 4, 3:24 -> 3:53 = #0
102 // CHECK-NEXT: File 4, 3:40 -> 3:45 = (#0 + #4)
103 // CHECK-NEXT: Branch,File 4, 3:40 -> 3:45 = #4, #0
104 // CHECK-NEXT: File 4, 3:47 -> 3:50 = #4
105 // CHECK-NEXT: File 4, 3:52 -> 3:53 = #4
106 // CHECK-NEXT: File 5, 10:3 -> 20:4 = #4
107 // CHECK-NEXT: File 5, 11:7 -> 11:13 = #4
108 // CHECK: File 5, 11:15 -> 13:4 = #5
109 // CHECK-NEXT: File 5, 13:10 -> 15:4 = (#4 - #5)
110 // CHECK-NEXT: File 5, 16:7 -> 16:11 = #4
111 // CHECK: File 5, 16:13 -> 18:4 = #6
112 // CHECK-NEXT: File 5, 18:10 -> 20:4 = (#4 - #6)
113 // CHECK-NEXT: File 6, 6:3 -> 7:4 = #4
114 // CHECK-NEXT: File 7, 3:24 -> 3:53 = #0
115 // CHECK-NEXT: File 7, 3:40 -> 3:45 = (#0 + #7)
116 // CHECK-NEXT: Branch,File 7, 3:40 -> 3:45 = #7, #0
117 // CHECK-NEXT: File 7, 3:47 -> 3:50 = #7
118 // CHECK-NEXT: File 7, 3:52 -> 3:53 = #7
119 // CHECK-NEXT: File 8, 6:3 -> 7:4 = #7
120 // CHECK-NEXT: File 9, 22:24 -> 22:37 = #0
121 // CHECK-NEXT: File 9, 22:31 -> 22:36 = (#0 + #8)
122 // CHECK-NEXT: Branch,File 9, 22:31 -> 22:36 = #8, #0
123 // CHECK-NEXT: File 10, 23:21 -> 23:24 = #8
124 // CHECK-NEXT: File 11, 22:24 -> 22:37 = #0
125 // CHECK-NEXT: File 11, 22:31 -> 22:36 = (#0 + #9)
126 // CHECK-NEXT: Branch,File 11, 22:31 -> 22:36 = #9, #0
127 // CHECK-NEXT: File 12, 23:21 -> 23:24 = #9
128 // CHECK-NEXT: File 13, 6:3 -> 7:4 = #9
129 // CHECK-NEXT: File 14, 26:3 -> 28:4 = #0
130 // CHECK-NEXT: File 14, 27:19 -> 27:24 = (#0 + #10)
131 // CHECK-NEXT: Branch,File 14, 27:19 -> 27:24 = #10, #0
132 // CHECK-NEXT: File 14, 27:26 -> 27:29 = #10
133 // CHECK-NEXT: File 14, 27:31 -> 28:4 = #10
134 // CHECK-NEXT: File 15, 31:3 -> 34:4 = #0
135 // CHECK-NEXT: File 15, 32:10 -> 32:15 = (#0 + #11)
136 // CHECK-NEXT: Branch,File 15, 32:10 -> 32:15 = #11, #0
137 // CHECK-NEXT: File 15, 32:17 -> 34:4 = #11