BUILD 5.8 KB

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