BUILD 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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_binary", "cc_library", "cc_test")
  5. load("//testing/fuzzing:rules.bzl", "cc_fuzz_test")
  6. package(default_visibility = ["//visibility:public"])
  7. filegroup(
  8. name = "testdata",
  9. srcs = glob(["testdata/**/*.carbon"]),
  10. )
  11. cc_library(
  12. name = "token_kind",
  13. srcs = ["token_kind.cpp"],
  14. hdrs = ["token_kind.h"],
  15. textual_hdrs = ["token_kind.def"],
  16. deps = [
  17. "//common:check",
  18. "//common:enum_base",
  19. "@llvm-project//llvm:Support",
  20. ],
  21. )
  22. cc_test(
  23. name = "token_kind_test",
  24. size = "small",
  25. srcs = ["token_kind_test.cpp"],
  26. deps = [
  27. ":token_kind",
  28. "//testing/base:gtest_main",
  29. "@googletest//:gtest",
  30. "@llvm-project//llvm:Support",
  31. ],
  32. )
  33. cc_library(
  34. name = "character_set",
  35. hdrs = ["character_set.h"],
  36. deps = ["@llvm-project//llvm:Support"],
  37. )
  38. cc_library(
  39. name = "helpers",
  40. srcs = ["helpers.cpp"],
  41. hdrs = ["helpers.h"],
  42. deps = [
  43. "//toolchain/diagnostics:diagnostic_emitter",
  44. "@llvm-project//llvm:Support",
  45. ],
  46. )
  47. cc_library(
  48. name = "test_helpers",
  49. testonly = 1,
  50. hdrs = ["test_helpers.h"],
  51. deps = [
  52. "//common:check",
  53. "//common:string_helpers",
  54. "//toolchain/diagnostics:diagnostic_emitter",
  55. "@googletest//:gtest",
  56. "@llvm-project//llvm:Support",
  57. ],
  58. )
  59. cc_library(
  60. name = "numeric_literal",
  61. srcs = ["numeric_literal.cpp"],
  62. hdrs = ["numeric_literal.h"],
  63. deps = [
  64. ":character_set",
  65. ":helpers",
  66. "//common:check",
  67. "//toolchain/diagnostics:diagnostic_emitter",
  68. "//toolchain/diagnostics:format_providers",
  69. "@llvm-project//llvm:Support",
  70. ],
  71. )
  72. cc_binary(
  73. name = "numeric_literal_benchmark",
  74. testonly = 1,
  75. srcs = ["numeric_literal_benchmark.cpp"],
  76. deps = [
  77. ":numeric_literal",
  78. "//common:check",
  79. "//testing/base:benchmark_main",
  80. "//toolchain/diagnostics:null_diagnostics",
  81. "@google_benchmark//:benchmark",
  82. ],
  83. )
  84. cc_test(
  85. name = "numeric_literal_test",
  86. size = "small",
  87. srcs = ["numeric_literal_test.cpp"],
  88. deps = [
  89. ":numeric_literal",
  90. ":test_helpers",
  91. "//common:check",
  92. "//common:ostream",
  93. "//testing/base:gtest_main",
  94. "//toolchain/diagnostics:diagnostic_emitter",
  95. "@googletest//:gtest",
  96. "@llvm-project//llvm:Support",
  97. ],
  98. )
  99. cc_fuzz_test(
  100. name = "numeric_literal_fuzzer",
  101. size = "small",
  102. srcs = ["numeric_literal_fuzzer.cpp"],
  103. corpus = glob(["fuzzer_corpus/numeric_literal/*"]),
  104. deps = [
  105. ":numeric_literal",
  106. "//testing/fuzzing:libfuzzer_header",
  107. "//toolchain/diagnostics:diagnostic_emitter",
  108. "//toolchain/diagnostics:null_diagnostics",
  109. "@llvm-project//llvm:Support",
  110. ],
  111. )
  112. cc_library(
  113. name = "string_literal",
  114. srcs = ["string_literal.cpp"],
  115. hdrs = ["string_literal.h"],
  116. deps = [
  117. ":character_set",
  118. ":helpers",
  119. "//common:check",
  120. "//toolchain/diagnostics:diagnostic_emitter",
  121. "@llvm-project//llvm:Support",
  122. ],
  123. )
  124. cc_binary(
  125. name = "string_literal_benchmark",
  126. testonly = 1,
  127. srcs = ["string_literal_benchmark.cpp"],
  128. deps = [
  129. ":string_literal",
  130. "//testing/base:benchmark_main",
  131. "//toolchain/diagnostics:null_diagnostics",
  132. "@google_benchmark//:benchmark",
  133. ],
  134. )
  135. cc_test(
  136. name = "string_literal_test",
  137. size = "small",
  138. srcs = ["string_literal_test.cpp"],
  139. deps = [
  140. ":string_literal",
  141. ":test_helpers",
  142. "//common:check",
  143. "//common:ostream",
  144. "//testing/base:gtest_main",
  145. "//toolchain/diagnostics:diagnostic_emitter",
  146. "@googletest//:gtest",
  147. "@llvm-project//llvm:Support",
  148. ],
  149. )
  150. cc_fuzz_test(
  151. name = "string_literal_fuzzer",
  152. size = "small",
  153. srcs = ["string_literal_fuzzer.cpp"],
  154. corpus = glob(["fuzzer_corpus/string_literal/*"]),
  155. deps = [
  156. ":string_literal",
  157. "//common:check",
  158. "//testing/fuzzing:libfuzzer_header",
  159. "//toolchain/diagnostics:diagnostic_emitter",
  160. "//toolchain/diagnostics:null_diagnostics",
  161. "@llvm-project//llvm:Support",
  162. ],
  163. )
  164. cc_library(
  165. name = "lex",
  166. srcs = ["lex.cpp"],
  167. hdrs = ["lex.h"],
  168. deps = [
  169. ":character_set",
  170. ":dump",
  171. ":helpers",
  172. ":numeric_literal",
  173. ":string_literal",
  174. ":token_index",
  175. ":token_kind",
  176. ":tokenized_buffer",
  177. "//common:check",
  178. "//common:variant_helpers",
  179. "//toolchain/base:shared_value_stores",
  180. "//toolchain/diagnostics:diagnostic_emitter",
  181. "//toolchain/source:source_buffer",
  182. "@llvm-project//llvm:Support",
  183. ],
  184. )
  185. cc_library(
  186. name = "dump",
  187. srcs = ["dump.cpp"],
  188. hdrs = ["dump.h"],
  189. deps = [
  190. ":tokenized_buffer",
  191. "//common:ostream",
  192. "//common:raw_string_ostream",
  193. ],
  194. # Always link dump methods.
  195. alwayslink = 1,
  196. )
  197. cc_library(
  198. name = "token_index",
  199. hdrs = ["token_index.h"],
  200. deps = [
  201. ":token_kind",
  202. "//toolchain/base:index_base",
  203. ],
  204. )
  205. cc_library(
  206. name = "tokenized_buffer",
  207. srcs = ["tokenized_buffer.cpp"],
  208. hdrs = ["tokenized_buffer.h"],
  209. deps = [
  210. ":character_set",
  211. ":helpers",
  212. ":numeric_literal",
  213. ":string_literal",
  214. ":token_index",
  215. ":token_kind",
  216. "//common:check",
  217. "//common:ostream",
  218. "//common:string_helpers",
  219. "//toolchain/base:index_base",
  220. "//toolchain/base:mem_usage",
  221. "//toolchain/base:shared_value_stores",
  222. "//toolchain/diagnostics:diagnostic_emitter",
  223. "//toolchain/source:source_buffer",
  224. "@llvm-project//llvm:Support",
  225. ],
  226. )
  227. cc_library(
  228. name = "tokenized_buffer_test_helpers",
  229. testonly = 1,
  230. hdrs = ["tokenized_buffer_test_helpers.h"],
  231. deps = [
  232. ":lex",
  233. ":tokenized_buffer",
  234. "//common:check",
  235. "//toolchain/base:shared_value_stores",
  236. "@googletest//:gtest",
  237. "@llvm-project//llvm:Support",
  238. ],
  239. )
  240. cc_test(
  241. name = "tokenized_buffer_test",
  242. size = "small",
  243. srcs = ["tokenized_buffer_test.cpp"],
  244. deps = [
  245. ":lex",
  246. ":token_kind",
  247. ":tokenized_buffer",
  248. ":tokenized_buffer_test_helpers",
  249. "//common:raw_string_ostream",
  250. "//testing/base:gtest_main",
  251. "//toolchain/base:shared_value_stores",
  252. "//toolchain/diagnostics:diagnostic_emitter",
  253. "//toolchain/diagnostics:mocks",
  254. "//toolchain/testing:compile_helper",
  255. "//toolchain/testing:yaml_test_helpers",
  256. "@googletest//:gtest",
  257. "@llvm-project//llvm:Support",
  258. ],
  259. )
  260. cc_fuzz_test(
  261. name = "tokenized_buffer_fuzzer",
  262. size = "small",
  263. srcs = ["tokenized_buffer_fuzzer.cpp"],
  264. corpus = glob(["fuzzer_corpus/tokenized_buffer/*"]),
  265. deps = [
  266. ":lex",
  267. "//common:check",
  268. "//testing/fuzzing:libfuzzer_header",
  269. "//toolchain/base:shared_value_stores",
  270. "//toolchain/diagnostics:diagnostic_emitter",
  271. "//toolchain/diagnostics:null_diagnostics",
  272. "@llvm-project//llvm:Support",
  273. ],
  274. )
  275. cc_binary(
  276. name = "tokenized_buffer_benchmark",
  277. testonly = 1,
  278. srcs = ["tokenized_buffer_benchmark.cpp"],
  279. deps = [
  280. ":lex",
  281. ":token_kind",
  282. ":tokenized_buffer",
  283. "//common:check",
  284. "//common:raw_string_ostream",
  285. "//testing/base:benchmark_main",
  286. "//testing/base:source_gen_lib",
  287. "//toolchain/base:shared_value_stores",
  288. "//toolchain/diagnostics:diagnostic_emitter",
  289. "//toolchain/diagnostics:null_diagnostics",
  290. "@abseil-cpp//absl/random",
  291. "@google_benchmark//:benchmark",
  292. "@llvm-project//llvm:Support",
  293. ],
  294. )