2014-08-20 01:32:30 +08:00
|
|
|
// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name switch.c %s | FileCheck %s
|
|
|
|
// CHECK: foo
|
2015-02-04 05:35:49 +08:00
|
|
|
void foo(int i) { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0
|
2014-08-20 01:32:30 +08:00
|
|
|
switch(i) {
|
2015-02-19 05:24:51 +08:00
|
|
|
case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #2
|
2014-08-20 01:32:30 +08:00
|
|
|
return;
|
2015-02-04 05:35:49 +08:00
|
|
|
case 2: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3
|
2014-08-20 01:32:30 +08:00
|
|
|
break;
|
2015-02-19 05:24:51 +08:00
|
|
|
}
|
|
|
|
int x = 0; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #1
|
|
|
|
}
|
|
|
|
|
|
|
|
void nop() {}
|
|
|
|
|
|
|
|
// CHECK: bar
|
|
|
|
void bar(int i) { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+20]]:2 = #0
|
|
|
|
switch (i)
|
|
|
|
; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:6 = 0
|
|
|
|
|
|
|
|
switch (i) { // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+16]]:2 = #1
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (i) // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+13]]:2 = #2
|
|
|
|
nop(); // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:10 = 0
|
|
|
|
|
|
|
|
switch (i) // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+10]]:2 = #3
|
|
|
|
case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #5
|
|
|
|
nop();
|
|
|
|
|
|
|
|
switch (i) { // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:2 = #4
|
|
|
|
nop(); // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+2]]:10 = 0
|
|
|
|
case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #7
|
|
|
|
nop();
|
|
|
|
}
|
|
|
|
nop(); // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #6
|
2014-08-20 01:32:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-NEXT: main
|
2015-02-04 05:35:49 +08:00
|
|
|
int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+34]]:2 = #0
|
2014-08-20 01:32:30 +08:00
|
|
|
int i = 0;
|
|
|
|
switch(i) {
|
2015-02-19 05:24:51 +08:00
|
|
|
case 0: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+7]]:10 = #2
|
2014-08-20 01:32:30 +08:00
|
|
|
i = 1;
|
|
|
|
break;
|
2015-02-04 05:35:49 +08:00
|
|
|
case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #3
|
2014-08-20 01:32:30 +08:00
|
|
|
i = 2;
|
|
|
|
break;
|
2015-02-04 05:35:49 +08:00
|
|
|
default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #4
|
2014-08-20 01:32:30 +08:00
|
|
|
break;
|
2015-02-19 05:24:51 +08:00
|
|
|
}
|
|
|
|
switch(i) { // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+22]]:2 = #1
|
|
|
|
case 0: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:10 = #6
|
2014-08-20 01:32:30 +08:00
|
|
|
i = 1;
|
|
|
|
break;
|
2015-02-19 05:24:51 +08:00
|
|
|
case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #7
|
2014-08-20 01:32:30 +08:00
|
|
|
i = 2;
|
2015-02-04 05:35:49 +08:00
|
|
|
default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = (#7 + #8)
|
2014-08-20 01:32:30 +08:00
|
|
|
break;
|
2015-02-19 05:24:51 +08:00
|
|
|
}
|
2014-08-20 01:32:30 +08:00
|
|
|
|
2015-02-19 05:24:51 +08:00
|
|
|
switch(i) { // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+12]]:2 = #5
|
|
|
|
case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+5]]:11 = #10
|
|
|
|
case 2: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+4]]:11 = (#10 + #11)
|
2014-08-20 01:32:30 +08:00
|
|
|
i = 11;
|
2015-02-19 05:24:51 +08:00
|
|
|
case 3: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:11 = ((#10 + #11) + #12)
|
2015-02-04 05:35:49 +08:00
|
|
|
case 4: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:11 = (((#10 + #11) + #12) + #13)
|
2014-08-20 01:32:30 +08:00
|
|
|
i = 99;
|
2015-02-19 05:24:51 +08:00
|
|
|
}
|
2014-08-20 01:32:30 +08:00
|
|
|
|
2015-02-19 05:24:51 +08:00
|
|
|
foo(1); // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:11 = #9
|
|
|
|
bar(1);
|
2014-08-20 01:32:30 +08:00
|
|
|
return 0;
|
|
|
|
}
|