BUILD 5.6 KB

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