BUILD 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. load("//bazel/cc_rules:defs.bzl", "cc_library", "cc_test")
  5. load("//bazel/manifest:defs.bzl", "manifest")
  6. load("//testing/fuzzing:rules.bzl", "cc_fuzz_test")
  7. package(default_visibility = ["//visibility:public"])
  8. filegroup(
  9. name = "testdata",
  10. srcs = glob(["testdata/**/*.carbon"]),
  11. )
  12. manifest(
  13. name = "testdata.txt",
  14. srcs = [":testdata"],
  15. )
  16. cc_library(
  17. name = "node_category",
  18. srcs = ["node_category.cpp"],
  19. hdrs = ["node_category.h"],
  20. deps = [
  21. "//common:enum_mask_base",
  22. "//common:ostream",
  23. "@llvm-project//llvm:Support",
  24. ],
  25. )
  26. cc_library(
  27. name = "node_kind",
  28. srcs = ["node_kind.cpp"],
  29. hdrs = [
  30. "node_ids.h",
  31. "node_kind.h",
  32. "typed_nodes.h",
  33. ],
  34. textual_hdrs = ["node_kind.def"],
  35. deps = [
  36. ":node_category",
  37. "//common:check",
  38. "//common:enum_base",
  39. "//common:ostream",
  40. "//toolchain/base:index_base",
  41. "//toolchain/lex:token_index",
  42. "//toolchain/lex:token_kind",
  43. "@llvm-project//llvm:Support",
  44. ],
  45. )
  46. cc_test(
  47. name = "typed_nodes_test",
  48. size = "small",
  49. srcs = ["typed_nodes_test.cpp"],
  50. deps = [
  51. ":node_kind",
  52. ":parse",
  53. ":tree",
  54. "//testing/base:gtest_main",
  55. "//toolchain/diagnostics:emitter",
  56. "//toolchain/diagnostics:mocks",
  57. "//toolchain/lex",
  58. "//toolchain/lex:tokenized_buffer",
  59. "//toolchain/testing:compile_helper",
  60. "@googletest//:gtest",
  61. ],
  62. )
  63. cc_library(
  64. name = "context",
  65. srcs = ["context.cpp"],
  66. hdrs = ["context.h"],
  67. deps = [
  68. ":node_kind",
  69. ":precedence",
  70. ":state",
  71. ":tree",
  72. "//common:check",
  73. "//common:ostream",
  74. "//common:vlog",
  75. "//toolchain/diagnostics:emitter",
  76. "//toolchain/diagnostics:format_providers",
  77. "//toolchain/lex:token_kind",
  78. "//toolchain/lex:tokenized_buffer",
  79. "@llvm-project//llvm:Support",
  80. ],
  81. )
  82. cc_library(
  83. name = "parse",
  84. srcs = ["parse.cpp"] +
  85. # Glob handler files to avoid missing any.
  86. glob([
  87. "handle_*.cpp",
  88. ]),
  89. hdrs = [
  90. "handle.h",
  91. "parse.h",
  92. ],
  93. deps = [
  94. ":context",
  95. ":dump",
  96. ":node_kind",
  97. ":precedence",
  98. ":state",
  99. ":tree",
  100. "//common:check",
  101. "//common:ostream",
  102. "//common:pretty_stack_trace_function",
  103. "//toolchain/base:shared_value_stores",
  104. "//toolchain/diagnostics:emitter",
  105. "//toolchain/diagnostics:format_providers",
  106. "//toolchain/lex:token_index",
  107. "//toolchain/lex:token_kind",
  108. "//toolchain/lex:tokenized_buffer",
  109. ],
  110. )
  111. cc_library(
  112. name = "dump",
  113. srcs = ["dump.cpp"],
  114. hdrs = ["dump.h"],
  115. deps = [
  116. ":context",
  117. ":tree",
  118. "//common:ostream",
  119. "//common:raw_string_ostream",
  120. "//toolchain/lex:dump",
  121. ],
  122. # Always link dump methods.
  123. alwayslink = 1,
  124. )
  125. cc_library(
  126. name = "state",
  127. srcs = ["state.cpp"],
  128. hdrs = ["state.h"],
  129. textual_hdrs = ["state.def"],
  130. deps = ["//common:enum_base"],
  131. )
  132. cc_library(
  133. name = "tree",
  134. srcs = [
  135. "extract.cpp",
  136. "tree.cpp",
  137. "tree_and_subtrees.cpp",
  138. ],
  139. hdrs = [
  140. "tree.h",
  141. "tree_and_subtrees.h",
  142. ],
  143. deps = [
  144. ":node_kind",
  145. "//common:check",
  146. "//common:error",
  147. "//common:find",
  148. "//common:ostream",
  149. "//common:struct_reflection",
  150. "//toolchain/base:fixed_size_value_store",
  151. "//toolchain/base:value_store",
  152. "//toolchain/lex:token_index",
  153. "//toolchain/lex:tokenized_buffer",
  154. "@llvm-project//llvm:Support",
  155. ],
  156. )
  157. cc_test(
  158. name = "tree_test",
  159. size = "small",
  160. srcs = ["tree_test.cpp"],
  161. deps = [
  162. ":node_kind",
  163. ":parse",
  164. ":tree",
  165. "//common:ostream",
  166. "//common:raw_string_ostream",
  167. "//testing/base:gtest_main",
  168. "//toolchain/base:shared_value_stores",
  169. "//toolchain/diagnostics:emitter",
  170. "//toolchain/diagnostics:mocks",
  171. "//toolchain/lex",
  172. "//toolchain/lex:tokenized_buffer",
  173. "//toolchain/testing:compile_helper",
  174. "//toolchain/testing:yaml_test_helpers",
  175. "@googletest//:gtest",
  176. "@llvm-project//llvm:Support",
  177. ],
  178. )
  179. cc_fuzz_test(
  180. name = "parse_fuzzer",
  181. size = "small",
  182. srcs = ["parse_fuzzer.cpp"],
  183. corpus = glob(["fuzzer_corpus/*"]),
  184. deps = [
  185. ":parse",
  186. "//common:check",
  187. "//testing/fuzzing:libfuzzer_header",
  188. "//toolchain/base:shared_value_stores",
  189. "//toolchain/diagnostics:emitter",
  190. "//toolchain/diagnostics:null_diagnostics",
  191. "//toolchain/lex",
  192. "@llvm-project//llvm:Support",
  193. ],
  194. )
  195. cc_library(
  196. name = "precedence",
  197. srcs = ["precedence.cpp"],
  198. hdrs = ["precedence.h"],
  199. deps = [
  200. "//common:check",
  201. "//toolchain/lex:token_kind",
  202. "@llvm-project//llvm:Support",
  203. ],
  204. )
  205. cc_test(
  206. name = "precedence_test",
  207. size = "small",
  208. srcs = ["precedence_test.cpp"],
  209. deps = [
  210. ":precedence",
  211. "//testing/base:gtest_main",
  212. "//toolchain/lex:token_kind",
  213. "@googletest//:gtest",
  214. ],
  215. )
  216. cc_test(
  217. name = "coverage_test",
  218. size = "small",
  219. srcs = ["coverage_test.cpp"],
  220. args = ["--testdata_manifest=$(location :testdata.txt)"],
  221. data = [
  222. ":testdata",
  223. ":testdata.txt",
  224. ],
  225. deps = [
  226. ":node_kind",
  227. "//testing/base:gtest_main",
  228. "//toolchain/testing:coverage_helper",
  229. "@abseil-cpp//absl/flags:flag",
  230. "@googletest//:gtest",
  231. ],
  232. )