xref: /minix3/external/bsd/llvm/dist/clang/test/Index/targeted-annotation.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc 
2*f4a2713aSLionel Sambuc #include "targeted-top.h"
3*f4a2713aSLionel Sambuc #include "targeted-preamble.h"
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc int LocalVar1;
6*f4a2713aSLionel Sambuc int LocalVar2;
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc // RUN: c-index-test -write-pch %t.h.pch %S/targeted-top.h
9*f4a2713aSLionel Sambuc // RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-annotate-tokens=%s:1:1:7:1 %s -include %t.h \
10*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=NestedVar1  \
11*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=TopVar  \
12*f4a2713aSLionel Sambuc // RUN:  | FileCheck %s -check-prefix=LOCAL
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc // RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
15*f4a2713aSLionel Sambuc // RUN:   c-index-test -test-annotate-tokens=%s:1:1:7:1 %s -include %t.h \
16*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=PreambleVar  \
17*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=NestedVar1  \
18*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=TopVar  \
19*f4a2713aSLionel Sambuc // RUN:  | FileCheck %s -check-prefix=LOCAL
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc // LOCAL: Punctuation: "#" [2:1 - 2:2] inclusion directive=targeted-top.h
22*f4a2713aSLionel Sambuc // LOCAL: Identifier: "include" [2:2 - 2:9] inclusion directive=targeted-top.h
23*f4a2713aSLionel Sambuc // LOCAL: Literal: ""targeted-top.h"" [2:10 - 2:26] inclusion directive=targeted-top.h
24*f4a2713aSLionel Sambuc // LOCAL: Punctuation: "#" [3:1 - 3:2] inclusion directive=targeted-preamble.h
25*f4a2713aSLionel Sambuc // LOCAL: Identifier: "include" [3:2 - 3:9] inclusion directive=targeted-preamble.h
26*f4a2713aSLionel Sambuc // LOCAL: Literal: ""targeted-preamble.h"" [3:10 - 3:31] inclusion directive=targeted-preamble.h
27*f4a2713aSLionel Sambuc // LOCAL: Keyword: "int" [5:1 - 5:4] VarDecl=LocalVar1:5:5
28*f4a2713aSLionel Sambuc // LOCAL: Identifier: "LocalVar1" [5:5 - 5:14] VarDecl=LocalVar1:5:5
29*f4a2713aSLionel Sambuc // LOCAL: Punctuation: ";" [5:14 - 5:15]
30*f4a2713aSLionel Sambuc // LOCAL: Keyword: "int" [6:1 - 6:4] VarDecl=LocalVar2:6:5
31*f4a2713aSLionel Sambuc // LOCAL: Identifier: "LocalVar2" [6:5 - 6:14] VarDecl=LocalVar2:6:5
32*f4a2713aSLionel Sambuc // LOCAL: Punctuation: ";" [6:14 - 6:15]
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc // RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-annotate-tokens=%S/targeted-fields.h:1:1:4:1 %s -include %t.h \
35*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=NestedVar1  \
36*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=TopVar  \
37*f4a2713aSLionel Sambuc // RUN:  | FileCheck %s -check-prefix=FIELD
38*f4a2713aSLionel Sambuc 
39*f4a2713aSLionel Sambuc // RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
40*f4a2713aSLionel Sambuc // RUN:   c-index-test -test-annotate-tokens=%S/targeted-fields.h:1:1:4:1 %s -include %t.h \
41*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=PreambleVar  \
42*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=NestedVar1  \
43*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=TopVar  \
44*f4a2713aSLionel Sambuc // RUN:  | FileCheck %s -check-prefix=FIELD
45*f4a2713aSLionel Sambuc 
46*f4a2713aSLionel Sambuc // FIELD: Keyword: "int" [2:3 - 2:6] FieldDecl=z:2:7 (Definition)
47*f4a2713aSLionel Sambuc // FIELD: Identifier: "z" [2:7 - 2:8] FieldDecl=z:2:7 (Definition)
48*f4a2713aSLionel Sambuc // FIELD: Punctuation: ";" [2:8 - 2:9] StructDecl=:13:9 (Definition)
49*f4a2713aSLionel Sambuc // FIELD: Keyword: "int" [3:3 - 3:6] FieldDecl=w:3:7 (Definition)
50*f4a2713aSLionel Sambuc // FIELD: Identifier: "w" [3:7 - 3:8] FieldDecl=w:3:7 (Definition)
51*f4a2713aSLionel Sambuc // FIELD: Punctuation: ";" [3:8 - 3:9] StructDecl=:13:9 (Definition)
52*f4a2713aSLionel Sambuc 
53*f4a2713aSLionel Sambuc // RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-annotate-tokens=%S/targeted-nested1.h:1:1:3:1 %s -include %t.h \
54*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=TopVar  \
55*f4a2713aSLionel Sambuc // RUN:  | FileCheck %s -check-prefix=NESTED
56*f4a2713aSLionel Sambuc 
57*f4a2713aSLionel Sambuc // RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
58*f4a2713aSLionel Sambuc // RUN:   c-index-test -test-annotate-tokens=%S/targeted-nested1.h:1:1:3:1 %s -include %t.h \
59*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=PreambleVar  \
60*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=TopVar  \
61*f4a2713aSLionel Sambuc // RUN:  | FileCheck %s -check-prefix=NESTED
62*f4a2713aSLionel Sambuc 
63*f4a2713aSLionel Sambuc // NESTED: Keyword: "extern" [2:1 - 2:7]
64*f4a2713aSLionel Sambuc // NESTED: Keyword: "int" [2:8 - 2:11] VarDecl=NestedVar1:2:12
65*f4a2713aSLionel Sambuc // NESTED: Identifier: "NestedVar1" [2:12 - 2:22] VarDecl=NestedVar1:2:12
66*f4a2713aSLionel Sambuc // NESTED: Punctuation: ";" [2:22 - 2:23]
67*f4a2713aSLionel Sambuc 
68*f4a2713aSLionel Sambuc // RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-annotate-tokens=%S/targeted-top.h:1:1:12:1 %s -include %t.h \
69*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=NestedVar1  \
70*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=vector_get_x  \
71*f4a2713aSLionel Sambuc // RUN:  | FileCheck %s -check-prefix=TOP
72*f4a2713aSLionel Sambuc 
73*f4a2713aSLionel Sambuc // RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
74*f4a2713aSLionel Sambuc // RUN:   c-index-test -test-annotate-tokens=%S/targeted-top.h:1:1:12:1 %s -include %t.h \
75*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=PreambleVar  \
76*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=NestedVar1  \
77*f4a2713aSLionel Sambuc // RUN:    -Xclang -error-on-deserialized-decl=vector_get_x  \
78*f4a2713aSLionel Sambuc // RUN:  | FileCheck %s -check-prefix=TOP
79*f4a2713aSLionel Sambuc 
80*f4a2713aSLionel Sambuc // TOP: Punctuation: "#" [2:1 - 2:2] preprocessing directive=
81*f4a2713aSLionel Sambuc // TOP: Identifier: "ifndef" [2:2 - 2:8] preprocessing directive=
82*f4a2713aSLionel Sambuc // TOP: Identifier: "TARGETED_TOP_H" [2:9 - 2:23] preprocessing directive=
83*f4a2713aSLionel Sambuc // TOP: Punctuation: "#" [3:1 - 3:2] preprocessing directive=
84*f4a2713aSLionel Sambuc // TOP: Identifier: "define" [3:2 - 3:8] preprocessing directive=
85*f4a2713aSLionel Sambuc // TOP: Identifier: "TARGETED_TOP_H" [3:9 - 3:23] macro definition=TARGETED_TOP_H
86*f4a2713aSLionel Sambuc // TOP: Punctuation: "#" [5:1 - 5:2] inclusion directive=targeted-nested1.h
87*f4a2713aSLionel Sambuc // TOP: Identifier: "include" [5:2 - 5:9] inclusion directive=targeted-nested1.h
88*f4a2713aSLionel Sambuc // TOP: Literal: ""targeted-nested1.h"" [5:10 - 5:30] inclusion directive=targeted-nested1.h
89*f4a2713aSLionel Sambuc // TOP: Keyword: "enum" [7:1 - 7:5] EnumDecl=:7:1 (Definition)
90*f4a2713aSLionel Sambuc // TOP: Punctuation: "{" [7:6 - 7:7] EnumDecl=:7:1 (Definition)
91*f4a2713aSLionel Sambuc // TOP: Identifier: "VALUE" [8:3 - 8:8] EnumConstantDecl=VALUE:8:3 (Definition)
92*f4a2713aSLionel Sambuc // TOP: Punctuation: "=" [8:9 - 8:10] EnumConstantDecl=VALUE:8:3 (Definition)
93*f4a2713aSLionel Sambuc // TOP: Literal: "3" [8:11 - 8:12] IntegerLiteral=
94*f4a2713aSLionel Sambuc // TOP: Punctuation: "}" [9:1 - 9:2] EnumDecl=:7:1 (Definition)
95*f4a2713aSLionel Sambuc // TOP: Punctuation: ";" [9:2 - 9:3]
96*f4a2713aSLionel Sambuc // TOP: Keyword: "extern" [11:1 - 11:7]
97*f4a2713aSLionel Sambuc // TOP: Keyword: "int" [11:8 - 11:11] VarDecl=TopVar:11:12
98*f4a2713aSLionel Sambuc // TOP: Identifier: "TopVar" [11:12 - 11:18] VarDecl=TopVar:11:12
99*f4a2713aSLionel Sambuc // TOP: Punctuation: ";" [11:18 - 11:19]
100