2020-07-23 10:04:59 +08:00
|
|
|
// RUN: %strip_comments > %t.stripped.cpp
|
|
|
|
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++1z -triple %itanium_abi_triple -main-file-name switch.cpp %t.stripped.cpp | FileCheck %s
|
2016-10-15 07:38:13 +08:00
|
|
|
|
2020-07-23 10:04:59 +08:00
|
|
|
// CHECK: foo
|
2015-02-04 05:35:49 +08:00
|
|
|
void foo(int i) { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0
|
2019-11-22 06:17:04 +08:00
|
|
|
switch(i) { // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+4]]:10 = 0
|
2017-08-03 07:22:50 +08:00
|
|
|
case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:11 = #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
|
2019-11-22 06:17:04 +08:00
|
|
|
break; // CHECK-NEXT: Gap,File 0, [[@LINE]]:10 -> [[@LINE+2]]:3 = #1
|
2015-02-19 05:24:51 +08:00
|
|
|
}
|
2016-09-28 07:30:36 +08:00
|
|
|
int x = 0; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #1
|
2015-02-19 05:24:51 +08:00
|
|
|
}
|
|
|
|
|
2016-10-15 07:38:13 +08:00
|
|
|
int nop() { return 0; }
|
2015-02-19 05:24:51 +08:00
|
|
|
|
|
|
|
// CHECK: bar
|
|
|
|
void bar(int i) { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+20]]:2 = #0
|
2016-09-28 07:30:36 +08:00
|
|
|
switch (i)
|
2015-02-19 05:24:51 +08:00
|
|
|
; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:6 = 0
|
|
|
|
|
2016-09-28 07:30:36 +08:00
|
|
|
switch (i) { // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+16]]:2 = #1
|
2015-02-19 05:24:51 +08:00
|
|
|
}
|
|
|
|
|
2016-09-28 07:30:36 +08:00
|
|
|
switch (i) // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+13]]:2 = #2
|
2015-02-19 05:24:51 +08:00
|
|
|
nop(); // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:10 = 0
|
|
|
|
|
2016-09-28 07:30:36 +08:00
|
|
|
switch (i) // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+10]]:2 = #3
|
2015-02-19 05:24:51 +08:00
|
|
|
case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #5
|
|
|
|
nop();
|
|
|
|
|
2016-09-28 07:30:36 +08:00
|
|
|
switch (i) { // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:2 = #4
|
2019-11-22 06:17:04 +08:00
|
|
|
nop(); // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE+2]]:10 = 0
|
2015-02-19 05:24:51 +08:00
|
|
|
case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #7
|
|
|
|
nop();
|
|
|
|
}
|
2016-09-28 07:30:36 +08:00
|
|
|
nop(); // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #6
|
2014-08-20 01:32:30 +08:00
|
|
|
}
|
|
|
|
|
2016-10-15 07:38:13 +08:00
|
|
|
// CHECK: baz
|
|
|
|
void baz() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+5]]:2 = #0
|
2017-11-09 10:33:38 +08:00
|
|
|
switch (int i = true ? nop() // CHECK: [[@LINE]]:26 -> [[@LINE]]:31 = #2
|
2016-10-15 07:38:13 +08:00
|
|
|
: nop(); // CHECK-NEXT: [[@LINE]]:26 -> [[@LINE]]:31 = (#0 - #2)
|
|
|
|
i) {}
|
|
|
|
nop(); // CHECK-NEXT: [[@LINE]]:3 -> [[@LINE+1]]:2 = #1
|
|
|
|
}
|
|
|
|
|
2014-08-20 01:32:30 +08:00
|
|
|
// CHECK-NEXT: main
|
2016-10-15 07:38:13 +08:00
|
|
|
int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+35]]:2 = #0
|
2014-08-20 01:32:30 +08:00
|
|
|
int i = 0;
|
2019-11-22 06:17:04 +08:00
|
|
|
switch(i) { // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+8]]:10 = 0
|
2017-08-03 07:22:50 +08:00
|
|
|
case 0: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]: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
|
2017-09-09 02:44:56 +08:00
|
|
|
break; // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+2]]:3 = #1
|
2015-02-19 05:24:51 +08:00
|
|
|
}
|
2016-10-15 07:38:13 +08:00
|
|
|
switch(i) { // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+23]]:2 = #1
|
2019-11-22 06:17:04 +08:00
|
|
|
case 0: // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:13 -> [[@LINE+6]]:10 = 0
|
|
|
|
i = 1; // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE+1]]:10 = #6
|
2014-08-20 01:32:30 +08:00
|
|
|
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)
|
2017-09-09 02:44:56 +08:00
|
|
|
break; // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+3]]:3 = #5
|
2015-02-19 05:24:51 +08:00
|
|
|
}
|
2019-11-22 06:17:04 +08:00
|
|
|
// CHECK-NEXT: File 0, [[@LINE+1]]:3 -> [[@LINE+14]]:2 = #5
|
|
|
|
switch(i) { // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+6]]:11 = 0
|
2015-02-19 05:24:51 +08:00
|
|
|
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
|
|
|
|
2016-10-15 07:38:13 +08:00
|
|
|
foo(1); // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:11 = #9
|
2015-02-19 05:24:51 +08:00
|
|
|
bar(1);
|
2016-10-15 07:38:13 +08:00
|
|
|
baz();
|
2014-08-20 01:32:30 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2017-08-03 07:22:50 +08:00
|
|
|
|
2019-11-22 06:17:04 +08:00
|
|
|
// CHECK: pr44011
|
|
|
|
int pr44011(int i) { // CHECK-NEXT: File 0, [[@LINE]]:20 -> {{.*}}:2 = #0
|
|
|
|
switch (i) { // CHECK-NEXT: Gap,File 0, [[@LINE]]:14 -> [[@LINE+6]]:13 = 0
|
|
|
|
|
|
|
|
case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13 = #2
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13 = #3
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} // A region for counter #1 is missing due to the missing return.
|
|
|
|
|
|
|
|
|
2017-08-03 07:22:50 +08:00
|
|
|
// FIXME: End location for "case 1" shouldn't point at the end of the switch.
|
|
|
|
// CHECK: fallthrough
|
|
|
|
int fallthrough(int i) { // CHECK-NEXT: File 0, [[@LINE]]:24 -> [[@LINE+12]]:2 = #0
|
2019-11-22 06:17:04 +08:00
|
|
|
switch(i) { // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+9]]:10 = 0
|
2017-08-03 07:22:50 +08:00
|
|
|
case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+8]]:10 = #2
|
|
|
|
i = 23;
|
|
|
|
case 2: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = (#2 + #3)
|
|
|
|
i = 11;
|
|
|
|
break;
|
|
|
|
case 3: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #4
|
|
|
|
case 4: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = (#4 + #5)
|
|
|
|
i = 99;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-08-09 04:10:14 +08:00
|
|
|
|
|
|
|
void abort(void) __attribute((noreturn));
|
|
|
|
// CHECK: noret
|
|
|
|
int noret(int x) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+9]]:2
|
2019-11-22 06:17:04 +08:00
|
|
|
switch (x) { // CHECK-NEXT: Gap,File 0, [[@LINE]]:14 -> [[@LINE+6]]:14 = 0
|
2017-08-09 04:10:14 +08:00
|
|
|
default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:12
|
|
|
|
abort();
|
|
|
|
case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13
|
|
|
|
return 5;
|
|
|
|
case 2: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:14
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
}
|