BUILD 5.8 KB

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