diff options
author | Eli Friedman <efriedma@codeaurora.org> | 2017-08-02 23:22:50 +0000 |
---|---|---|
committer | Eli Friedman <efriedma@codeaurora.org> | 2017-08-02 23:22:50 +0000 |
commit | 7f53fbfcdc27d8532d5636a8d8fc7f012a0e782d (patch) | |
tree | 894ff4636715df403b5695f2459e6bcedda21c10 /clang/test/CoverageMapping/switch.cpp | |
parent | 8d2cbf2e9b788a544f7e46b200a1be403effc708 (diff) | |
download | bcm5719-llvm-7f53fbfcdc27d8532d5636a8d8fc7f012a0e782d.tar.gz bcm5719-llvm-7f53fbfcdc27d8532d5636a8d8fc7f012a0e782d.zip |
[coverage] Make smaller regions for the first case of a switch.
We never overwrite the end location of a region, so we would end up with
an overly large region when we reused the switch's region.
It's possible this code will be substantially rewritten in the near
future to deal with fallthrough more accurately, but this seems like
an improvement on its own for now.
Differential Revision: https://reviews.llvm.org/D34801
llvm-svn: 309901
Diffstat (limited to 'clang/test/CoverageMapping/switch.cpp')
-rw-r--r-- | clang/test/CoverageMapping/switch.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/clang/test/CoverageMapping/switch.cpp b/clang/test/CoverageMapping/switch.cpp index 312f26ca16e..17aa53bb486 100644 --- a/clang/test/CoverageMapping/switch.cpp +++ b/clang/test/CoverageMapping/switch.cpp @@ -3,7 +3,7 @@ // CHECK: foo void foo(int i) { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0 switch(i) { - case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #2 + case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:11 = #2 return; case 2: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3 break; @@ -48,7 +48,7 @@ void baz() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+5]]:2 = #0 int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+35]]:2 = #0 int i = 0; switch(i) { - case 0: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+7]]:10 = #2 + case 0: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #2 i = 1; break; case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #3 @@ -58,7 +58,7 @@ int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+35]]:2 = #0 break; } switch(i) { // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+23]]:2 = #1 - case 0: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:10 = #6 + case 0: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #6 i = 1; break; case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #7 @@ -81,3 +81,19 @@ int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+35]]:2 = #0 baz(); return 0; } + +// 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 + switch(i) { + 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; + } +} |