xref: /aosp_15_r20/external/clang/test/Index/targeted-cursor.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li 
2*67e74705SXin Li #include "targeted-top.h"
3*67e74705SXin Li #include "targeted-preamble.h"
4*67e74705SXin Li 
5*67e74705SXin Li int LocalVar1;
6*67e74705SXin Li int LocalVar2;
7*67e74705SXin Li 
8*67e74705SXin Li // RUN: c-index-test -write-pch %t.h.pch %S/targeted-top.h
9*67e74705SXin Li // RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%s:5:10 %s -include %t.h \
10*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=NestedVar1  \
11*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=TopVar  \
12*67e74705SXin Li // RUN:  | FileCheck %s -check-prefix=LOCAL-CURSOR1
13*67e74705SXin Li 
14*67e74705SXin Li // RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%S/targeted-top.h:11:15 %s -include %t.h \
15*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=NestedVar1  \
16*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=vector_get_x  \
17*67e74705SXin Li // RUN:  | FileCheck %s -check-prefix=TOP-CURSOR1
18*67e74705SXin Li 
19*67e74705SXin Li // RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%S/targeted-nested1.h:2:16 %s -include %t.h \
20*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=TopVar  \
21*67e74705SXin Li // RUN:  | FileCheck %s -check-prefix=NESTED-CURSOR1
22*67e74705SXin Li 
23*67e74705SXin Li // RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%S/targeted-fields.h:2:7 %s -include %t.h \
24*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=NestedVar1  \
25*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=TopVar  \
26*67e74705SXin Li // RUN:  | FileCheck %s -check-prefix=FIELD-CURSOR1
27*67e74705SXin Li 
28*67e74705SXin Li // RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%S/targeted-fields.h:1:1 %s -include %t.h \
29*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=NestedVar1  \
30*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=TopVar  \
31*67e74705SXin Li // RUN:  | FileCheck %s -check-prefix=FIELD-CURSOR2
32*67e74705SXin Li 
33*67e74705SXin Li // RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
34*67e74705SXin Li // RUN:   c-index-test -cursor-at=%s:5:10 %s -include %t.h \
35*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=PreambleVar  \
36*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=NestedVar1  \
37*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=TopVar  \
38*67e74705SXin Li // RUN:  | FileCheck %s -check-prefix=LOCAL-CURSOR1
39*67e74705SXin Li 
40*67e74705SXin Li // RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
41*67e74705SXin Li // RUN:   c-index-test -cursor-at=%S/targeted-top.h:11:15 %s -include %t.h \
42*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=PreambleVar  \
43*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=NestedVar1  \
44*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=vector_get_x  \
45*67e74705SXin Li // RUN:  | FileCheck %s -check-prefix=TOP-CURSOR1
46*67e74705SXin Li 
47*67e74705SXin Li // RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
48*67e74705SXin Li // RUN:   c-index-test -cursor-at=%S/targeted-nested1.h:2:16 %s -include %t.h \
49*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=PreambleVar  \
50*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=TopVar  \
51*67e74705SXin Li // RUN:  | FileCheck %s -check-prefix=NESTED-CURSOR1
52*67e74705SXin Li 
53*67e74705SXin Li // RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
54*67e74705SXin Li // RUN:   c-index-test -cursor-at=%S/targeted-preamble.h:2:15 %s -include %t.h \
55*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=NestedVar1  \
56*67e74705SXin Li // RUN:    -Xclang -error-on-deserialized-decl=TopVar  \
57*67e74705SXin Li // RUN:  | FileCheck %s -check-prefix=PREAMBLE-CURSOR1
58*67e74705SXin Li 
59*67e74705SXin Li // LOCAL-CURSOR1: VarDecl=LocalVar1:5:5
60*67e74705SXin Li // TOP-CURSOR1: VarDecl=TopVar:11:12
61*67e74705SXin Li // NESTED-CURSOR1: VarDecl=NestedVar1:2:12
62*67e74705SXin Li // PREAMBLE-CURSOR1: VarDecl=PreambleVar:2:12
63*67e74705SXin Li 
64*67e74705SXin Li // FIELD-CURSOR1: FieldDecl=z:2:7 (Definition)
65*67e74705SXin Li // FIELD-CURSOR2: StructDecl=:13:9 (Definition)
66