diff options
author | Vedant Kumar <vsk@apple.com> | 2016-03-04 08:07:15 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2016-03-04 08:07:15 +0000 |
commit | 22bd871ea66538c1c21929828e2eca2185161c3e (patch) | |
tree | aa80b9bff2dd8548eedf07d0ceb148928f6b3c46 /clang/test/CoverageMapping/switchmacro.c | |
parent | 37e594c79966900734dd1cc1bda3a9cafc48cd85 (diff) | |
download | bcm5719-llvm-22bd871ea66538c1c21929828e2eca2185161c3e.tar.gz bcm5719-llvm-22bd871ea66538c1c21929828e2eca2185161c3e.zip |
[Coverage] Fix the start/end locations of switch statements
While pushing switch statements onto the region stack we neglected to
specify their start/end locations. This results in a crash (PR26825) if
we end up in nested macro expansions without enough information to
handle the relevant file exits.
I added a test in switchmacro.c and fixed up a bunch of incorrect CHECK
lines that specify strange end locations for switches.
llvm-svn: 262697
Diffstat (limited to 'clang/test/CoverageMapping/switchmacro.c')
-rw-r--r-- | clang/test/CoverageMapping/switchmacro.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/clang/test/CoverageMapping/switchmacro.c b/clang/test/CoverageMapping/switchmacro.c index 8410c03de03..f2943b8ae44 100644 --- a/clang/test/CoverageMapping/switchmacro.c +++ b/clang/test/CoverageMapping/switchmacro.c @@ -4,11 +4,11 @@ // CHECK: foo int foo(int i) { // CHECK-NEXT: File 0, [[@LINE]]:16 -> {{[0-9]+}}:2 = #0 - switch (i) { + switch (i) { // CHECK-NEXT: File 0, [[@LINE]]:3 -> {{[0-9]+}}:4 = #1 default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> {{[0-9]+}}:11 = #2 if (i == 1) // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:15 = #2 return 0; // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:15 = #3 - // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:5 -> [[@LINE+2]]:8 = (#2 - #3) + // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:5 -> [[@LINE+2]]:8 = (#2 - #3) (Expanded file = 1) // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> {{[0-9]+}}:11 = (#2 - #3) FOO(1); case 0: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13 = ((#2 + #4) - #3) @@ -22,6 +22,16 @@ int foo(int i) { // CHECK-NEXT: File 0, [[@LINE]]:16 -> {{[0-9]+}}:2 = #0 } } +// PR26825 - Crash when exiting macro expansion containing a switch +// CHECK: bar +#define START { while (0) { switch (0) { +#define END }}} +void bar() { + START // CHECK: File 0, [[@LINE]]:8 -> [[@LINE+2]]:6 +default: ; + END +} + int main(int argc, const char *argv[]) { foo(3); return 0; |