[ELF] Reorder SectionBase/InputSectionBase members
[llvm-project.git] / clang / test / CoverageMapping / switchmacro.c
blob0696e7490cdf99ad6e49ae477165704dad918113
1 // RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name switchmacro.c %s | FileCheck %s
3 #define FOO(x) (void)x
5 // CHECK: foo
6 int foo(int i) { // CHECK-NEXT: File 0, [[@LINE]]:16 -> {{[0-9]+}}:2 = #0
7 switch (i) { // CHECK-NEXT: Gap,File 0, [[@LINE]]:14 -> {{[0-9]+}}:11 = 0
8 default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> {{[0-9]+}}:11 = #2
9 // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:3 -> [[@LINE-1]]:10 = #2, 0
10 if (i == 1) // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:15 = #2
11 // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:9 -> [[@LINE-1]]:15 = #3, (#2 - #3)
12 return 0; // CHECK: File 0, [[@LINE]]:7 -> [[@LINE]]:15 = #3
13 // CHECK-NEXT: File 0, [[@LINE-1]]:16 -> [[@LINE+3]]:5 = (#2 - #3)
14 // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:5 -> [[@LINE+2]]:8 = (#2 - #3) (Expanded file = 1)
15 // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> {{[0-9]+}}:11 = (#2 - #3)
16 FOO(1);
17 case 0: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:13 = ((#2 + #4) - #3)
18 // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:3 -> [[@LINE-1]]:9 = #4, 0
19 return 2; // CHECK-NEXT: Gap,File 0, [[@LINE]]:14 -> [[@LINE+4]]:3 = 0
21 // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:3 -> [[@LINE+2]]:6 = 0
22 // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> {{[0-9]+}}:11 = 0
23 FOO(1);
24 // CHECK-NEXT: File 0, [[@LINE+1]]:3 -> {{[0-9]+}}:11 = #5
25 label: ;
29 // PR26825 - Crash when exiting macro expansion containing a switch
30 // CHECK: bar
31 #define START { while (0) { switch (0) {
32 #define END }}}
33 void bar(void) {
34 START // CHECK: File 0, [[@LINE]]:8 -> [[@LINE+2]]:6
35 default: ;
36 END
39 // PR27948 - Crash when handling a switch partially covered by a macro
40 // CHECK: baz
41 #define START2 switch (0) default:
42 void baz(void) {
43 for (;;)
44 START2 return; // CHECK: Expansion,File 0, [[@LINE]]:5 -> [[@LINE]]:11 = #1 (Expanded file = 1)
47 int main(int argc, const char *argv[]) {
48 foo(3);
49 return 0;