xref: /minix3/external/bsd/llvm/dist/clang/test/Index/c-index-getCursor-pp.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc #define OBSCURE(X) X
2*f4a2713aSLionel Sambuc #define DECORATION
3*f4a2713aSLionel Sambuc #define FNM(X) OBSCURE(X)
4*f4a2713aSLionel Sambuc typedef int T;
OBSCURE(func)5*f4a2713aSLionel Sambuc void OBSCURE(func)(int x) {
6*f4a2713aSLionel Sambuc   OBSCURE(T) DECORATION value;
7*f4a2713aSLionel Sambuc }
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc #include "a.h"
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc #define A(X) X
12*f4a2713aSLionel Sambuc #define B(X) A(X)
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc B(int x);
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc const char *fname = __FILE__;
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc #include <a.h>
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc #ifdef OBSCURE
21*f4a2713aSLionel Sambuc #endif
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc #if defined(OBSCURE)
24*f4a2713aSLionel Sambuc #endif
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc #define C(A) A
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc // RUN: c-index-test -cursor-at=%s:1:11 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-1 %s
29*f4a2713aSLionel Sambuc // CHECK-1: macro definition=OBSCURE
30*f4a2713aSLionel Sambuc // RUN: c-index-test -cursor-at=%s:2:14 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-2 %s
31*f4a2713aSLionel Sambuc // CHECK-2: macro definition=DECORATION
32*f4a2713aSLionel Sambuc // RUN: c-index-test -cursor-at=%s:5:7 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-3 %s
33*f4a2713aSLionel Sambuc // CHECK-3: macro expansion=OBSCURE:1:9
34*f4a2713aSLionel Sambuc // RUN: c-index-test -cursor-at=%s:6:6 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-4 %s
35*f4a2713aSLionel Sambuc // CHECK-4: macro expansion=OBSCURE:1:9
36*f4a2713aSLionel Sambuc // RUN: c-index-test -cursor-at=%s:6:19 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-5 %s
37*f4a2713aSLionel Sambuc // CHECK-5: macro expansion=DECORATION:2:9
38*f4a2713aSLionel Sambuc // RUN: c-index-test -cursor-at=%s:9:10 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-6 %s
39*f4a2713aSLionel Sambuc // CHECK-6: inclusion directive=a.h
40*f4a2713aSLionel Sambuc // RUN: c-index-test -cursor-at=%s:14:1 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-7 %s
41*f4a2713aSLionel Sambuc // CHECK-7: macro expansion=B:12:9
42*f4a2713aSLionel Sambuc // RUN: c-index-test -cursor-at=%s:16:25 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-8 %s
43*f4a2713aSLionel Sambuc // CHECK-8: macro expansion=__FILE__
44*f4a2713aSLionel Sambuc // RUN: c-index-test -cursor-at=%s:18:12 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-9 %s
45*f4a2713aSLionel Sambuc // CHECK-9: inclusion directive=a.h
46*f4a2713aSLionel Sambuc // RUN: c-index-test -cursor-at=%s:20:10 -cursor-at=%s:23:15 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-10 %s
47*f4a2713aSLionel Sambuc // CHECK-10: 20:8 macro expansion=OBSCURE
48*f4a2713aSLionel Sambuc // CHECK-10: 23:13 macro expansion=OBSCURE
49*f4a2713aSLionel Sambuc 
50*f4a2713aSLionel Sambuc // RUN: c-index-test -cursor-at=%s:3:20 -cursor-at=%s:12:14 \
51*f4a2713aSLionel Sambuc // RUN:              -cursor-at=%s:26:11 -cursor-at=%s:26:14 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-IN-MACRODEF %s
52*f4a2713aSLionel Sambuc // CHECK-IN-MACRODEF: 3:16 macro expansion=OBSCURE
53*f4a2713aSLionel Sambuc // CHECK-IN-MACRODEF: 12:14 macro expansion=A
54*f4a2713aSLionel Sambuc // CHECK-IN-MACRODEF: 26:9 macro definition=C
55*f4a2713aSLionel Sambuc // CHECK-IN-MACRODEF: 26:9 macro definition=C
56*f4a2713aSLionel Sambuc 
57*f4a2713aSLionel Sambuc // Same tests, but with "editing" optimizations
58*f4a2713aSLionel Sambuc // RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%s:1:11 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-1 %s
59*f4a2713aSLionel Sambuc // RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%s:2:14 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-2 %s
60*f4a2713aSLionel Sambuc // RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%s:5:7 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-3 %s
61*f4a2713aSLionel Sambuc // RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%s:9:10 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-6 %s
62*f4a2713aSLionel Sambuc // RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%s:3:20 -cursor-at=%s:12:14 \
63*f4a2713aSLionel Sambuc // RUN:              -cursor-at=%s:26:11 -cursor-at=%s:26:14 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-IN-MACRODEF %s
64