BUILD 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. "//toolchain/base: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:value_store",
  148. "//toolchain/lex:token_index",
  149. "//toolchain/lex:tokenized_buffer",
  150. "@llvm-project//llvm:Support",
  151. ],
  152. )
  153. cc_test(
  154. name = "tree_test",
  155. size = "small",
  156. srcs = ["tree_test.cpp"],
  157. deps = [
  158. ":node_kind",
  159. ":parse",
  160. ":tree",
  161. "//common:ostream",
  162. "//common:raw_string_ostream",
  163. "//testing/base:gtest_main",
  164. "//toolchain/base:shared_value_stores",
  165. "//toolchain/diagnostics:diagnostic_emitter",
  166. "//toolchain/diagnostics:mocks",
  167. "//toolchain/lex",
  168. "//toolchain/lex:tokenized_buffer",
  169. "//toolchain/testing:compile_helper",
  170. "//toolchain/testing:yaml_test_helpers",
  171. "@googletest//:gtest",
  172. "@llvm-project//llvm:Support",
  173. ],
  174. )
  175. cc_fuzz_test(
  176. name = "parse_fuzzer",
  177. size = "small",
  178. srcs = ["parse_fuzzer.cpp"],
  179. corpus = glob(["fuzzer_corpus/*"]),
  180. deps = [
  181. ":parse",
  182. "//common:check",
  183. "//testing/fuzzing:libfuzzer_header",
  184. "//toolchain/base:shared_value_stores",
  185. "//toolchain/diagnostics:diagnostic_emitter",
  186. "//toolchain/diagnostics:null_diagnostics",
  187. "//toolchain/lex",
  188. "@llvm-project//llvm:Support",
  189. ],
  190. )
  191. cc_library(
  192. name = "precedence",
  193. srcs = ["precedence.cpp"],
  194. hdrs = ["precedence.h"],
  195. deps = [
  196. "//common:check",
  197. "//toolchain/lex:token_kind",
  198. "@llvm-project//llvm:Support",
  199. ],
  200. )
  201. cc_test(
  202. name = "precedence_test",
  203. size = "small",
  204. srcs = ["precedence_test.cpp"],
  205. deps = [
  206. ":precedence",
  207. "//testing/base:gtest_main",
  208. "//toolchain/lex:token_kind",
  209. "@googletest//:gtest",
  210. ],
  211. )
  212. cc_test(
  213. name = "coverage_test",
  214. size = "small",
  215. srcs = ["coverage_test.cpp"],
  216. args = ["--testdata_manifest=$(location :testdata.txt)"],
  217. data = [
  218. ":testdata",
  219. ":testdata.txt",
  220. ],
  221. deps = [
  222. ":node_kind",
  223. "//testing/base:gtest_main",
  224. "//toolchain/testing:coverage_helper",
  225. "@abseil-cpp//absl/flags:flag",
  226. "@googletest//:gtest",
  227. ],
  228. )