diff options
author | Vedant Kumar <vsk@apple.com> | 2017-09-11 20:47:42 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2017-09-11 20:47:42 +0000 |
commit | 3919a501f30688f0c4a03156fb672f381f03de5f (patch) | |
tree | ab649c95b8d89362f1dc95961206d117c1a09c4a /clang/test/CoverageMapping/preprocessor.c | |
parent | 5d5aa214d83a7b90c8b8370e9449f32d4d6629b4 (diff) | |
download | bcm5719-llvm-3919a501f30688f0c4a03156fb672f381f03de5f.tar.gz bcm5719-llvm-3919a501f30688f0c4a03156fb672f381f03de5f.zip |
[Lexer] Report more precise skipped regions (PR34166)
This patch teaches the preprocessor to report more precise source ranges for
code that is skipped due to conditional directives.
The new behavior includes the '#' from the opening directive and the full text
of the line containing the closing directive in the skipped area. This matches
up clang's behavior (we don't IRGen the code between the closing "endif" and
the end of a line).
This also affects the code coverage implementation. See llvm.org/PR34166 (this
also happens to be rdar://problem/23224058).
The old behavior (report the end of the skipped range as the end
location of the 'endif' token) is preserved for indexing clients.
Differential Revision: https://reviews.llvm.org/D36642
llvm-svn: 312947
Diffstat (limited to 'clang/test/CoverageMapping/preprocessor.c')
-rw-r--r-- | clang/test/CoverageMapping/preprocessor.c | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/clang/test/CoverageMapping/preprocessor.c b/clang/test/CoverageMapping/preprocessor.c index bd82b3939ed..cce8b67999c 100644 --- a/clang/test/CoverageMapping/preprocessor.c +++ b/clang/test/CoverageMapping/preprocessor.c @@ -3,36 +3,69 @@ // CHECK: func void func() { // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0 int i = 0; -#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+2]]:2 = 0 +#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+3]]:1 = 0 int x = i; #endif } -#if 0 - int g = 0; - - void bar() { } -#endif - // CHECK: main int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0 int i = 0; -#if 0 // CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+4]]:2 = 0 +# if 0 // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:1 = 0 if(i == 0) { i = 1; } -#endif +# endif // Mark me skipped! #if 1 // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> [[@LINE+1]]:12 = #0 if(i == 0) { // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #1 i = 1; } -#else // CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+5]]:2 = 0 +#else // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+6]]:1 = 0 if(i == 1) { i = 0; } } #endif + + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1 +#\ + if 0 +#\ + endif // also skipped + +#if 1 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1 +#\ + elif 0 +#endif + +#if 1 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1 +#\ + else +#endif + + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1 +#\ + ifdef NOT_DEFINED +#\ + endif + + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1 +#\ + ifndef __FILE__ +#\ + endif + + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+7]]:1 +#\ + ifdef NOT_DEFINED +#\ + \ + \ + endif // also skipped + return 0; } |