1// RUN: pp-trace -callbacks '*,-FileChanged' %s -- -undef -target x86_64 -std=c++11 | FileCheck --strict-whitespace %s
2
3#define MACRO 1
4int i = MACRO;
5#if defined(MACRO)
6#endif
7#undef MACRO
8#if defined(MACRO)
9#endif
10#define FUNCMACRO(ARG1) ARG1
11int j = FUNCMACRO(1);
12#define X X_IMPL(a+y,b) X_IMPL2(c)
13#define X_IMPL(p1,p2)
14#define X_IMPL2(p1)
15X
16
17// CHECK: ---
18// CHECK-NEXT: - Callback: MacroDefined
19// CHECK: MacroNameTok: __STDC__
20// CHECK-NEXT: MacroDirective: MD_Define
21// CHECK-NEXT: - Callback: MacroDefined
22// CHECK: MacroNameTok: __STDC_HOSTED__
23// CHECK-NEXT: MacroDirective: MD_Define
24// CHECK-NEXT: - Callback: MacroDefined
25// CHECK: MacroNameTok: __cplusplus
26// CHECK-NEXT: MacroDirective: MD_Define
27// CHECK-NEXT: - Callback: MacroDefined
28// CHECK: MacroNameTok: __STDC_UTF_16__
29// CHECK-NEXT: MacroDirective: MD_Define
30// CHECK-NEXT: - Callback: MacroDefined
31// CHECK: MacroNameTok: __STDC_UTF_32__
32// CHECK-NEXT: MacroDirective: MD_Define
33// CHECK: - Callback: MacroDefined
34// CHECK: - Callback: MacroDefined
35// CHECK-NEXT: MacroNameTok: MACRO
36// CHECK-NEXT: MacroDirective: MD_Define
37// CHECK-NEXT: - Callback: MacroExpands
38// CHECK-NEXT: MacroNameTok: MACRO
39// CHECK-NEXT: MacroDefinition: [(local)]
40// CHECK-NEXT: Range: ["{{.*}}{{[/\\]}}pp-trace-macro.cpp:4:9", "{{.*}}{{[/\\]}}pp-trace-macro.cpp:4:9"]
41// CHECK-NEXT: Args: (null)
42// CHECK-NEXT: - Callback: Defined
43// CHECK-NEXT: MacroNameTok: MACRO
44// CHECK-NEXT: MacroDefinition: [(local)]
45// CHECK-NEXT: Range: ["{{.*}}{{[/\\]}}pp-trace-macro.cpp:5:5", "{{.*}}{{[/\\]}}pp-trace-macro.cpp:5:19"]
46// CHECK-NEXT: - Callback: If
47// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}pp-trace-macro.cpp:5:2"
48// CHECK-NEXT: ConditionRange: ["{{.*}}{{[/\\]}}pp-trace-macro.cpp:5:5", "{{.*}}{{[/\\]}}pp-trace-macro.cpp:5:19"]
49// CHECK-NEXT: ConditionValue: CVK_True
50// CHECK-NEXT: - Callback: Endif
51// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}pp-trace-macro.cpp:6:2"
52// CHECK-NEXT: IfLoc: "{{.*}}{{[/\\]}}pp-trace-macro.cpp:5:2"
53// CHECK-NEXT: - Callback: MacroUndefined
54// CHECK-NEXT: MacroNameTok: MACRO
55// CHECK-NEXT: MacroDefinition: [(local)]
56// CHECK-NEXT: - Callback: Defined
57// CHECK-NEXT: MacroNameTok: MACRO
58// CHECK-NEXT: MacroDefinition: []
59// CHECK-NEXT: Range: ["{{.*}}{{[/\\]}}pp-trace-macro.cpp:8:5", "{{.*}}{{[/\\]}}pp-trace-macro.cpp:8:19"]
60// CHECK-NEXT: - Callback: If
61// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}pp-trace-macro.cpp:8:2"
62// CHECK-NEXT: ConditionRange: ["{{.*}}{{[/\\]}}pp-trace-macro.cpp:8:5", "{{.*}}{{[/\\]}}pp-trace-macro.cpp:8:19"]
63// CHECK-NEXT: ConditionValue: CVK_False
64// CHECK-NEXT: - Callback: Endif
65// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}pp-trace-macro.cpp:9:2"
66// CHECK-NEXT: IfLoc: "{{.*}}{{[/\\]}}pp-trace-macro.cpp:8:2"
67// CHECK-NEXT: - Callback: SourceRangeSkipped
68// CHECK-NEXT: Range: ["{{.*}}{{[/\\]}}pp-trace-macro.cpp:8:1", "{{.*}}{{[/\\]}}pp-trace-macro.cpp:9:2"]
69// CHECK-NEXT: - Callback: MacroDefined
70// CHECK-NEXT: MacroNameTok: FUNCMACRO
71// CHECK-NEXT: MacroDirective: MD_Define
72// CHECK-NEXT: - Callback: MacroExpands
73// CHECK-NEXT: MacroNameTok: FUNCMACRO
74// CHECK-NEXT: MacroDefinition: [(local)]
75// CHECK-NEXT: Range: ["{{.*}}{{[/\\]}}pp-trace-macro.cpp:11:9", "{{.*}}{{[/\\]}}pp-trace-macro.cpp:11:20"]
76// CHECK-NEXT: Args: [1]
77// CHECK-NEXT: - Callback: MacroDefined
78// CHECK-NEXT: MacroNameTok: X
79// CHECK-NEXT: MacroDirective: MD_Define
80// CHECK-NEXT: - Callback: MacroDefined
81// CHECK-NEXT: MacroNameTok: X_IMPL
82// CHECK-NEXT: MacroDirective: MD_Define
83// CHECK-NEXT: - Callback: MacroDefined
84// CHECK-NEXT: MacroNameTok: X_IMPL2
85// CHECK-NEXT: MacroDirective: MD_Define
86// CHECK-NEXT: - Callback: MacroExpands
87// CHECK-NEXT: MacroNameTok: X
88// CHECK-NEXT: MacroDefinition: [(local)]
89// CHECK-NEXT: Range: ["{{.*}}{{[/\\]}}pp-trace-macro.cpp:15:1", "{{.*}}{{[/\\]}}pp-trace-macro.cpp:15:1"]
90// CHECK-NEXT: Args: (null)
91// CHECK-NEXT: - Callback: MacroExpands
92// CHECK-NEXT: MacroNameTok: X_IMPL
93// CHECK-NEXT: MacroDefinition: [(local)]
94// CHECK-NEXT: Range: [(nonfile), (nonfile)]
95// CHECK-NEXT: Args: [a <plus> y, b]
96// CHECK-NEXT: - Callback: MacroExpands
97// CHECK-NEXT: MacroNameTok: X_IMPL2
98// CHECK-NEXT: MacroDefinition: [(local)]
99// CHECK-NEXT: Range: [(nonfile), (nonfile)]
100// CHECK-NEXT: Args: [c]
101// CHECK-NEXT: - Callback: EndOfMainFile
102// CHECK-NEXT: ...
103

source code of clang-tools-extra/test/pp-trace/pp-trace-macro.cpp