1#include <stdio.h>
2int main() {
3#error This was inevitable...
4#if HELLO
5 printf("hello, world\n");
6 return 0;
7#else
8 abort();
9#endif
10}
11
12/* This comment gets lexed along with the input above! We just don't CHECK it.
13
14RUN: clang-pseudo -source %s -print-directive-tree | FileCheck %s -check-prefix=PPT --strict-whitespace
15 PPT: #include (7 tokens)
16PPT-NEXT: code (5 tokens)
17PPT-NEXT: #error (6 tokens)
18PPT-NEXT: #if (3 tokens) TAKEN
19PPT-NEXT: code (8 tokens)
20PPT-NEXT: #else (2 tokens)
21PPT-NEXT: code (4 tokens)
22PPT-NEXT: #endif (2 tokens)
23PPT-NEXT: code (2 tokens)
24 ^ including this block comment
25
26RUN: clang-pseudo -source %s -strip-directives -print-source | FileCheck %s --strict-whitespace
27 CHECK: int main() {
28CHECK-NEXT: printf("hello, world\n");
29CHECK-NEXT: return 0;
30CHECK-NEXT: }
31
32RUN: clang-pseudo -source %s -strip-directives -print-tokens | FileCheck %s --check-prefix=TOKEN
33 TOKEN: 0: raw_identifier 1:0 "int" flags=1
34TOKEN-NEXT: raw_identifier 1:0 "main"
35TOKEN-NEXT: l_paren 1:0 "("
36TOKEN-NEXT: r_paren 1:0 ")"
37TOKEN-NEXT: l_brace 1:0 "{"
38TOKEN-NEXT: raw_identifier 4:2 "printf" flags=1
39TOKEN-NEXT: l_paren 4:2 "("
40TOKEN-NEXT: string_literal 4:2 "\22hello, world\\n\22"
41TOKEN-NEXT: r_paren 4:2 ")"
42TOKEN-NEXT: semi 4:2 ";"
43TOKEN-NEXT: raw_identifier 5:2 "return" flags=1
44TOKEN-NEXT: numeric_constant 5:2 "0"
45TOKEN-NEXT: semi 5:2 ";"
46TOKEN-NEXT: r_brace 9:0 "}" flags=1
47
48*******************************************************************************/
49
50

source code of clang-tools-extra/pseudo/test/strip-directives.c