Debian Codegraph @

utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel

raw
1 # This file is licensed under the Apache License v2.0 with LLVM Exceptions.
2 # See https://llvm.org/LICENSE.txt for license information.
3 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5 load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
6
7 package(default_visibility = ["//visibility:public"])
8
9 licenses(["notice"])
10
11 cc_test(
12 name = "ast_tests",
13 size = "medium",
14 srcs = glob(
15 [
16 "AST/*.cpp",
17 "AST/*.h",
18 ],
19 allow_empty = False,
20 ),
21 shard_count = 20,
22 deps = [
23 "//clang:ast",
24 "//clang:ast_matchers",
25 "//clang:basic",
26 "//clang:frontend",
27 "//clang:lex",
28 "//clang:testing",
29 "//clang:tooling",
30 "//llvm:Core",
31 "//llvm:Support",
32 "//llvm:TargetParser",
33 "//llvm:TestingAnnotations",
34 "//llvm:TestingSupport",
35 "//third-party/unittest:gmock",
36 "//third-party/unittest:gtest",
37 "//third-party/unittest:gtest_main",
38 ],
39 )
40
41 cc_library(
42 name = "ast_matchers_tests_hdrs",
43 testonly = 1,
44 hdrs = glob(
45 ["ASTMatchers/*.h"],
46 allow_empty = False,
47 ),
48 deps = [
49 "//clang:ast_matchers",
50 "//clang:frontend",
51 "//clang:testing",
52 "//clang:tooling",
53 "//third-party/unittest:gtest",
54 ],
55 )
56
57 cc_test(
58 name = "ast_matchers_tests",
59 size = "medium",
60 srcs = glob(
61 ["ASTMatchers/*.cpp"],
62 allow_empty = False,
63 ),
64 shard_count = 20,
65 deps = [
66 ":ast_matchers_tests_hdrs",
67 "//clang:ast",
68 "//clang:ast_matchers",
69 "//clang:frontend",
70 "//clang:testing",
71 "//clang:tooling",
72 "//llvm:Support",
73 "//llvm:TargetParser",
74 "//llvm:TestingSupport",
75 "//third-party/unittest:gtest",
76 "//third-party/unittest:gtest_main",
77 ],
78 )
79
80 cc_test(
81 name = "ast_matchers_dynamic_tests",
82 size = "small",
83 srcs = glob(
84 ["ASTMatchers/Dynamic/*.cpp"],
85 allow_empty = False,
86 ),
87 deps = [
88 ":ast_matchers_tests_hdrs",
89 "//clang:ast_matchers",
90 "//clang:ast_matchers_dynamic",
91 "//clang:frontend",
92 "//clang:tooling",
93 "//llvm:Support",
94 "//third-party/unittest:gtest",
95 "//third-party/unittest:gtest_main",
96 ],
97 )
98
99 cc_library(
100 name = "dataflow_testing_support",
101 testonly = 1,
102 srcs = ["Analysis/FlowSensitive/TestingSupport.cpp"],
103 hdrs = ["Analysis/FlowSensitive/TestingSupport.h"],
104 deps = [
105 "//clang:analysis",
106 "//clang:ast",
107 "//clang:ast_matchers",
108 "//clang:basic",
109 "//clang:lex",
110 "//clang:serialization",
111 "//clang:tooling",
112 "//llvm:Support",
113 "//llvm:TestingAnnotations",
114 "//third-party/unittest:gtest",
115 ],
116 )
117
118 cc_library(
119 name = "dataflow_solver_test",
120 testonly = 1,
121 hdrs = ["Analysis/FlowSensitive/SolverTest.h"],
122 deps = [
123 ":dataflow_testing_support",
124 "//clang:analysis",
125 "//third-party/unittest:gmock",
126 "//third-party/unittest:gtest",
127 ],
128 )
129
130 cc_test(
131 name = "analysis_tests",
132 size = "small",
133 srcs = glob(
134 [
135 "Analysis/*.cpp",
136 "Analysis/*.h",
137 ],
138 allow_empty = False,
139 ),
140 deps = [
141 "//clang:analysis",
142 "//clang:ast",
143 "//clang:ast_matchers",
144 "//clang:basic",
145 "//clang:frontend",
146 "//clang:lex",
147 "//clang:parse",
148 "//clang:testing",
149 "//clang:tooling",
150 "//llvm:Support",
151 "//llvm:TestingSupport",
152 "//third-party/unittest:gmock",
153 "//third-party/unittest:gtest",
154 "//third-party/unittest:gtest_main",
155 ],
156 )
157
158 cc_test(
159 name = "analysis_flow_sensitive_tests",
160 srcs = glob(
161 [
162 "Analysis/FlowSensitive/*.cpp",
163 "Analysis/FlowSensitive/*.h",
164 ],
165 allow_empty = False,
166 ),
167 deps = [
168 "//clang:analysis",
169 "//clang:ast",
170 "//clang:ast_matchers",
171 "//clang:basic",
172 "//clang:frontend",
173 "//clang:lex",
174 "//clang:serialization",
175 "//clang:testing",
176 "//clang:tooling",
177 "//llvm:Support",
178 "//llvm:TestingADT",
179 "//llvm:TestingAnnotations",
180 "//llvm:TestingSupport",
181 "//third-party/unittest:gmock",
182 "//third-party/unittest:gtest",
183 "//third-party/unittest:gtest_main",
184 ],
185 )
186
187 cc_test(
188 name = "basic_tests",
189 size = "small",
190 srcs = glob(
191 ["Basic/*.cpp"],
192 allow_empty = False,
193 ),
194 deps = [
195 "//clang:basic",
196 "//clang:frontend",
197 "//clang:lex",
198 "//llvm:Support",
199 "//llvm:TestingSupport",
200 "//llvm:config",
201 "//third-party/unittest:gmock",
202 "//third-party/unittest:gtest",
203 "//third-party/unittest:gtest_main",
204 ],
205 )
206
207 cc_test(
208 name = "codegen_tests",
209 size = "small",
210 srcs = glob(
211 [
212 "CodeGen/*.cpp",
213 "CodeGen/*.h",
214 ],
215 allow_empty = False,
216 ),
217 deps = [
218 "//clang:ast",
219 "//clang:basic",
220 "//clang:codegen",
221 "//clang:frontend",
222 "//clang:lex",
223 "//clang:parse",
224 "//clang:sema",
225 "//llvm:Core",
226 "//llvm:Support",
227 "//llvm:TargetParser",
228 "//third-party/unittest:gtest",
229 "//third-party/unittest:gtest_main",
230 ],
231 )
232
233 cc_test(
234 name = "format_tests",
235 size = "medium",
236 srcs = glob(
237 [
238 "Format/*.cpp",
239 "Format/*.h",
240 ],
241 allow_empty = False,
242 ),
243 copts = ["$(STACK_FRAME_UNLIMITED)"],
244 features = ["-layering_check"], # #include "../../lib/Format/TokenAnalyzer.h"
245 shard_count = 20,
246 deps = [
247 ":tooling_tests_hdrs",
248 "//clang:basic",
249 "//clang:format",
250 "//clang:frontend",
251 "//clang:tooling_core",
252 "//llvm:Support",
253 "//third-party/unittest:gmock",
254 "//third-party/unittest:gtest",
255 "//third-party/unittest:gtest_main",
256 ],
257 )
258
259 cc_test(
260 name = "frontend_tests",
261 size = "small",
262 srcs = glob(
263 ["Frontend/*.cpp"],
264 allow_empty = False,
265 ),
266 deps = [
267 "//clang:ast",
268 "//clang:basic",
269 "//clang:codegen",
270 "//clang:driver",
271 "//clang:driver_options_inc_gen",
272 "//clang:frontend",
273 "//clang:frontend_tool",
274 "//clang:lex",
275 "//clang:sema",
276 "//clang:serialization",
277 "//clang:tooling",
278 "//llvm:Option",
279 "//llvm:Support",
280 "//llvm:TargetParser",
281 "//third-party/unittest:gmock",
282 "//third-party/unittest:gtest",
283 "//third-party/unittest:gtest_main",
284 ],
285 )
286
287 cc_test(
288 name = "lex_tests",
289 size = "small",
290 srcs = glob(
291 [
292 "Lex/*.cpp",
293 "Lex/*.h",
294 ],
295 allow_empty = False,
296 ),
297 copts = ["$(STACK_FRAME_UNLIMITED)"],
298 deps = [
299 "//clang:ast",
300 "//clang:basic",
301 "//clang:frontend",
302 "//clang:lex",
303 "//clang:parse",
304 "//clang:sema",
305 "//clang:serialization",
306 "//llvm:Support",
307 "//llvm:TestingAnnotations",
308 "//llvm:TestingSupport",
309 "//third-party/unittest:gmock",
310 "//third-party/unittest:gtest",
311 "//third-party/unittest:gtest_main",
312 ],
313 )
314
315 cc_test(
316 name = "rewrite_tests",
317 size = "small",
318 srcs = glob(
319 ["Rewrite/*.cpp"],
320 allow_empty = False,
321 ),
322 deps = [
323 "//clang:rewrite",
324 "//clang:tooling",
325 "//third-party/unittest:gtest",
326 "//third-party/unittest:gtest_main",
327 ],
328 )
329
330 cc_test(
331 name = "sema_tests",
332 size = "small",
333 srcs = glob(
334 ["Sema/*.cpp"],
335 allow_empty = False,
336 ),
337 deps = [
338 ":ast_matchers_tests_hdrs",
339 "//clang:ast",
340 "//clang:ast_matchers",
341 "//clang:basic",
342 "//clang:driver",
343 "//clang:frontend",
344 "//clang:lex",
345 "//clang:parse",
346 "//clang:sema",
347 "//clang:tooling",
348 "//llvm:TestingAnnotations",
349 "//llvm:TestingSupport",
350 "//third-party/unittest:gmock",
351 "//third-party/unittest:gtest",
352 "//third-party/unittest:gtest_main",
353 ],
354 )
355
356 cc_library(
357 name = "static_analyzer_test_headers",
358 testonly = 1,
359 hdrs = glob(
360 ["StaticAnalyzer/*.h"],
361 allow_empty = False,
362 ),
363 deps = [
364 "//clang:analysis",
365 "//clang:ast_matchers",
366 "//clang:crosstu",
367 "//clang:frontend",
368 "//clang:static_analyzer_core",
369 "//clang:static_analyzer_frontend",
370 "//clang:tooling",
371 "//third-party/unittest:gtest",
372 ],
373 )
374
375 cc_test(
376 name = "static_analyzer_tests",
377 size = "small",
378 srcs = glob(
379 ["StaticAnalyzer/*.cpp"],
380 allow_empty = False,
381 exclude = [
382 # New test has unused-variable warnings.
383 "StaticAnalyzer/ParamRegionTest.cpp",
384 ],
385 ),
386 deps = [
387 ":static_analyzer_test_headers",
388 "//clang:analysis",
389 "//clang:ast",
390 "//clang:ast_matchers",
391 "//clang:basic",
392 "//clang:frontend",
393 "//clang:static_analyzer_core",
394 "//clang:static_analyzer_frontend",
395 "//clang:testing",
396 "//clang:tooling",
397 "//llvm:Support",
398 "//llvm:config",
399 "//third-party/unittest:gtest",
400 "//third-party/unittest:gtest_main",
401 ],
402 )
403
404 cc_library(
405 name = "tooling_tests_hdrs",
406 testonly = 1,
407 hdrs = glob(
408 ["Tooling/*.h"],
409 allow_empty = False,
410 ),
411 deps = [
412 "//clang:ast",
413 "//clang:basic",
414 "//clang:frontend",
415 "//clang:rewrite",
416 "//clang:tooling",
417 "//clang:tooling_core",
418 "//llvm:Support",
419 "//third-party/unittest:gtest",
420 ],
421 )
422
423 cc_test(
424 name = "tooling_tests",
425 size = "medium",
426 srcs = glob(
427 ["Tooling/*.cpp"],
428 allow_empty = False,
429 ),
430 shard_count = 20,
431 deps = [
432 ":tooling_tests_hdrs",
433 "//clang:ast",
434 "//clang:ast_matchers",
435 "//clang:basic",
436 "//clang:dependency_scanning",
437 "//clang:driver",
438 "//clang:format",
439 "//clang:frontend",
440 "//clang:lex",
441 "//clang:rewrite",
442 "//clang:testing",
443 "//clang:tooling",
444 "//clang:tooling_core",
445 "//clang:tooling_inclusions",
446 "//clang:tooling_refactoring",
447 "//clang:transformer",
448 "//llvm:MC",
449 "//llvm:Support",
450 "//llvm:TargetParser",
451 "//llvm:TestingAnnotations",
452 "//llvm:TestingSupport",
453 "//third-party/unittest:gmock",
454 "//third-party/unittest:gtest",
455 "//third-party/unittest:gtest_main",
456 ],
457 )
458
459 # A library to carefully expose the tooling headers using the include prefix
460 # expected by the `tooling_recursive_ast_visitor_tests`.
461 cc_library(
462 name = "tooling_recursive_ast_visitor_tests_tooling_hdrs",
463 testonly = 1,
464 hdrs = glob(
465 ["Tooling/*.h"],
466 allow_empty = False,
467 ),
468 strip_include_prefix = "Tooling",
469 deps = [
470 "//clang:ast",
471 "//clang:basic",
472 "//clang:frontend",
473 "//clang:rewrite",
474 "//clang:tooling",
475 "//clang:tooling_core",
476 "//llvm:Support",
477 "//third-party/unittest:gtest",
478 ],
479 )
480
481 cc_test(
482 name = "tooling_recursive_ast_visitor_tests",
483 size = "medium",
484 srcs = glob(
485 ["Tooling/RecursiveASTVisitorTests/*.cpp"],
486 allow_empty = False,
487 ) + [
488 "Tooling/RecursiveASTVisitorTests/CallbacksCommon.h",
489 ],
490 deps = [
491 ":tooling_recursive_ast_visitor_tests_tooling_hdrs",
492 "//clang:ast",
493 "//clang:basic",
494 "//clang:frontend",
495 "//clang:lex",
496 "//clang:tooling",
497 "//clang:tooling_syntax",
498 "//llvm:Support",
499 "//llvm:TargetParser",
500 "//llvm:TestingSupport",
501 "//third-party/unittest:gmock",
502 "//third-party/unittest:gtest",
503 "//third-party/unittest:gtest_main",
504 ],
505 )
506
507 cc_test(
508 name = "tooling_syntax_tests",
509 size = "medium",
510 srcs = glob(
511 [
512 "Tooling/Syntax/*.cpp",
513 "Tooling/Syntax/*.h",
514 ],
515 allow_empty = False,
516 ),
517 shard_count = 20,
518 deps = [
519 "//clang:ast",
520 "//clang:basic",
521 "//clang:driver",
522 "//clang:frontend",
523 "//clang:lex",
524 "//clang:testing",
525 "//clang:tooling",
526 "//clang:tooling_core",
527 "//clang:tooling_syntax",
528 "//llvm:Support",
529 "//llvm:TestingAnnotations",
530 "//llvm:TestingSupport",
531 "//third-party/unittest:gmock",
532 "//third-party/unittest:gtest",
533 "//third-party/unittest:gtest_main",
534 ],
535 )
536
537 cc_test(
538 name = "libclang_tests",
539 size = "small",
540 srcs = glob(
541 ["libclang/*.cpp"],
542 allow_empty = False,
543 ) + [
544 "libclang/TestUtils.h",
545 ],
546 args = select({
547 "@platforms//os:windows": [
548 # Need to disable the VFS tests that don't use Windows friendly
549 # paths. These are also disabled on Windows in the CMake build.
550 "--gtest_filter=-*VirtualFileOverlay*",
551 ],
552 "//conditions:default": [],
553 }),
554 deps = [
555 "//clang:libclang",
556 "//llvm:Support",
557 "//third-party/unittest:gtest",
558 "//third-party/unittest:gtest_main",
559 ],
560 )
561
562 cc_test(
563 name = "crosstu_tests",
564 size = "small",
565 srcs = glob(
566 ["CrossTU/*.cpp"],
567 allow_empty = False,
568 ),
569 deps = [
570 "//clang:ast",
571 "//clang:crosstu",
572 "//clang:frontend",
573 "//clang:tooling",
574 "//llvm:Support",
575 "//third-party/unittest:gtest",
576 "//third-party/unittest:gtest_main",
577 ],
578 )
579
580 cc_test(
581 name = "driver_tests",
582 size = "small",
583 srcs = glob(
584 [
585 "Driver/*.cpp",
586 "Driver/*.h",
587 ],
588 allow_empty = False,
589 exclude = [
590 "Driver/GCCVersionTest.cpp", # Includes private headers
591 ],
592 ),
593 deps = [
594 "//clang:basic",
595 "//clang:driver",
596 "//clang:frontend",
597 "//llvm:FrontendDebug",
598 "//llvm:MC",
599 "//llvm:Support",
600 "//llvm:TargetParser",
601 "//third-party/unittest:gmock",
602 "//third-party/unittest:gtest",
603 "//third-party/unittest:gtest_main",
604 ],
605 )
606
607 cc_test(
608 name = "parse_tests",
609 size = "small",
610 srcs = glob(
611 ["Parse/*.cpp"],
612 allow_empty = False,
613 ),
614 deps = [
615 "//clang:ast",
616 "//clang:basic",
617 "//clang:lex",
618 "//clang:parse",
619 "//third-party/unittest:gtest",
620 "//third-party/unittest:gtest_main",
621 ],
622 )
623
624 cc_test(
625 name = "directory_watcher_tests",
626 size = "small",
627 srcs = glob(
628 ["DirectoryWatcher/*.cpp"],
629 allow_empty = False,
630 ),
631 deps = [
632 "//clang:directory_watcher",
633 "//llvm:Support",
634 "//llvm:TestingSupport",
635 "//third-party/unittest:gtest",
636 "//third-party/unittest:gtest_main",
637 ],
638 )
639
640 cc_test(
641 name = "index_tests",
642 size = "small",
643 srcs = glob(
644 ["Index/*.cpp"],
645 allow_empty = False,
646 ),
647 deps = [
648 "//clang:ast",
649 "//clang:basic",
650 "//clang:frontend",
651 "//clang:index",
652 "//clang:lex",
653 "//clang:tooling",
654 "//llvm:Support",
655 "//third-party/unittest:gmock",
656 "//third-party/unittest:gtest",
657 "//third-party/unittest:gtest_main",
658 ],
659 )
660
661 cc_test(
662 name = "install_api_tests",
663 size = "small",
664 srcs = glob(
665 ["InstallAPI/*.cpp"],
666 allow_empty = False,
667 ),
668 deps = [
669 "//clang:install_api",
670 "//llvm:Support",
671 "//llvm:TestingSupport",
672 "//third-party/unittest:gtest",
673 "//third-party/unittest:gtest_main",
674 ],
675 )
676
677 cc_test(
678 name = "interpreter_tests",
679 size = "small",
680 srcs = glob(
681 [
682 "Interpreter/*.cpp",
683 "Interpreter/*.h",
684 ],
685 allow_empty = False,
686 ),
687 args = [
688 # TODO: some tests fail with: "JIT session error: Symbols not found:
689 # [ _ZnwmPv26__clang_Interpreter_NewTag, __clang_Interpreter_SetValueWithAlloc ]
690 "--gtest_filter=-InterpreterTest.*:OutOfProcessInterpreterTest.*",
691 ],
692 deps = [
693 "//clang:ast",
694 "//clang:basic",
695 "//clang:codegen",
696 "//clang:config",
697 "//clang:frontend",
698 "//clang:interpreter",
699 "//clang:lex",
700 "//clang:parse",
701 "//clang:sema",
702 "//llvm:LineEditor",
703 "//llvm:MC",
704 "//llvm:OrcJIT",
705 "//llvm:OrcShared",
706 "//llvm:Support",
707 "//llvm:TargetParser",
708 "//llvm:TestingSupport",
709 "//llvm:ir_headers",
710 "//third-party/unittest:gmock",
711 "//third-party/unittest:gtest",
712 "//third-party/unittest:gtest_main",
713 ],
714 )
715
716 cc_test(
717 name = "serialization_tests",
718 size = "small",
719 srcs = glob(
720 ["Serialization/*.cpp"],
721 allow_empty = False,
722 ),
723 deps = [
724 "//clang:ast_matchers",
725 "//clang:basic",
726 "//clang:driver",
727 "//clang:frontend",
728 "//clang:lex",
729 "//clang:parse",
730 "//clang:serialization",
731 "//clang:tooling",
732 "//llvm:Support",
733 "//third-party/unittest:gtest",
734 "//third-party/unittest:gtest_main",
735 ],
736 )
737
738 cc_test(
739 name = "support_tests",
740 size = "small",
741 srcs = glob(
742 ["Support/*.cpp"],
743 allow_empty = False,
744 ),
745 deps = [
746 "//clang:frontend",
747 "//clang:lex",
748 "//llvm:Support",
749 "//third-party/unittest:gtest",
750 "//third-party/unittest:gtest_main",
751 ],
752 )