targeted-annotation.c 5.4 KB

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