BUILD 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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_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. data = 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. "@llvm-project//llvm:Support",
  69. ],
  70. )
  71. cc_binary(
  72. name = "numeric_literal_benchmark",
  73. testonly = 1,
  74. srcs = ["numeric_literal_benchmark.cpp"],
  75. deps = [
  76. ":numeric_literal",
  77. "//common:check",
  78. "//testing/base:benchmark_main",
  79. "//toolchain/diagnostics:null_diagnostics",
  80. "@google_benchmark//:benchmark",
  81. ],
  82. )
  83. cc_test(
  84. name = "numeric_literal_test",
  85. size = "small",
  86. srcs = ["numeric_literal_test.cpp"],
  87. deps = [
  88. ":numeric_literal",
  89. ":test_helpers",
  90. "//common:check",
  91. "//common:ostream",
  92. "//testing/base:gtest_main",
  93. "//toolchain/diagnostics:diagnostic_emitter",
  94. "@googletest//:gtest",
  95. "@llvm-project//llvm:Support",
  96. ],
  97. )
  98. cc_fuzz_test(
  99. name = "numeric_literal_fuzzer",
  100. size = "small",
  101. srcs = ["numeric_literal_fuzzer.cpp"],
  102. corpus = glob(["fuzzer_corpus/numeric_literal/*"]),
  103. deps = [
  104. ":numeric_literal",
  105. "//testing/fuzzing:libfuzzer_header",
  106. "//toolchain/diagnostics:diagnostic_emitter",
  107. "//toolchain/diagnostics:null_diagnostics",
  108. "@llvm-project//llvm:Support",
  109. ],
  110. )
  111. cc_library(
  112. name = "string_literal",
  113. srcs = ["string_literal.cpp"],
  114. hdrs = ["string_literal.h"],
  115. deps = [
  116. ":character_set",
  117. ":helpers",
  118. "//common:check",
  119. "//toolchain/diagnostics:diagnostic_emitter",
  120. "@llvm-project//llvm:Support",
  121. ],
  122. )
  123. cc_binary(
  124. name = "string_literal_benchmark",
  125. testonly = 1,
  126. srcs = ["string_literal_benchmark.cpp"],
  127. deps = [
  128. ":string_literal",
  129. "//testing/base:benchmark_main",
  130. "//toolchain/diagnostics:null_diagnostics",
  131. "@google_benchmark//:benchmark",
  132. ],
  133. )
  134. cc_test(
  135. name = "string_literal_test",
  136. size = "small",
  137. srcs = ["string_literal_test.cpp"],
  138. deps = [
  139. ":string_literal",
  140. ":test_helpers",
  141. "//common:check",
  142. "//common:ostream",
  143. "//testing/base:gtest_main",
  144. "//toolchain/diagnostics:diagnostic_emitter",
  145. "@googletest//:gtest",
  146. "@llvm-project//llvm:Support",
  147. ],
  148. )
  149. cc_fuzz_test(
  150. name = "string_literal_fuzzer",
  151. size = "small",
  152. srcs = ["string_literal_fuzzer.cpp"],
  153. corpus = glob(["fuzzer_corpus/string_literal/*"]),
  154. deps = [
  155. ":string_literal",
  156. "//common:check",
  157. "//testing/fuzzing:libfuzzer_header",
  158. "//toolchain/diagnostics:diagnostic_emitter",
  159. "//toolchain/diagnostics:null_diagnostics",
  160. "@llvm-project//llvm:Support",
  161. ],
  162. )
  163. cc_library(
  164. name = "lex",
  165. srcs = ["lex.cpp"],
  166. hdrs = ["lex.h"],
  167. deps = [
  168. ":character_set",
  169. ":helpers",
  170. ":numeric_literal",
  171. ":string_literal",
  172. ":token_kind",
  173. ":tokenized_buffer",
  174. "//common:check",
  175. "//common:variant_helpers",
  176. "//toolchain/base:value_store",
  177. "//toolchain/diagnostics:diagnostic_emitter",
  178. "//toolchain/source:source_buffer",
  179. "@llvm-project//llvm:Support",
  180. ],
  181. )
  182. cc_library(
  183. name = "token_index",
  184. hdrs = ["token_index.h"],
  185. deps = [
  186. ":token_kind",
  187. "//toolchain/base:index_base",
  188. ],
  189. )
  190. cc_library(
  191. name = "tokenized_buffer",
  192. srcs = ["tokenized_buffer.cpp"],
  193. hdrs = ["tokenized_buffer.h"],
  194. deps = [
  195. ":character_set",
  196. ":helpers",
  197. ":numeric_literal",
  198. ":string_literal",
  199. ":token_index",
  200. ":token_kind",
  201. "//common:check",
  202. "//common:ostream",
  203. "//common:string_helpers",
  204. "//toolchain/base:index_base",
  205. "//toolchain/base:mem_usage",
  206. "//toolchain/base:value_store",
  207. "//toolchain/diagnostics:diagnostic_emitter",
  208. "//toolchain/source:source_buffer",
  209. "@llvm-project//llvm:Support",
  210. ],
  211. )
  212. cc_library(
  213. name = "tokenized_buffer_test_helpers",
  214. testonly = 1,
  215. hdrs = ["tokenized_buffer_test_helpers.h"],
  216. deps = [
  217. ":lex",
  218. ":tokenized_buffer",
  219. "//common:check",
  220. "//toolchain/base:value_store",
  221. "@googletest//:gtest",
  222. "@llvm-project//llvm:Support",
  223. ],
  224. )
  225. cc_test(
  226. name = "tokenized_buffer_test",
  227. size = "small",
  228. srcs = ["tokenized_buffer_test.cpp"],
  229. deps = [
  230. ":lex",
  231. ":token_kind",
  232. ":tokenized_buffer",
  233. ":tokenized_buffer_test_helpers",
  234. "//testing/base:gtest_main",
  235. "//testing/base:test_raw_ostream",
  236. "//toolchain/base:value_store",
  237. "//toolchain/diagnostics:diagnostic_emitter",
  238. "//toolchain/diagnostics:mocks",
  239. "//toolchain/testing:yaml_test_helpers",
  240. "@googletest//:gtest",
  241. "@llvm-project//llvm:Support",
  242. ],
  243. )
  244. cc_fuzz_test(
  245. name = "tokenized_buffer_fuzzer",
  246. size = "small",
  247. srcs = ["tokenized_buffer_fuzzer.cpp"],
  248. corpus = glob(["fuzzer_corpus/tokenized_buffer/*"]),
  249. deps = [
  250. ":lex",
  251. "//common:check",
  252. "//testing/fuzzing:libfuzzer_header",
  253. "//toolchain/base:value_store",
  254. "//toolchain/diagnostics:diagnostic_emitter",
  255. "//toolchain/diagnostics:null_diagnostics",
  256. "@llvm-project//llvm:Support",
  257. ],
  258. )
  259. cc_binary(
  260. name = "tokenized_buffer_benchmark",
  261. testonly = 1,
  262. srcs = ["tokenized_buffer_benchmark.cpp"],
  263. deps = [
  264. ":lex",
  265. ":token_kind",
  266. ":tokenized_buffer",
  267. "//common:check",
  268. "//testing/base:benchmark_main",
  269. "//testing/base:source_gen_lib",
  270. "//toolchain/base:value_store",
  271. "//toolchain/diagnostics:diagnostic_emitter",
  272. "//toolchain/diagnostics:null_diagnostics",
  273. "@abseil-cpp//absl/random",
  274. "@google_benchmark//:benchmark",
  275. "@llvm-project//llvm:Support",
  276. ],
  277. )