BUILD 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. ":context",
  115. ":tree",
  116. "//common:ostream",
  117. "//common:raw_string_ostream",
  118. "//toolchain/lex:dump",
  119. ],
  120. # Always link dump methods.
  121. alwayslink = 1,
  122. )
  123. cc_library(
  124. name = "state",
  125. srcs = ["state.cpp"],
  126. hdrs = ["state.h"],
  127. textual_hdrs = ["state.def"],
  128. deps = ["//common:enum_base"],
  129. )
  130. cc_library(
  131. name = "tree",
  132. srcs = [
  133. "extract.cpp",
  134. "tree.cpp",
  135. "tree_and_subtrees.cpp",
  136. ],
  137. hdrs = [
  138. "tree.h",
  139. "tree_and_subtrees.h",
  140. ],
  141. deps = [
  142. ":node_kind",
  143. "//common:check",
  144. "//common:error",
  145. "//common:find",
  146. "//common:ostream",
  147. "//common:struct_reflection",
  148. "//toolchain/base:fixed_size_value_store",
  149. "//toolchain/base:value_store",
  150. "//toolchain/lex:token_index",
  151. "//toolchain/lex:tokenized_buffer",
  152. "@llvm-project//llvm:Support",
  153. ],
  154. )
  155. cc_test(
  156. name = "tree_test",
  157. size = "small",
  158. srcs = ["tree_test.cpp"],
  159. deps = [
  160. ":node_kind",
  161. ":parse",
  162. ":tree",
  163. "//common:ostream",
  164. "//common:raw_string_ostream",
  165. "//testing/base:gtest_main",
  166. "//toolchain/base:shared_value_stores",
  167. "//toolchain/diagnostics:diagnostic_emitter",
  168. "//toolchain/diagnostics:mocks",
  169. "//toolchain/lex",
  170. "//toolchain/lex:tokenized_buffer",
  171. "//toolchain/testing:compile_helper",
  172. "//toolchain/testing:yaml_test_helpers",
  173. "@googletest//:gtest",
  174. "@llvm-project//llvm:Support",
  175. ],
  176. )
  177. cc_fuzz_test(
  178. name = "parse_fuzzer",
  179. size = "small",
  180. srcs = ["parse_fuzzer.cpp"],
  181. corpus = glob(["fuzzer_corpus/*"]),
  182. deps = [
  183. ":parse",
  184. "//common:check",
  185. "//testing/fuzzing:libfuzzer_header",
  186. "//toolchain/base:shared_value_stores",
  187. "//toolchain/diagnostics:diagnostic_emitter",
  188. "//toolchain/diagnostics:null_diagnostics",
  189. "//toolchain/lex",
  190. "@llvm-project//llvm:Support",
  191. ],
  192. )
  193. cc_library(
  194. name = "precedence",
  195. srcs = ["precedence.cpp"],
  196. hdrs = ["precedence.h"],
  197. deps = [
  198. "//common:check",
  199. "//toolchain/lex:token_kind",
  200. "@llvm-project//llvm:Support",
  201. ],
  202. )
  203. cc_test(
  204. name = "precedence_test",
  205. size = "small",
  206. srcs = ["precedence_test.cpp"],
  207. deps = [
  208. ":precedence",
  209. "//testing/base:gtest_main",
  210. "//toolchain/lex:token_kind",
  211. "@googletest//:gtest",
  212. ],
  213. )
  214. cc_test(
  215. name = "coverage_test",
  216. size = "small",
  217. srcs = ["coverage_test.cpp"],
  218. args = ["--testdata_manifest=$(location :testdata.txt)"],
  219. data = [
  220. ":testdata",
  221. ":testdata.txt",
  222. ],
  223. deps = [
  224. ":node_kind",
  225. "//testing/base:gtest_main",
  226. "//toolchain/testing:coverage_helper",
  227. "@abseil-cpp//absl/flags:flag",
  228. "@googletest//:gtest",
  229. ],
  230. )