BUILD 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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:format_providers",
  65. "//toolchain/lex:token_kind",
  66. "//toolchain/lex:tokenized_buffer",
  67. "@llvm-project//llvm:Support",
  68. ],
  69. )
  70. cc_library(
  71. name = "parse",
  72. srcs = ["parse.cpp"] +
  73. # Glob handler files to avoid missing any.
  74. glob([
  75. "handle_*.cpp",
  76. ]),
  77. hdrs = [
  78. "handle.h",
  79. "parse.h",
  80. ],
  81. deps = [
  82. ":context",
  83. ":node_kind",
  84. ":state",
  85. ":tree",
  86. "//common:check",
  87. "//common:ostream",
  88. "//toolchain/base:pretty_stack_trace_function",
  89. "//toolchain/base:value_store",
  90. "//toolchain/diagnostics:diagnostic_emitter",
  91. "//toolchain/diagnostics:format_providers",
  92. "//toolchain/lex:token_kind",
  93. "//toolchain/lex:tokenized_buffer",
  94. ],
  95. )
  96. cc_library(
  97. name = "state",
  98. srcs = ["state.cpp"],
  99. hdrs = ["state.h"],
  100. textual_hdrs = ["state.def"],
  101. deps = ["//common:enum_base"],
  102. )
  103. cc_library(
  104. name = "tree",
  105. srcs = [
  106. "extract.cpp",
  107. "tree.cpp",
  108. "tree_and_subtrees.cpp",
  109. ],
  110. hdrs = [
  111. "tree.h",
  112. "tree_and_subtrees.h",
  113. ],
  114. deps = [
  115. ":node_kind",
  116. "//common:check",
  117. "//common:error",
  118. "//common:ostream",
  119. "//common:struct_reflection",
  120. "//toolchain/lex:tokenized_buffer",
  121. "@llvm-project//llvm:Support",
  122. ],
  123. )
  124. cc_test(
  125. name = "tree_test",
  126. size = "small",
  127. srcs = ["tree_test.cpp"],
  128. deps = [
  129. ":node_kind",
  130. ":parse",
  131. ":tree",
  132. "//common:ostream",
  133. "//testing/base:gtest_main",
  134. "//testing/base:test_raw_ostream",
  135. "//toolchain/base:value_store",
  136. "//toolchain/diagnostics:diagnostic_emitter",
  137. "//toolchain/diagnostics:mocks",
  138. "//toolchain/lex",
  139. "//toolchain/lex:tokenized_buffer",
  140. "//toolchain/testing:compile_helper",
  141. "//toolchain/testing:yaml_test_helpers",
  142. "@googletest//:gtest",
  143. "@llvm-project//llvm:Support",
  144. ],
  145. )
  146. cc_fuzz_test(
  147. name = "parse_fuzzer",
  148. size = "small",
  149. srcs = ["parse_fuzzer.cpp"],
  150. corpus = glob(["fuzzer_corpus/*"]),
  151. deps = [
  152. ":parse",
  153. "//common:check",
  154. "//testing/fuzzing:libfuzzer_header",
  155. "//toolchain/base:value_store",
  156. "//toolchain/diagnostics:diagnostic_emitter",
  157. "//toolchain/diagnostics:null_diagnostics",
  158. "//toolchain/lex",
  159. "@llvm-project//llvm:Support",
  160. ],
  161. )
  162. cc_library(
  163. name = "tree_node_diagnostic_converter",
  164. hdrs = ["tree_node_diagnostic_converter.h"],
  165. deps = [
  166. ":tree",
  167. "//toolchain/diagnostics:diagnostic_emitter",
  168. "//toolchain/lex:tokenized_buffer",
  169. ],
  170. )
  171. cc_library(
  172. name = "precedence",
  173. srcs = ["precedence.cpp"],
  174. hdrs = ["precedence.h"],
  175. deps = [
  176. "//common:check",
  177. "//toolchain/lex:token_kind",
  178. "@llvm-project//llvm:Support",
  179. ],
  180. )
  181. cc_test(
  182. name = "precedence_test",
  183. size = "small",
  184. srcs = ["precedence_test.cpp"],
  185. deps = [
  186. ":precedence",
  187. "//testing/base:gtest_main",
  188. "//toolchain/lex:token_kind",
  189. "@googletest//:gtest",
  190. ],
  191. )
  192. cc_test(
  193. name = "coverage_test",
  194. size = "small",
  195. srcs = ["coverage_test.cpp"],
  196. args = ["--testdata_manifest=$(location :testdata.txt)"],
  197. data = [
  198. ":testdata",
  199. ":testdata.txt",
  200. ],
  201. deps = [
  202. ":node_kind",
  203. "//testing/base:gtest_main",
  204. "//toolchain/testing:coverage_helper",
  205. "@abseil-cpp//absl/flags:flag",
  206. "@googletest//:gtest",
  207. ],
  208. )