llvm/clang/test/Index/skipped-ranges.c
Vedant Kumar 3919a501f3 [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
2017-09-11 20:47:42 +00:00

26 lines
431 B
C

#define cool
#if defined(cool)
#if defined(really_cool)
#endif // really_cool
#elif defined(hot)
// hot
#endif // trailing comment
#ifndef cool
#ifndef uncool
int probably_hot = 1;
#endif // uncool
#endif // cool
// RUN: env CINDEXTEST_SHOW_SKIPPED_RANGES=1 c-index-test -test-annotate-tokens=%s:1:1:16:1 %s | FileCheck %s
// CHECK: Skipping: [5:1 - 6:7]
// CHECK: Skipping: [8:1 - 12:7]
// CHECK: Skipping: [14:1 - 20:7]