[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / utils / bazel / llvm-project-overlay / clang / BUILD.bazel
blob43b251d9482e274a6dbdf1a36b06e87dbf841267
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
5 load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
6 load("//:workspace_root.bzl", "workspace_root")
7 load("//llvm:tblgen.bzl", "gentbl")
8 load("//llvm:binary_alias.bzl", "binary_alias")
9 load("//llvm:cc_plugin_library.bzl", "cc_plugin_library")
10 load(
11     "//:vars.bzl",
12     "LLVM_VERSION",
13     "LLVM_VERSION_MAJOR",
14     "LLVM_VERSION_MINOR",
15     "LLVM_VERSION_PATCH",
18 package(
19     default_visibility = ["//visibility:public"],
20     features = ["layering_check"],
23 licenses(["notice"])
25 exports_files([
26     "tools/clang-format/clang-format.el",
27     "tools/clang-format/clang-format-test.el",
28     "tools/clang-format/clang-format.py",
29     "tools/clang-rename/clang-rename.el",
30     "tools/extra/clang-include-fixer/tool/clang-include-fixer.el",
31     "tools/extra/clang-include-fixer/tool/clang-include-fixer-test.el",
34 cc_binary(
35     name = "clang-tblgen",
36     srcs = glob([
37         "utils/TableGen/*.cpp",
38         "utils/TableGen/*.h",
39     ]),
40     copts = [
41         "$(STACK_FRAME_UNLIMITED)",
42     ],
43     stamp = 0,
44     deps = [
45         ":support",
46         "//llvm:Support",
47         "//llvm:TableGen",
48         "//llvm:config",
49     ],
52 gentbl(
53     name = "diagnostic_defs_gen",
54     tbl_outs = [(
55         "-gen-clang-diags-defs -clang-component=%s" % c,
56         "include/clang/Basic/Diagnostic%sKinds.inc" % c,
57     ) for c in [
58         "AST",
59         "Analysis",
60         "Comment",
61         "Common",
62         "CrossTU",
63         "Driver",
64         "Frontend",
65         "Lex",
66         "Parse",
67         "Refactoring",
68         "Sema",
69         "Serialization",
70     ]] + [
71         (
72             "-gen-clang-diag-groups",
73             "include/clang/Basic/DiagnosticGroups.inc",
74         ),
75         (
76             "-gen-clang-diags-index-name",
77             "include/clang/Basic/DiagnosticIndexName.inc",
78         ),
79     ],
80     tblgen = ":clang-tblgen",
81     td_file = "include/clang/Basic/Diagnostic.td",
82     td_srcs = glob(["include/clang/Basic/*.td"]),
85 gentbl(
86     name = "basic_arm_neon_inc_gen",
87     tbl_outs = [(
88         "-gen-arm-neon-sema",
89         "include/clang/Basic/arm_neon.inc",
90     )],
91     tblgen = ":clang-tblgen",
92     td_file = "include/clang/Basic/arm_neon.td",
93     td_srcs = [
94         "include/clang/Basic/arm_neon.td",
95         "include/clang/Basic/arm_neon_incl.td",
96     ],
99 gentbl(
100     name = "basic_arm_fp16_inc_gen",
101     tbl_outs = [(
102         "-gen-arm-neon-sema",
103         "include/clang/Basic/arm_fp16.inc",
104     )],
105     tblgen = ":clang-tblgen",
106     td_file = "include/clang/Basic/arm_fp16.td",
107     td_srcs = [
108         "include/clang/Basic/arm_fp16.td",
109         "include/clang/Basic/arm_neon_incl.td",
110     ],
113 gentbl(
114     name = "basic_arm_mve_aliases_gen",
115     tbl_outs = [(
116         "-gen-arm-mve-builtin-aliases",
117         "include/clang/Basic/arm_mve_builtin_aliases.inc",
118     )],
119     tblgen = ":clang-tblgen",
120     td_file = "include/clang/Basic/arm_mve.td",
121     td_srcs = [
122         "include/clang/Basic/arm_mve.td",
123         "include/clang/Basic/arm_mve_defs.td",
124     ],
127 gentbl(
128     name = "basic_arm_sve_builtins_gen",
129     tbl_outs = [(
130         "-gen-arm-sve-builtins",
131         "include/clang/Basic/arm_sve_builtins.inc",
132     )],
133     tblgen = ":clang-tblgen",
134     td_file = "include/clang/Basic/arm_sve.td",
135     td_srcs = [
136         "include/clang/Basic/arm_sve.td",
137         "include/clang/Basic/arm_sve_sme_incl.td",
138     ],
141 gentbl(
142     name = "basic_arm_sve_builtin_cg_gen",
143     tbl_outs = [(
144         "-gen-arm-sve-builtin-codegen",
145         "include/clang/Basic/arm_sve_builtin_cg.inc",
146     )],
147     tblgen = ":clang-tblgen",
148     td_file = "include/clang/Basic/arm_sve.td",
149     td_srcs = [
150         "include/clang/Basic/arm_sve.td",
151         "include/clang/Basic/arm_sve_sme_incl.td",
152     ],
155 gentbl(
156     name = "basic_arm_sve_typeflags_gen",
157     tbl_outs = [(
158         "-gen-arm-sve-typeflags",
159         "include/clang/Basic/arm_sve_typeflags.inc",
160     )],
161     tblgen = ":clang-tblgen",
162     td_file = "include/clang/Basic/arm_sve.td",
163     td_srcs = [
164         "include/clang/Basic/arm_sve.td",
165         "include/clang/Basic/arm_sve_sme_incl.td",
166     ],
169 gentbl(
170     name = "basic_arm_sve_sema_rangechecks_gen",
171     tbl_outs = [(
172         "-gen-arm-sve-sema-rangechecks",
173         "include/clang/Basic/arm_sve_sema_rangechecks.inc",
174     )],
175     tblgen = ":clang-tblgen",
176     td_file = "include/clang/Basic/arm_sve.td",
177     td_srcs = [
178         "include/clang/Basic/arm_sve.td",
179         "include/clang/Basic/arm_sve_sme_incl.td",
180     ],
183 gentbl(
184     name = "basic_arm_sme_builtins_gen",
185     tbl_outs = [(
186         "-gen-arm-sme-builtins",
187         "include/clang/Basic/arm_sme_builtins.inc",
188     )],
189     tblgen = ":clang-tblgen",
190     td_file = "include/clang/Basic/arm_sme.td",
191     td_srcs = [
192         "include/clang/Basic/arm_sme.td",
193         "include/clang/Basic/arm_sve_sme_incl.td",
194     ],
197 gentbl(
198     name = "basic_arm_sme_builtin_cg_gen",
199     tbl_outs = [(
200         "-gen-arm-sme-builtin-codegen",
201         "include/clang/Basic/arm_sme_builtin_cg.inc",
202     )],
203     tblgen = ":clang-tblgen",
204     td_file = "include/clang/Basic/arm_sme.td",
205     td_srcs = [
206         "include/clang/Basic/arm_sme.td",
207         "include/clang/Basic/arm_sve_sme_incl.td",
208     ],
211 gentbl(
212     name = "basic_arm_sme_sema_rangechecks_gen",
213     tbl_outs = [(
214         "-gen-arm-sme-sema-rangechecks",
215         "include/clang/Basic/arm_sme_sema_rangechecks.inc",
216     )],
217     tblgen = ":clang-tblgen",
218     td_file = "include/clang/Basic/arm_sme.td",
219     td_srcs = [
220         "include/clang/Basic/arm_sme.td",
221         "include/clang/Basic/arm_sve_sme_incl.td",
222     ],
225 gentbl(
226     name = "basic_arm_mve_cg_gen",
227     tbl_outs = [(
228         "-gen-arm-mve-builtin-codegen",
229         "include/clang/Basic/arm_mve_builtin_cg.inc",
230     )],
231     tblgen = ":clang-tblgen",
232     td_file = "include/clang/Basic/arm_mve.td",
233     td_srcs = [
234         "include/clang/Basic/arm_mve.td",
235         "include/clang/Basic/arm_mve_defs.td",
236     ],
239 gentbl(
240     name = "basic_arm_mve_inc_gen",
241     tbl_outs = [(
242         "-gen-arm-mve-builtin-def",
243         "include/clang/Basic/arm_mve_builtins.inc",
244     )],
245     tblgen = ":clang-tblgen",
246     td_file = "include/clang/Basic/arm_mve.td",
247     td_srcs = [
248         "include/clang/Basic/arm_mve.td",
249         "include/clang/Basic/arm_mve_defs.td",
250     ],
253 gentbl(
254     name = "basic_arm_mve_sema_gen",
255     tbl_outs = [(
256         "-gen-arm-mve-builtin-sema",
257         "include/clang/Basic/arm_mve_builtin_sema.inc",
258     )],
259     tblgen = ":clang-tblgen",
260     td_file = "include/clang/Basic/arm_mve.td",
261     td_srcs = [
262         "include/clang/Basic/arm_mve.td",
263         "include/clang/Basic/arm_mve_defs.td",
264     ],
267 gentbl(
268     name = "basic_riscv_vector_builtins_gen",
269     tbl_outs = [(
270         "-gen-riscv-vector-builtins",
271         "include/clang/Basic/riscv_vector_builtins.inc",
272     )],
273     tblgen = ":clang-tblgen",
274     td_file = "include/clang/Basic/riscv_vector.td",
275     td_srcs = [
276         "include/clang/Basic/riscv_vector.td",
277         "include/clang/Basic/riscv_vector_common.td",
278     ],
281 gentbl(
282     name = "basic_riscv_vector_builtin_cg_gen",
283     tbl_outs = [(
284         "-gen-riscv-vector-builtin-codegen",
285         "include/clang/Basic/riscv_vector_builtin_cg.inc",
286     )],
287     tblgen = ":clang-tblgen",
288     td_file = "include/clang/Basic/riscv_vector.td",
289     td_srcs = [
290         "include/clang/Basic/riscv_vector.td",
291         "include/clang/Basic/riscv_vector_common.td",
292     ],
295 gentbl(
296     name = "basic_riscv_vector_builtin_sema_gen",
297     tbl_outs = [(
298         "-gen-riscv-vector-builtin-sema",
299         "include/clang/Basic/riscv_vector_builtin_sema.inc",
300     )],
301     tblgen = ":clang-tblgen",
302     td_file = "include/clang/Basic/riscv_vector.td",
303     td_srcs = [
304         "include/clang/Basic/riscv_vector.td",
305         "include/clang/Basic/riscv_vector_common.td",
306     ],
309 gentbl(
310     name = "basic_riscv_sifive_vector_builtins_gen",
311     tbl_outs = [(
312         "-gen-riscv-sifive-vector-builtins",
313         "include/clang/Basic/riscv_sifive_vector_builtins.inc",
314     )],
315     tblgen = ":clang-tblgen",
316     td_file = "include/clang/Basic/riscv_sifive_vector.td",
317     td_srcs = [
318         "include/clang/Basic/riscv_sifive_vector.td",
319         "include/clang/Basic/riscv_vector_common.td",
320     ],
323 gentbl(
324     name = "basic_riscv_sifive_vector_builtin_cg_gen",
325     tbl_outs = [(
326         "-gen-riscv-sifive-vector-builtin-codegen",
327         "include/clang/Basic/riscv_sifive_vector_builtin_cg.inc",
328     )],
329     tblgen = ":clang-tblgen",
330     td_file = "include/clang/Basic/riscv_sifive_vector.td",
331     td_srcs = [
332         "include/clang/Basic/riscv_sifive_vector.td",
333         "include/clang/Basic/riscv_vector_common.td",
334     ],
337 gentbl(
338     name = "basic_riscv_sifive_vector_builtin_sema_gen",
339     tbl_outs = [(
340         "-gen-riscv-sifive-vector-builtin-sema",
341         "include/clang/Basic/riscv_sifive_vector_builtin_sema.inc",
342     )],
343     tblgen = ":clang-tblgen",
344     td_file = "include/clang/Basic/riscv_sifive_vector.td",
345     td_srcs = [
346         "include/clang/Basic/riscv_sifive_vector.td",
347         "include/clang/Basic/riscv_vector_common.td",
348     ],
351 gentbl(
352     name = "basic_arm_cde_gen",
353     tbl_outs = [(
354         "-gen-arm-cde-builtin-def",
355         "include/clang/Basic/arm_cde_builtins.inc",
356     )],
357     tblgen = ":clang-tblgen",
358     td_file = "include/clang/Basic/arm_cde.td",
359     td_srcs = [
360         "include/clang/Basic/arm_cde.td",
361         "include/clang/Basic/arm_mve_defs.td",
362     ],
365 gentbl(
366     name = "basic_arm_cde_aliases_gen",
367     tbl_outs = [(
368         "-gen-arm-cde-builtin-aliases",
369         "include/clang/Basic/arm_cde_builtin_aliases.inc",
370     )],
371     tblgen = ":clang-tblgen",
372     td_file = "include/clang/Basic/arm_cde.td",
373     td_srcs = [
374         "include/clang/Basic/arm_cde.td",
375         "include/clang/Basic/arm_mve_defs.td",
376     ],
379 gentbl(
380     name = "basic_arm_cde_cg_gen",
381     tbl_outs = [(
382         "-gen-arm-cde-builtin-codegen",
383         "include/clang/Basic/arm_cde_builtin_cg.inc",
384     )],
385     tblgen = ":clang-tblgen",
386     td_file = "include/clang/Basic/arm_cde.td",
387     td_srcs = [
388         "include/clang/Basic/arm_cde.td",
389         "include/clang/Basic/arm_mve_defs.td",
390     ],
393 gentbl(
394     name = "basic_arm_cde_sema_gen",
395     tbl_outs = [(
396         "-gen-arm-cde-builtin-sema",
397         "include/clang/Basic/arm_cde_builtin_sema.inc",
398     )],
399     tblgen = ":clang-tblgen",
400     td_file = "include/clang/Basic/arm_cde.td",
401     td_srcs = [
402         "include/clang/Basic/arm_cde.td",
403         "include/clang/Basic/arm_mve_defs.td",
404     ],
407 gentbl(
408     name = "basic_attr_gen",
409     tbl_outs = [
410         (
411             "-gen-clang-attr-has-attribute-impl",
412             "include/clang/Basic/AttrHasAttributeImpl.inc",
413         ),
414         (
415             "-gen-clang-attr-list",
416             "include/clang/Basic/AttrList.inc",
417         ),
418         (
419             "-gen-clang-attr-subject-match-rule-list",
420             "include/clang/Basic/AttrSubMatchRulesList.inc",
421         ),
422         (
423             "-gen-clang-attr-token-kinds",
424             "include/clang/Basic/AttrTokenKinds.inc",
425         ),
426     ],
427     tblgen = ":clang-tblgen",
428     td_file = "include/clang/Basic/Attr.td",
429     td_srcs = [
430         "include/clang/Basic/ASTNode.td",
431         "include/clang/Basic/Attr.td",
432         "include/clang/Basic/AttrDocs.td",
433         "include/clang/Basic/DeclNodes.td",
434         "include/clang/Basic/StmtNodes.td",
435     ],
438 gentbl(
439     name = "libsema_openclbuiltins_inc_gen",
440     strip_include_prefix = "lib/Sema",
441     tbl_outs = [(
442         "-gen-clang-opencl-builtins",
443         "lib/Sema/OpenCLBuiltins.inc",
444     )],
445     tblgen = ":clang-tblgen",
446     td_file = "lib/Sema/OpenCLBuiltins.td",
447     td_srcs = [
448         "lib/Sema/OpenCLBuiltins.td",
449     ],
452 # Table definition files can be used for documentation:
453 filegroup(
454     name = "all_table_defs",
455     srcs = glob(["include/**/*.td"]),
458 exports_files(
459     glob(["include/**/*.td"]),
462 genrule(
463     name = "basic_version_gen",
464     outs = ["include/clang/Basic/Version.inc"],
465     cmd = (
466         "echo '#define CLANG_VERSION {vers}' >> $@\n" +
467         "echo '#define CLANG_VERSION_MAJOR {major}' >> $@\n" +
468         "echo '#define CLANG_VERSION_MAJOR_STRING \"{major}\"' >> $@\n" +
469         "echo '#define CLANG_VERSION_MINOR {minor}' >> $@\n" +
470         "echo '#define CLANG_VERSION_PATCHLEVEL {patch}' >> $@\n" +
471         "echo '#define CLANG_VERSION_STRING \"{vers}\"' >> $@\n"
472     ).format(
473         major = LLVM_VERSION_MAJOR,
474         minor = LLVM_VERSION_MINOR,
475         patch = LLVM_VERSION_PATCH,
476         vers = LLVM_VERSION,
477     ),
480 cc_library(
481     name = "config",
482     hdrs = [
483         "include/clang/Basic/Version.inc",
484         "include/clang/Config/config.h",
485     ],
486     includes = ["include"],
487     deps = [
488         # We rely on the LLVM config library to provide configuration defines.
489         "//llvm:config",
490     ],
493 # TODO: This should get replaced with something that actually generates the
494 # correct version number.
495 genrule(
496     name = "vcs_version_gen",
497     # This should be under lib/Basic, but because of how the include paths
498     # are passed through bazel, it's easier to drop generated files next to
499     # the other includes.
500     outs = ["include/VCSVersion.inc"],
501     cmd = "echo '#undef CLANG_REVISION' > $@",
504 py_binary(
505     name = "bundle_resources",
506     srcs = [
507         "utils/bundle_resources.py",
508     ],
509     main = "utils/bundle_resources.py",
512 # A hacky library to expose some internal headers of the `basic` library to its
513 # own implementation source files using a stripped include prefix rather than
514 # file-relative-inclusion. This is inherently non-modular as these headers will
515 # be repeated in the sources below for file-relative-inclusion.
516 cc_library(
517     name = "basic_internal_headers",
518     hdrs = glob([
519         "lib/Basic/*.h",
520     ]),
521     features = ["-header_modules"],
522     strip_include_prefix = "lib/Basic",
525 cc_library(
526     name = "basic",
527     srcs = [
528         "include/VCSVersion.inc",
529         "include/clang/Basic/Version.inc",
530     ] + glob([
531         "lib/Basic/*.cpp",
532         "lib/Basic/*.c",
533         "lib/Basic/*.h",
534         "lib/Basic/Targets/*.cpp",
535         "lib/Basic/Targets/*.h",
536     ]),
537     hdrs = glob([
538         "include/clang/Basic/*.h",
539     ]),
540     copts = [
541         "-DHAVE_VCS_VERSION_INC",
542         "$(STACK_FRAME_UNLIMITED)",
543     ],
544     includes = ["include"],
545     textual_hdrs = [
546         "include/clang/Basic/arm_fp16.inc",
547         "include/clang/Basic/arm_mve_builtins.inc",
548         "include/clang/Basic/arm_mve_builtin_aliases.inc",
549         "include/clang/Basic/arm_mve_builtin_cg.inc",
550         "include/clang/Basic/arm_mve_builtin_sema.inc",
551         "include/clang/Basic/arm_sme_builtins.inc",
552         "include/clang/Basic/arm_sme_builtin_cg.inc",
553         "include/clang/Basic/arm_neon.inc",
554         "include/clang/Basic/AttrHasAttributeImpl.inc",
555         "include/clang/Basic/AttrList.inc",
556         "include/clang/Basic/AttrSubMatchRulesList.inc",
557         "include/clang/Basic/DiagnosticASTKinds.inc",
558         "include/clang/Basic/DiagnosticGroups.inc",
559         "include/clang/Basic/DiagnosticRefactoringKinds.inc",
560         "include/clang/Basic/DiagnosticAnalysisKinds.inc",
561         "include/clang/Basic/DiagnosticSemaKinds.inc",
562         "include/clang/Basic/DiagnosticCommentKinds.inc",
563         "include/clang/Basic/DiagnosticParseKinds.inc",
564         "include/clang/Basic/DiagnosticLexKinds.inc",
565         "include/clang/Basic/DiagnosticSerializationKinds.inc",
566         "include/clang/Basic/DiagnosticFrontendKinds.inc",
567         "include/clang/Basic/DiagnosticDriverKinds.inc",
568         "include/clang/Basic/DiagnosticCrossTUKinds.inc",
569         "include/clang/Basic/DiagnosticCommonKinds.inc",
570         "include/clang/Basic/DiagnosticIndexName.inc",
571     ] + glob([
572         "include/clang/Basic/*.def",
573     ]),
574     deps = [
575         ":basic_arm_cde_gen",
576         ":basic_arm_fp16_inc_gen",
577         ":basic_arm_mve_aliases_gen",
578         ":basic_arm_mve_cg_gen",
579         ":basic_arm_mve_inc_gen",
580         ":basic_arm_mve_sema_gen",
581         ":basic_arm_neon_inc_gen",
582         ":basic_arm_sme_builtin_cg_gen",
583         ":basic_arm_sme_builtins_gen",
584         ":basic_arm_sve_builtins_gen",
585         ":basic_arm_sve_typeflags_gen",
586         ":basic_attr_gen",
587         ":basic_internal_headers",
588         ":basic_riscv_sifive_vector_builtins_gen",
589         ":basic_riscv_vector_builtin_cg_gen",
590         ":basic_riscv_vector_builtins_gen",
591         ":config",
592         ":diagnostic_defs_gen",
593         ":sema_attr_gen",
594         "//llvm:Core",
595         "//llvm:FrontendDebug",
596         "//llvm:FrontendOpenMP",
597         "//llvm:Instrumentation",
598         "//llvm:MC",
599         "//llvm:Support",
600         "//llvm:Target",
601         "//llvm:TargetParser",
602         "//llvm:config",
603     ],
606 cc_library(
607     name = "lex",
608     srcs = glob([
609         "lib/Lex/*.cpp",
610         "lib/Lex/*.h",
611     ]),
612     hdrs = glob([
613         "include/clang/Lex/*.h",
614     ]),
615     includes = ["include"],
616     deps = [
617         ":basic",
618         ":config",
619         "//llvm:Support",
620         "//llvm:TargetParser",
621     ],
624 gentbl(
625     name = "ast_attr_gen",
626     tbl_outs = [
627         (
628             "-gen-clang-attr-ast-visitor",
629             "include/clang/AST/AttrVisitor.inc",
630         ),
631         (
632             "-gen-clang-attr-classes",
633             "include/clang/AST/Attrs.inc",
634         ),
635         (
636             "-gen-clang-attr-doc-table",
637             "lib/AST/AttrDocTable.inc",
638         ),
639         (
640             "-gen-clang-attr-text-node-dump",
641             "include/clang/AST/AttrTextNodeDump.inc",
642         ),
643         (
644             "-gen-clang-attr-node-traverse",
645             "include/clang/AST/AttrNodeTraverse.inc",
646         ),
647         (
648             "-gen-clang-attr-impl",
649             "include/clang/AST/AttrImpl.inc",
650         ),
651         (
652             "-gen-clang-attr-can-print-left-list",
653             "include/clang/Basic/AttrLeftSideCanPrintList.inc",
654         ),
655         (
656             "-gen-clang-attr-must-print-left-list",
657             "include/clang/Basic/AttrLeftSideMustPrintList.inc",
658         ),
659     ],
660     tblgen = ":clang-tblgen",
661     td_file = "include/clang/Basic/Attr.td",
662     td_srcs = [
663         "include/clang/Basic/Attr.td",
664         "include/clang/Basic/AttrDocs.td",
665         "include/clang/Basic/ASTNode.td",
666         "include/clang/Basic/DeclNodes.td",
667         "include/clang/Basic/StmtNodes.td",
668     ],
671 gentbl(
672     name = "ast_decl_nodes_gen",
673     tbl_outs = [(
674         "-gen-clang-decl-nodes",
675         "include/clang/AST/DeclNodes.inc",
676     )],
677     tblgen = ":clang-tblgen",
678     td_file = "include/clang/Basic/DeclNodes.td",
679     td_srcs = [
680         "include/clang/Basic/ASTNode.td",
681         "include/clang/Basic/DeclNodes.td",
682     ],
685 gentbl(
686     name = "ast_stmt_nodes_gen",
687     tbl_outs = [(
688         "-gen-clang-stmt-nodes",
689         "include/clang/AST/StmtNodes.inc",
690     )],
691     tblgen = ":clang-tblgen",
692     td_file = "include/clang/Basic/StmtNodes.td",
693     td_srcs = [
694         "include/clang/Basic/ASTNode.td",
695         "include/clang/Basic/StmtNodes.td",
696     ],
699 gentbl(
700     name = "ast_comment_nodes_gen",
701     tbl_outs = [(
702         "-gen-clang-comment-nodes",
703         "include/clang/AST/CommentNodes.inc",
704     )],
705     tblgen = ":clang-tblgen",
706     td_file = "include/clang/Basic/CommentNodes.td",
707     td_srcs = [
708         "include/clang/Basic/ASTNode.td",
709         "include/clang/Basic/CommentNodes.td",
710     ],
713 gentbl(
714     name = "ast_comment_command_info_gen",
715     tbl_outs = [
716         (
717             "-gen-clang-comment-command-info",
718             "include/clang/AST/CommentCommandInfo.inc",
719         ),
720         (
721             "-gen-clang-comment-command-list",
722             "include/clang/AST/CommentCommandList.inc",
723         ),
724     ],
725     tblgen = ":clang-tblgen",
726     td_file = "include/clang/AST/CommentCommands.td",
727     td_srcs = ["include/clang/AST/CommentCommands.td"],
730 gentbl(
731     name = "ast_comment_html_tags_gen",
732     tbl_outs = [(
733         "-gen-clang-comment-html-tags",
734         "include/clang/AST/CommentHTMLTags.inc",
735     )],
736     tblgen = ":clang-tblgen",
737     td_file = "include/clang/AST/CommentHTMLTags.td",
738     td_srcs = ["include/clang/AST/CommentHTMLTags.td"],
741 gentbl(
742     name = "ast_comment_html_tags_properties_gen",
743     tbl_outs = [(
744         "-gen-clang-comment-html-tags-properties",
745         "include/clang/AST/CommentHTMLTagsProperties.inc",
746     )],
747     tblgen = ":clang-tblgen",
748     td_file = "include/clang/AST/CommentHTMLTags.td",
749     td_srcs = ["include/clang/AST/CommentHTMLTags.td"],
752 gentbl(
753     name = "ast_comment_html_named_character_references_gen",
754     tbl_outs = [(
755         "-gen-clang-comment-html-named-character-references",
756         "include/clang/AST/CommentHTMLNamedCharacterReferences.inc",
757     )],
758     tblgen = ":clang-tblgen",
759     td_file = "include/clang/AST/CommentHTMLNamedCharacterReferences.td",
760     td_srcs = ["include/clang/AST/CommentHTMLNamedCharacterReferences.td"],
763 gentbl(
764     name = "ast_stmt_data_collectors_gen",
765     tbl_outs = [(
766         "-gen-clang-data-collectors",
767         "include/clang/AST/StmtDataCollectors.inc",
768     )],
769     tblgen = ":clang-tblgen",
770     td_file = "include/clang/AST/StmtDataCollectors.td",
771     td_srcs = ["include/clang/AST/StmtDataCollectors.td"],
774 gentbl(
775     name = "ast_interp_opcodes_gen",
776     tbl_outs = [(
777         "-gen-clang-opcodes",
778         "lib/AST/Interp/Opcodes.inc",
779     )],
780     tblgen = ":clang-tblgen",
781     td_file = "lib/AST/Interp/Opcodes.td",
782     td_srcs = ["lib/AST/Interp/Opcodes.td"],
785 gentbl(
786     name = "ast_properties_base_gen",
787     tbl_outs = [
788         (
789             "-gen-clang-basic-reader",
790             "include/clang/AST/AbstractBasicReader.inc",
791         ),
792         (
793             "-gen-clang-basic-writer",
794             "include/clang/AST/AbstractBasicWriter.inc",
795         ),
796     ],
797     tblgen = ":clang-tblgen",
798     td_file = "include/clang/AST/PropertiesBase.td",
799     td_srcs = ["include/clang/AST/PropertiesBase.td"],
802 gentbl(
803     name = "ast_type_properties_gen",
804     tbl_outs = [
805         (
806             "-gen-clang-type-reader",
807             "include/clang/AST/AbstractTypeReader.inc",
808         ),
809         (
810             "-gen-clang-type-writer",
811             "include/clang/AST/AbstractTypeWriter.inc",
812         ),
813     ],
814     tblgen = ":clang-tblgen",
815     td_file = "include/clang/AST/TypeProperties.td",
816     td_srcs = [
817         "include/clang/AST/PropertiesBase.td",
818         "include/clang/AST/TypeProperties.td",
819         "include/clang/Basic/ASTNode.td",
820         "include/clang/Basic/TypeNodes.td",
821     ],
824 gentbl(
825     name = "type_nodes_gen",
826     tbl_outs = [(
827         "-gen-clang-type-nodes",
828         "include/clang/AST/TypeNodes.inc",
829     )],
830     tblgen = ":clang-tblgen",
831     td_file = "include/clang/Basic/TypeNodes.td",
832     td_srcs = [
833         "include/clang/Basic/ASTNode.td",
834         "include/clang/Basic/TypeNodes.td",
835     ],
838 workspace_root(name = "workspace_root")
840 cc_library(
841     name = "ast",
842     srcs = glob([
843         "lib/AST/*.cpp",
844         "lib/AST/*.h",
845         "lib/AST/Interp/*.cpp",
846         "lib/AST/Interp/*.h",
847     ]) + [
848         "lib/AST/AttrDocTable.inc",
849         "lib/AST/Interp/Opcodes.inc",
850     ],
851     hdrs = glob([
852         "include/clang/AST/*.h",
853     ]),
854     copts = [
855         # FIXME: This is necessary to allow "file relative" include paths from
856         # non-generated `srcs` to find generated `srcs` above. Bazel should
857         # either make this work automatically by creating a unified tree of
858         # `srcs` or at least provide a `local_includes` that has the path
859         # translation logic of `includes` but is only used locally (similar to
860         # `local_defines` vs. `defines`). Until one of those lands, this is the
861         # least bad approach. Using `includes` is *specifically* problematic for
862         # this library because it contains files that collide easily with system
863         # headers such as `CXXABI.h`.
864         "-I$(GENDIR)/$(WORKSPACE_ROOT)/clang/lib/AST",
865         "-I$(GENDIR)/$(WORKSPACE_ROOT)/clang/lib/AST/Interp",
866     ],
867     textual_hdrs = [
868         "include/clang/AST/AttrImpl.inc",
869         "include/clang/AST/AttrNodeTraverse.inc",
870         "include/clang/AST/Attrs.inc",
871         "include/clang/AST/AttrTextNodeDump.inc",
872         "include/clang/AST/AttrVisitor.inc",
873         "include/clang/AST/CommentCommandInfo.inc",
874         "include/clang/AST/CommentCommandList.inc",
875         "include/clang/AST/CommentHTMLNamedCharacterReferences.inc",
876         "include/clang/AST/CommentHTMLTags.inc",
877         "include/clang/AST/CommentHTMLTagsProperties.inc",
878         "include/clang/AST/CommentNodes.inc",
879         "include/clang/AST/DeclNodes.inc",
880         "include/clang/AST/StmtDataCollectors.inc",
881         "include/clang/AST/StmtNodes.inc",
882     ] + glob([
883         "include/clang/AST/*.def",
884     ]),
885     toolchains = [
886         ":workspace_root",
887     ],
888     deps = [
889         ":ast_attr_gen",
890         ":ast_comment_command_info_gen",
891         ":ast_comment_html_named_character_references_gen",
892         ":ast_comment_html_tags_gen",
893         ":ast_comment_html_tags_properties_gen",
894         ":ast_comment_nodes_gen",
895         ":ast_decl_nodes_gen",
896         ":ast_interp_opcodes_gen",
897         ":ast_properties_base_gen",
898         ":ast_stmt_data_collectors_gen",
899         ":ast_stmt_nodes_gen",
900         ":ast_type_properties_gen",
901         ":basic",
902         ":lex",
903         ":type_nodes_gen",
904         "//llvm:BinaryFormat",
905         "//llvm:Core",
906         "//llvm:FrontendHLSL",
907         "//llvm:FrontendOpenMP",
908         "//llvm:Support",
909         "//llvm:TargetParser",
910     ],
913 cc_library(
914     name = "index",
915     srcs = glob([
916         "lib/Index/*.cpp",
917         "lib/Index/*.h",
918     ]),
919     hdrs = glob([
920         "include/clang/Index/*.h",
921         "include/clang-c/*.h",
922     ]),
923     includes = ["include"],
924     deps = [
925         ":ast",
926         ":basic",
927         ":format",
928         ":frontend",
929         ":lex",
930         ":rewrite",
931         ":serialization",
932         "//llvm:Core",
933         "//llvm:Support",
934     ],
937 genrule(
938     name = "analysis_htmllogger_gen",
939     srcs = [
940         "lib/Analysis/FlowSensitive/HTMLLogger.html",
941         "lib/Analysis/FlowSensitive/HTMLLogger.css",
942         "lib/Analysis/FlowSensitive/HTMLLogger.js",
943     ],
944     outs = ["lib/Analysis/FlowSensitive/HTMLLogger.inc"],
945     cmd = "$(location :bundle_resources) $@ $(SRCS)",
946     tools = [":bundle_resources"],
949 cc_library(
950     name = "analysis",
951     srcs = glob([
952         "lib/Analysis/FlowSensitive/Models/*.cpp",
953         "lib/Analysis/FlowSensitive/*.cpp",
954         "lib/Analysis/*.cpp",
955         "lib/Analysis/*.h",
956     ]) + [
957         ":analysis_htmllogger_gen",
958     ],
959     hdrs = glob([
960         "include/clang/Analysis/**/*.h",
961     ]),
962     includes = [
963         "include",
964         "lib/Analysis/FlowSensitive",
965     ],
966     textual_hdrs = glob([
967         "include/clang/Analysis/**/*.def",
968     ]),
969     deps = [
970         ":ast",
971         ":ast_matchers",
972         ":basic",
973         ":lex",
974         "//llvm:Support",
975     ],
978 gentbl(
979     name = "sema_attr_gen",
980     tbl_outs = [
981         (
982             "-gen-clang-attr-parsed-attr-impl",
983             "include/clang/Sema/AttrParsedAttrImpl.inc",
984         ),
985         (
986             "-gen-clang-attr-parsed-attr-kinds",
987             "include/clang/Sema/AttrParsedAttrKinds.inc",
988         ),
989         (
990             "-gen-clang-attr-parsed-attr-list",
991             "include/clang/Sema/AttrParsedAttrList.inc",
992         ),
993         (
994             "-gen-clang-attr-spelling-index",
995             "include/clang/Sema/AttrSpellingListIndex.inc",
996         ),
997         (
998             "-gen-clang-attr-template-instantiate",
999             "include/clang/Sema/AttrTemplateInstantiate.inc",
1000         ),
1001     ],
1002     tblgen = ":clang-tblgen",
1003     td_file = "include/clang/Basic/Attr.td",
1004     td_srcs = [
1005         "include/clang/Basic/ASTNode.td",
1006         "include/clang/Basic/Attr.td",
1007         "include/clang/Basic/AttrDocs.td",
1008         "include/clang/Basic/DeclNodes.td",
1009         "include/clang/Basic/StmtNodes.td",
1010     ],
1013 cc_library(
1014     name = "sema",
1015     srcs = glob([
1016         "lib/Sema/*.cpp",
1017         "lib/Sema/*.h",
1018     ]),
1019     hdrs = glob([
1020         "include/clang/Sema/*.h",
1021         "include/clang-c/*.h",
1022     ]),
1023     copts = ["$(STACK_FRAME_UNLIMITED)"],
1024     includes = ["include"],
1025     textual_hdrs = [
1026         "include/clang/Sema/AttrParsedAttrImpl.inc",
1027         "include/clang/Sema/AttrParsedAttrKinds.inc",
1028         "include/clang/Sema/AttrParsedAttrList.inc",
1029         "include/clang/Sema/AttrSpellingListIndex.inc",
1030         "include/clang/Sema/AttrTemplateInstantiate.inc",
1031         "lib/Sema/OpenCLBuiltins.inc",
1032     ],
1033     deps = [
1034         ":analysis",
1035         ":ast",
1036         ":basic",
1037         ":basic_arm_cde_aliases_gen",
1038         ":basic_arm_cde_sema_gen",
1039         ":basic_arm_sme_builtins_gen",
1040         ":basic_arm_sme_sema_rangechecks_gen",
1041         ":basic_arm_sve_builtins_gen",
1042         ":basic_arm_sve_sema_rangechecks_gen",
1043         ":basic_riscv_sifive_vector_builtin_sema_gen",
1044         ":basic_riscv_vector_builtin_sema_gen",
1045         ":edit",
1046         ":lex",
1047         ":libsema_openclbuiltins_inc_gen",
1048         ":sema_attr_gen",
1049         ":support",
1050         ":type_nodes_gen",
1051         "//llvm:AllTargetsAsmParsers",
1052         "//llvm:AllTargetsCodeGens",
1053         "//llvm:Core",
1054         "//llvm:FrontendHLSL",
1055         "//llvm:FrontendOpenMP",
1056         "//llvm:MC",
1057         "//llvm:MCParser",
1058         "//llvm:Support",
1059         "//llvm:TargetParser",
1060     ],
1063 gentbl(
1064     name = "parse_attr_gen",
1065     tbl_outs = [
1066         (
1067             "-gen-clang-attr-parser-string-switches",
1068             "include/clang/Parse/AttrParserStringSwitches.inc",
1069         ),
1070         (
1071             "-gen-clang-attr-subject-match-rules-parser-string-switches",
1072             "include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc",
1073         ),
1074     ],
1075     tblgen = ":clang-tblgen",
1076     td_file = "include/clang/Basic/Attr.td",
1077     td_srcs = [
1078         "include/clang/Basic/ASTNode.td",
1079         "include/clang/Basic/Attr.td",
1080         "include/clang/Basic/AttrDocs.td",
1081         "include/clang/Basic/DeclNodes.td",
1082         "include/clang/Basic/StmtNodes.td",
1083     ],
1086 cc_library(
1087     name = "parse",
1088     srcs = [
1089     ] + glob([
1090         "lib/Parse/*.cpp",
1091         "lib/Parse/*.h",
1092     ]),
1093     hdrs = [
1094         "include/clang/Parse/AttrParserStringSwitches.inc",
1095         "include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc",
1096     ] + glob(["include/clang/Parse/*.h"]),
1097     includes = ["include"],
1098     deps = [
1099         ":ast",
1100         ":basic",
1101         ":lex",
1102         ":parse_attr_gen",
1103         ":sema",
1104         "//llvm:FrontendOpenMP",
1105         "//llvm:MC",
1106         "//llvm:MCParser",
1107         "//llvm:Support",
1108     ],
1111 cc_library(
1112     name = "ast_matchers",
1113     srcs = glob([
1114         "lib/ASTMatchers/*.cpp",
1115         "lib/ASTMatchers/*.h",
1116     ]),
1117     hdrs = glob(["include/clang/ASTMatchers/*.h"]),
1118     includes = ["include"],
1119     deps = [
1120         ":ast",
1121         ":basic",
1122         ":lex",
1123         "//llvm:Support",
1124     ],
1127 cc_library(
1128     name = "ast_matchers_dynamic",
1129     srcs = glob([
1130         "lib/ASTMatchers/Dynamic/*.cpp",
1131         "lib/ASTMatchers/Dynamic/*.h",
1132     ]),
1133     hdrs = glob(["include/clang/ASTMatchers/Dynamic/*.h"]),
1134     copts = ["$(STACK_FRAME_UNLIMITED)"],
1135     includes = ["include"],
1136     deps = [
1137         ":ast",
1138         ":ast_matchers",
1139         ":basic",
1140         "//llvm:FrontendOpenMP",
1141         "//llvm:Support",
1142     ],
1145 cc_library(
1146     name = "rewrite",
1147     srcs = glob([
1148         "lib/Rewrite/*.cpp",
1149         "lib/Rewrite/*.h",
1150     ]),
1151     hdrs = glob(["include/clang/Rewrite/Core/*.h"]),
1152     includes = ["include"],
1153     deps = [
1154         ":ast",
1155         ":basic",
1156         ":edit",
1157         ":lex",
1158         "//llvm:Support",
1159     ],
1162 cc_library(
1163     name = "testing",
1164     testonly = 1,
1165     srcs = glob([
1166         "lib/Testing/*.cpp",
1167     ]),
1168     hdrs = glob(["include/clang/Testing/*.h"]),
1169     includes = ["include"],
1170     deps = [
1171         ":basic",
1172         ":frontend",
1173         "//llvm:MC",
1174         "//llvm:Support",
1175         "//third-party/unittest:gtest",
1176     ],
1179 cc_library(
1180     name = "tooling_core",
1181     srcs = glob([
1182         "lib/Tooling/Core/*.cpp",
1183         "lib/Tooling/Core/*.h",
1184     ]),
1185     hdrs = glob(["include/clang/Tooling/Core/*.h"]),
1186     includes = ["include"],
1187     deps = [
1188         ":ast",
1189         ":basic",
1190         ":lex",
1191         ":rewrite",
1192         "//llvm:Support",
1193     ],
1196 cc_library(
1197     name = "tooling",
1198     srcs = glob(
1199         [
1200             "lib/Tooling/*.cpp",
1201         ],
1202         # Temporarily disable until we support the generated file.
1203         exclude = ["lib/Tooling/NodeIntrospection.cpp"],
1204     ),
1205     hdrs = glob([
1206         "include/clang/Tooling/*.h",
1207     ]),
1208     includes = ["include"],
1209     deps = [
1210         ":ast",
1211         ":ast_matchers",
1212         ":basic",
1213         ":driver",
1214         ":format",
1215         ":frontend",
1216         ":lex",
1217         ":rewrite",
1218         ":tooling_core",
1219         "//llvm:Option",
1220         "//llvm:Support",
1221         "//llvm:TargetParser",
1222     ],
1225 cc_library(
1226     name = "tooling_inclusions",
1227     srcs = glob([
1228         "lib/Tooling/Inclusions/**/*.cpp",
1229         "lib/Tooling/Inclusions/**/*.inc",
1230     ]),
1231     hdrs = glob([
1232         "include/clang/Tooling/Inclusions/**/*.h",
1233     ]),
1234     deps = [
1235         ":ast",
1236         ":basic",
1237         ":lex",
1238         ":rewrite",
1239         ":tooling_core",
1240         "//llvm:Support",
1241     ],
1244 cc_library(
1245     name = "tooling_refactoring",
1246     srcs = glob([
1247         "lib/Tooling/Refactoring/**/*.cpp",
1248         "lib/Tooling/Refactoring/**/*.h",
1249     ]),
1250     hdrs = glob([
1251         "include/clang/Tooling/Refactoring/**/*.h",
1252         "include/clang/Tooling/Refactoring/**/*.def",
1253     ]),
1254     deps = [
1255         ":ast",
1256         ":ast_matchers",
1257         ":basic",
1258         ":format",
1259         ":frontend",
1260         ":index",
1261         ":lex",
1262         ":rewrite",
1263         ":tooling",
1264         ":tooling_core",
1265         "//llvm:Support",
1266     ],
1269 gentbl(
1270     name = "tooling_syntax_gen",
1271     tbl_outs = [
1272         ("-gen-clang-syntax-node-list", "include/clang/Tooling/Syntax/Nodes.inc"),
1273         ("-gen-clang-syntax-node-classes", "include/clang/Tooling/Syntax/NodeClasses.inc"),
1274     ],
1275     tblgen = ":clang-tblgen",
1276     td_file = "include/clang/Tooling/Syntax/Nodes.td",
1277     td_srcs = [
1278         "include/clang/Tooling/Syntax/Nodes.td",
1279         "include/clang/Tooling/Syntax/Syntax.td",
1280     ],
1283 cc_library(
1284     name = "tooling_syntax",
1285     srcs = glob(["lib/Tooling/Syntax/**/*.cpp"]),
1286     hdrs = glob(["include/clang/Tooling/Syntax/**/*.h"]),
1287     deps = [
1288         ":ast",
1289         ":basic",
1290         ":lex",
1291         ":tooling_core",
1292         ":tooling_syntax_gen",
1293         "//llvm:Support",
1294     ],
1297 cc_library(
1298     name = "tooling_dependency_scanning",
1299     srcs = glob(["lib/Tooling/DependencyScanning/**/*.cpp"]),
1300     hdrs = glob(["include/clang/Tooling/DependencyScanning/**/*.h"]),
1301     deps = [
1302         ":basic",
1303         ":codegen",
1304         ":driver",
1305         ":frontend",
1306         ":lex",
1307         ":serialization",
1308         ":tooling",
1309         "//llvm:Support",
1310         "//llvm:TargetParser",
1311     ],
1314 cc_library(
1315     name = "transformer",
1316     srcs = glob(["lib/Tooling/Transformer/**/*.cpp"]),
1317     hdrs = glob(["include/clang/Tooling/Transformer/**/*.h"]),
1318     deps = [
1319         ":ast",
1320         ":ast_matchers",
1321         ":basic",
1322         ":lex",
1323         ":rewrite",
1324         ":tooling_refactoring",
1325         "//llvm:Support",
1326     ],
1329 cc_library(
1330     name = "ast-diff",
1331     srcs = glob(["lib/Tooling/ASTDiff/*.cpp"]),
1332     hdrs = glob(["include/clang/Tooling/ASTDiff/*.h"]),
1333     deps = [
1334         ":ast",
1335         ":basic",
1336         ":lex",
1337         "//llvm:Support",
1338     ],
1341 cc_library(
1342     name = "crosstu",
1343     srcs = glob(["lib/CrossTU/*.cpp"]),
1344     hdrs = glob(["include/clang/CrossTU/*.h"]),
1345     deps = [
1346         ":analysis",
1347         ":ast",
1348         ":basic",
1349         ":frontend",
1350         ":index",
1351         "//llvm:Option",
1352         "//llvm:Support",
1353         "//llvm:TargetParser",
1354     ],
1357 cc_library(
1358     name = "format",
1359     srcs = glob(
1360         [
1361             "lib/Format/*.cpp",
1362             "lib/Format/*.h",
1363         ],
1364     ),
1365     hdrs = [
1366         "lib/Format/FormatTokenLexer.h",
1367         "lib/Format/FormatTokenSource.h",
1368         "lib/Format/Macros.h",
1369         "lib/Format/QualifierAlignmentFixer.h",
1370         "lib/Format/UnwrappedLineParser.h",
1371     ] + glob([
1372         "include/clang/Format/*.h",
1373     ]),
1374     includes = ["include"],
1375     deps = [
1376         ":basic",
1377         ":lex",
1378         ":tooling_core",
1379         ":tooling_inclusions",
1380         "//llvm:Support",
1381     ],
1384 cc_library(
1385     name = "edit",
1386     srcs = glob(["lib/Edit/*.cpp"]),
1387     hdrs = glob(["include/clang/Edit/*.h"]),
1388     includes = ["include"],
1389     deps = [
1390         ":ast",
1391         ":basic",
1392         ":lex",
1393         "//llvm:Support",
1394     ],
1397 cc_library(
1398     name = "static_analyzer_core_options",
1399     hdrs = [
1400         "include/clang/StaticAnalyzer/Core/AnalyzerOptions.h",
1401     ],
1402     textual_hdrs = [
1403         "include/clang/StaticAnalyzer/Core/Analyses.def",
1404         "include/clang/StaticAnalyzer/Core/AnalyzerOptions.def",
1405     ],
1406     deps = [
1407         ":basic",
1408         ":static_analyzer_checkers_gen",
1409         "//llvm:Support",
1410     ],
1413 cc_library(
1414     name = "static_analyzer_core",
1415     srcs = glob([
1416         "lib/StaticAnalyzer/Core/**/*.cpp",
1417         "lib/StaticAnalyzer/Core/**/*.h",
1418     ]),
1419     hdrs = glob([
1420         "include/clang/StaticAnalyzer/Core/**/*.h",
1421     ]),
1422     includes = ["include"],
1423     textual_hdrs = glob([
1424         "include/clang/StaticAnalyzer/Core/**/*.def",
1425     ]),
1426     deps = [
1427         ":analysis",
1428         ":ast",
1429         ":ast_matchers",
1430         ":basic",
1431         ":crosstu",
1432         ":driver",
1433         ":frontend",
1434         ":lex",
1435         ":rewrite",
1436         ":static_analyzer_checkers_gen",
1437         ":tooling",
1438         ":tooling_core",
1439         "//llvm:Support",
1440     ],
1443 gentbl(
1444     name = "static_analyzer_checkers_gen",
1445     tbl_outs = [(
1446         "-gen-clang-sa-checkers",
1447         "include/clang/StaticAnalyzer/Checkers/Checkers.inc",
1448     )],
1449     tblgen = ":clang-tblgen",
1450     td_file = "include/clang/StaticAnalyzer/Checkers/Checkers.td",
1451     td_srcs = [
1452         "include/clang/StaticAnalyzer/Checkers/CheckerBase.td",
1453         "include/clang/StaticAnalyzer/Checkers/Checkers.td",
1454     ],
1457 cc_library(
1458     name = "static_analyzer_checkers",
1459     srcs = glob([
1460         "lib/StaticAnalyzer/Checkers/**/*.cpp",
1461         "lib/StaticAnalyzer/Checkers/**/*.h",
1462     ]),
1463     hdrs = [
1464         "include/clang/StaticAnalyzer/Checkers/Checkers.inc",
1465     ] + glob([
1466         "include/clang/StaticAnalyzer/Checkers/**/*.h",
1467     ]),
1468     copts = ["$(STACK_FRAME_UNLIMITED)"],
1469     includes = ["include"],
1470     deps = [
1471         ":analysis",
1472         ":ast",
1473         ":ast_matchers",
1474         ":basic",
1475         ":driver",
1476         ":lex",
1477         ":static_analyzer_checkers_gen",
1478         ":static_analyzer_core",
1479         "//llvm:Support",
1480     ],
1483 gentbl(
1484     name = "driver_options_inc_gen",
1485     tbl_outs = [(
1486         "-gen-opt-parser-defs",
1487         "include/clang/Driver/Options.inc",
1488     )],
1489     tblgen = "//llvm:llvm-tblgen",
1490     td_file = "include/clang/Driver/Options.td",
1491     td_srcs = [
1492         "//llvm:include/llvm/Option/OptParser.td",
1493     ],
1496 cc_library(
1497     name = "driver",
1498     srcs = glob(
1499         [
1500             "lib/Driver/*.cpp",
1501             "lib/Driver/*.h",
1502             "lib/Driver/Arch/*.cpp",
1503             "lib/Driver/Arch/*.h",
1504             "lib/Driver/ToolChains/*.cpp",
1505             "lib/Driver/ToolChains/*.h",
1506             "lib/Driver/ToolChains/Arch/*.cpp",
1507             "lib/Driver/ToolChains/Arch/*.h",
1508         ],
1509         exclude = [
1510             "lib/Driver/ToolChains/MSVCSetupApi.h",
1511         ],
1512     ),
1513     hdrs = glob([
1514         "include/clang/Driver/*.h",
1515     ]),
1516     copts = ["$(STACK_FRAME_UNLIMITED)"],
1517     includes = [
1518         "include",
1519         # TODO: This is likely a layering issue, but files in Arch are currently
1520         # directly #including "Tools.h".
1521         "lib/Driver",
1522     ],
1523     linkopts = select({
1524         "@platforms//os:windows": ["version.lib"],
1525         "//conditions:default": [],
1526     }),
1527     textual_hdrs = glob([
1528         "include/clang/Driver/*.def",
1529     ]),
1530     deps = [
1531         ":ast",
1532         ":basic",
1533         ":config",
1534         ":driver_options_inc_gen",
1535         ":parse",
1536         ":static_analyzer_checkers_gen",
1537         "//llvm:BinaryFormat",
1538         "//llvm:FrontendDebug",
1539         "//llvm:Instrumentation",
1540         "//llvm:MC",
1541         "//llvm:Object",
1542         "//llvm:Option",
1543         "//llvm:ProfileData",
1544         "//llvm:Support",
1545         "//llvm:Target",
1546         "//llvm:TargetParser",
1547         "//llvm:WindowsDriver",
1548         "//llvm:config",
1549     ],
1552 gentbl(
1553     name = "headers_arm_neon_gen",
1554     tbl_outs = [(
1555         "-gen-arm-neon",
1556         "lib/Headers/arm_neon.h",
1557     )],
1558     tblgen = ":clang-tblgen",
1559     td_file = "include/clang/Basic/arm_neon.td",
1560     td_srcs = [
1561         "include/clang/Basic/arm_neon.td",
1562         "include/clang/Basic/arm_neon_incl.td",
1563     ],
1566 gentbl(
1567     name = "headers_arm_fp16_gen",
1568     tbl_outs = [(
1569         "-gen-arm-fp16",
1570         "lib/Headers/arm_fp16.h",
1571     )],
1572     tblgen = ":clang-tblgen",
1573     td_file = "include/clang/Basic/arm_fp16.td",
1574     td_srcs = [
1575         "include/clang/Basic/arm_fp16.td",
1576         "include/clang/Basic/arm_neon_incl.td",
1577     ],
1580 gentbl(
1581     name = "headers_arm_mve_gen",
1582     tbl_outs = [(
1583         "-gen-arm-mve-header",
1584         "lib/Headers/arm_mve.h",
1585     )],
1586     tblgen = ":clang-tblgen",
1587     td_file = "include/clang/Basic/arm_mve.td",
1588     td_srcs = [
1589         "include/clang/Basic/arm_mve.td",
1590         "include/clang/Basic/arm_mve_defs.td",
1591     ],
1594 gentbl(
1595     name = "headers_arm_cde_gen",
1596     tbl_outs = [(
1597         "-gen-arm-cde-header",
1598         "lib/Headers/arm_cde.h",
1599     )],
1600     tblgen = ":clang-tblgen",
1601     td_file = "include/clang/Basic/arm_cde.td",
1602     td_srcs = [
1603         "include/clang/Basic/arm_cde.td",
1604         "include/clang/Basic/arm_mve_defs.td",
1605     ],
1608 gentbl(
1609     name = "headers_arm_sve_gen",
1610     tbl_outs = [(
1611         "-gen-arm-sve-header",
1612         "lib/Headers/arm_sve.h",
1613     )],
1614     tblgen = ":clang-tblgen",
1615     td_file = "include/clang/Basic/arm_sve.td",
1616     td_srcs = [
1617         "include/clang/Basic/arm_sve.td",
1618         "include/clang/Basic/arm_sve_sme_incl.td",
1619     ],
1622 gentbl(
1623     name = "headers_arm_bf16_gen",
1624     tbl_outs = [(
1625         "-gen-arm-bf16",
1626         "lib/Headers/arm_bf16.h",
1627     )],
1628     tblgen = ":clang-tblgen",
1629     td_file = "include/clang/Basic/arm_bf16.td",
1630     td_srcs = [
1631         "include/clang/Basic/arm_bf16.td",
1632         "include/clang/Basic/arm_neon_incl.td",
1633     ],
1636 gentbl(
1637     name = "headers_arm_sme_draft_spec_subject_to_change_gen",
1638     copts = [
1639         "-Wno-implicit-fallthrough",
1640         "-Wno-error=frame-larger-than=",
1641     ],
1642     tbl_outs = [(
1643         "-gen-arm-sme-header",
1644         "lib/Headers/arm_sme_draft_spec_subject_to_change.h",
1645     )],
1646     tblgen = ":clang-tblgen",
1647     td_file = "include/clang/Basic/arm_sme.td",
1648     td_srcs = [
1649         "include/clang/Basic/arm_sme.td",
1650         "include/clang/Basic/arm_sve_sme_incl.td",
1651     ],
1654 gentbl(
1655     name = "headers_riscv_vector",
1656     tbl_outs = [(
1657         "-gen-riscv-vector-header",
1658         "lib/Headers/riscv_vector.h",
1659     )],
1660     tblgen = ":clang-tblgen",
1661     td_file = "include/clang/Basic/riscv_vector.td",
1662     td_srcs = [
1663         "include/clang/Basic/riscv_vector.td",
1664         "include/clang/Basic/riscv_vector_common.td",
1665     ],
1668 # We generate the set of builtin headers under a special subdirectory in the
1669 # 'bin' section of the bazel output so that they can be used as data
1670 # dependencies. It requires listing explicitly all the generated inputs here.
1671 builtin_headers = glob(
1672     ["lib/Headers/**/*.h"],
1673     exclude = [
1674         # FIXME: They are not handled in CMake side.
1675         "lib/Headers/openmp_wrappers/stdlib.h",
1676         "lib/Headers/openmp_wrappers/time.h",
1677         "lib/Headers/ppc_wrappers/nmmintrin.h",
1678     ],
1679 ) + [
1680     "lib/Headers/arm_cde.h",
1681     "lib/Headers/arm_fp16.h",
1682     "lib/Headers/arm_mve.h",
1683     "lib/Headers/arm_neon.h",
1684     "lib/Headers/arm_sve.h",
1685     "lib/Headers/arm_sme_draft_spec_subject_to_change.h",
1686     "lib/Headers/arm_bf16.h",
1687     "lib/Headers/module.modulemap",
1688     "lib/Headers/riscv_vector.h",
1689     "lib/Headers/cuda_wrappers/algorithm",
1690     "lib/Headers/cuda_wrappers/complex",
1691     "lib/Headers/cuda_wrappers/new",
1692     "lib/Headers/openmp_wrappers/cmath",
1693     "lib/Headers/openmp_wrappers/complex",
1694     "lib/Headers/openmp_wrappers/new",
1697 genrule(
1698     name = "builtin_headers_gen",
1699     srcs = builtin_headers,
1700     outs = [hdr.replace("lib/Headers/", "staging/include/") for hdr in builtin_headers],
1701     cmd = """
1702        for src in $(SRCS); do
1703          relsrc=$${src#*"$(WORKSPACE_ROOT)"/clang/lib/Headers}
1704          target=$(@D)/staging/include/$$relsrc
1705          mkdir -p $$(dirname $$target)
1706          cp $$src $$target
1707        done""",
1708     output_to_bindir = 1,
1709     toolchains = [
1710         ":workspace_root",
1711     ],
1714 cc_library(
1715     name = "frontend",
1716     srcs = glob([
1717         "lib/Frontend/*.cpp",
1718         "lib/Frontend/*.h",
1719     ]),
1720     hdrs = glob([
1721         "include/clang/Frontend/*.h",
1722     ]),
1723     copts = ["$(STACK_FRAME_UNLIMITED)"],
1724     data = [":builtin_headers_gen"],
1725     includes = ["include"],
1726     textual_hdrs = glob([
1727         "include/clang/Frontend/*.def",
1728     ]),
1729     deps = [
1730         ":ast",
1731         ":basic",
1732         ":config",
1733         ":driver",
1734         ":driver_options_inc_gen",
1735         ":edit",
1736         ":lex",
1737         ":parse",
1738         ":sema",
1739         ":serialization",
1740         ":static_analyzer_core_options",
1741         "//llvm:BinaryFormat",
1742         "//llvm:BitReader",
1743         "//llvm:BitstreamReader",
1744         "//llvm:BitstreamWriter",
1745         "//llvm:Core",
1746         "//llvm:FrontendDebug",
1747         "//llvm:Linker",
1748         "//llvm:MC",
1749         "//llvm:Option",
1750         "//llvm:ProfileData",
1751         "//llvm:Remarks",
1752         "//llvm:Support",
1753         "//llvm:Target",
1754         "//llvm:TargetParser",
1755         "//llvm:config",
1756     ],
1759 cc_library(
1760     name = "frontend_rewrite",
1761     srcs = glob([
1762         "lib/Frontend/Rewrite/*.cpp",
1763         "lib/Frontend/Rewrite/*.h",
1764     ]),
1765     hdrs = glob(["include/clang/Rewrite/Frontend/*.h"]),
1766     includes = ["include"],
1767     deps = [
1768         ":ast",
1769         ":basic",
1770         ":config",
1771         ":edit",
1772         ":frontend",
1773         ":lex",
1774         ":parse",
1775         ":rewrite",
1776         ":serialization",
1777         "//llvm:Support",
1778     ],
1781 cc_library(
1782     name = "interpreter",
1783     srcs = glob([
1784         "lib/Interpreter/*.cpp",
1785         "lib/Interpreter/*.h",
1786     ]),
1787     hdrs = glob(["include/clang/Interpreter/*.h"]),
1788     includes = ["include"],
1789     deps = [
1790         ":analysis",
1791         ":ast",
1792         ":basic",
1793         ":codegen",
1794         ":driver",
1795         ":edit",
1796         ":frontend",
1797         ":frontend_tool",
1798         ":lex",
1799         ":parse",
1800         ":sema",
1801         ":serialization",
1802         "//llvm:AllTargetsAsmParsers",
1803         "//llvm:AllTargetsCodeGens",
1804         "//llvm:Core",
1805         "//llvm:ExecutionEngine",
1806         "//llvm:MC",
1807         "//llvm:Option",
1808         "//llvm:OrcDebugging",
1809         "//llvm:OrcJIT",
1810         "//llvm:OrcShared",
1811         "//llvm:OrcTargetProcess",
1812         "//llvm:Support",
1813         "//llvm:Target",
1814         "//llvm:TargetParser",
1815     ],
1818 cc_library(
1819     name = "codegen",
1820     srcs = glob([
1821         "lib/CodeGen/**/*.cpp",
1822         "lib/CodeGen/**/*.h",
1823     ]),
1824     hdrs = glob(["include/clang/CodeGen/*.h"]),
1825     copts = ["$(STACK_FRAME_UNLIMITED)"],
1826     includes = [
1827         "include",
1828         "lib/CodeGen",
1829     ],
1830     deps = [
1831         ":analysis",
1832         ":ast",
1833         ":basic",
1834         ":basic_arm_cde_cg_gen",
1835         ":basic_arm_sme_builtin_cg_gen",
1836         ":basic_arm_sve_builtin_cg_gen",
1837         ":basic_riscv_sifive_vector_builtin_cg_gen",
1838         ":basic_riscv_vector_builtin_cg_gen",
1839         ":driver",
1840         ":frontend",
1841         ":lex",
1842         ":sema",
1843         ":type_nodes_gen",
1844         "//llvm:AllTargetsAsmParsers",
1845         "//llvm:Analysis",
1846         "//llvm:BinaryFormat",
1847         "//llvm:BitReader",
1848         "//llvm:BitWriter",
1849         "//llvm:BitstreamReader",
1850         "//llvm:CodeGen",
1851         "//llvm:CodeGenTypes",
1852         "//llvm:Core",
1853         "//llvm:Coroutines",
1854         "//llvm:Coverage",
1855         "//llvm:DebugInfoDWARF",
1856         "//llvm:Demangle",
1857         "//llvm:FrontendHLSL",
1858         "//llvm:FrontendOffloading",
1859         "//llvm:FrontendOpenMP",
1860         "//llvm:HipStdPar",
1861         "//llvm:IPO",
1862         "//llvm:IRPrinter",
1863         "//llvm:IRReader",
1864         "//llvm:InstCombine",
1865         "//llvm:Instrumentation",
1866         "//llvm:LTO",
1867         "//llvm:Linker",
1868         "//llvm:MC",
1869         "//llvm:ObjCARC",
1870         "//llvm:Object",
1871         "//llvm:Passes",
1872         "//llvm:ProfileData",
1873         "//llvm:Scalar",
1874         "//llvm:Support",
1875         "//llvm:Target",
1876         "//llvm:TargetParser",
1877         "//llvm:TransformUtils",
1878     ],
1881 cc_library(
1882     name = "static_analyzer_frontend",
1883     srcs = glob([
1884         "lib/StaticAnalyzer/Frontend/**/*.cpp",
1885         "lib/StaticAnalyzer/Frontend/**/*.h",
1886     ]),
1887     hdrs = glob(["include/clang/StaticAnalyzer/Frontend/**/*.h"]),
1888     includes = ["include"],
1889     deps = [
1890         ":analysis",
1891         ":ast",
1892         ":basic",
1893         ":crosstu",
1894         ":driver",
1895         ":frontend",
1896         ":lex",
1897         ":rewrite",
1898         ":serialization",
1899         ":static_analyzer_checkers",
1900         ":static_analyzer_core",
1901         ":tooling",
1902         ":tooling_core",
1903         "//llvm:Support",
1904     ],
1907 gentbl(
1908     name = "serialization_attr_gen",
1909     tbl_outs = [
1910         (
1911             "-gen-clang-attr-pch-read",
1912             "include/clang/Serialization/AttrPCHRead.inc",
1913         ),
1914         (
1915             "-gen-clang-attr-pch-write",
1916             "include/clang/Serialization/AttrPCHWrite.inc",
1917         ),
1918     ],
1919     tblgen = ":clang-tblgen",
1920     td_file = "include/clang/Basic/Attr.td",
1921     td_srcs = [
1922         "include/clang/Basic/ASTNode.td",
1923         "include/clang/Basic/Attr.td",
1924         "include/clang/Basic/AttrDocs.td",
1925         "include/clang/Basic/DeclNodes.td",
1926         "include/clang/Basic/StmtNodes.td",
1927     ],
1930 cc_library(
1931     name = "support",
1932     srcs = glob([
1933         "lib/Support/*.cpp",
1934     ]),
1935     hdrs = glob([
1936         "include/clang/Support/*.h",
1937     ]),
1938     includes = ["include"],
1939     deps = [
1940         "//llvm:Support",
1941     ],
1944 cc_library(
1945     name = "serialization",
1946     srcs = [
1947         "include/clang/Serialization/AttrPCHRead.inc",
1948         "include/clang/Serialization/AttrPCHWrite.inc",
1949     ] + glob([
1950         "lib/Serialization/*.cpp",
1951         "lib/Serialization/*.h",
1952     ]),
1953     hdrs = glob([
1954         "include/clang/Serialization/*.h",
1955     ]),
1956     includes = ["include"],
1957     textual_hdrs = glob([
1958         "include/clang/Serialization/*.def",
1959     ]),
1960     deps = [
1961         ":ast",
1962         ":basic",
1963         ":lex",
1964         ":sema",
1965         ":serialization_attr_gen",
1966         ":type_nodes_gen",
1967         "//llvm:BitReader",
1968         "//llvm:BitWriter",
1969         "//llvm:BitstreamReader",
1970         "//llvm:BitstreamWriter",
1971         "//llvm:FrontendOpenMP",
1972         "//llvm:Support",
1973         "//llvm:TargetParser",
1974     ],
1977 cc_library(
1978     name = "frontend_tool",
1979     srcs = glob([
1980         "lib/FrontendTool/*.cpp",
1981         "lib/FrontendTool/*.h",
1982     ]),
1983     hdrs = glob(["include/clang/FrontendTool/*.h"]),
1984     includes = ["include"],
1985     deps = [
1986         ":arc_migrate",
1987         ":codegen",
1988         ":config",
1989         ":driver",
1990         ":extract_api",
1991         ":frontend",
1992         ":frontend_rewrite",
1993         ":static_analyzer_frontend",
1994         "//llvm:Option",
1995         "//llvm:Support",
1996     ],
1999 cc_library(
2000     name = "arc_migrate",
2001     srcs = glob([
2002         "lib/ARCMigrate/*.cpp",
2003         "lib/ARCMigrate/*.h",
2004     ]),
2005     hdrs = glob(["include/clang/ARCMigrate/*.h"]),
2006     includes = ["include"],
2007     deps = [
2008         ":analysis",
2009         ":ast",
2010         ":basic",
2011         ":edit",
2012         ":frontend",
2013         ":frontend_rewrite",
2014         ":lex",
2015         ":parse",
2016         ":rewrite",
2017         ":sema",
2018         ":serialization",
2019         ":static_analyzer_checkers",
2020         ":static_analyzer_core",
2021         "//llvm:Support",
2022         "//llvm:TargetParser",
2023     ],
2026 cc_library(
2027     name = "libclang_static",
2028     srcs = glob([
2029         "tools/libclang/*.cpp",
2030         "tools/libclang/*.h",
2031     ]),
2032     hdrs = glob(["include/clang-c/*.h"]),
2033     defines = ["CINDEX_NO_EXPORTS"],
2034     deps = [
2035         ":arc_migrate",
2036         ":ast",
2037         ":basic",
2038         ":codegen",
2039         ":config",
2040         ":driver",
2041         ":extract_api",
2042         ":frontend",
2043         ":index",
2044         ":lex",
2045         ":rewrite",
2046         ":sema",
2047         ":tooling",
2048         "//llvm:BitstreamReader",
2049         "//llvm:FrontendOpenMP",
2050         "//llvm:Support",
2051         "//llvm:config",
2052     ],
2055 cc_plugin_library(
2056     name = "libclang",
2057     srcs = glob([
2058         "tools/libclang/*.cpp",
2059         "tools/libclang/*.h",
2060     ]),
2061     hdrs = glob(["include/clang-c/*.h"]),
2062     copts = select({
2063         "@platforms//os:windows": ["-D_CINDEX_LIB_"],
2064         "//conditions:default": [],
2065     }),
2066     strip_include_prefix = "include",
2067     deps = [
2068         ":arc_migrate",
2069         ":ast",
2070         ":basic",
2071         ":codegen",
2072         ":config",
2073         ":driver",
2074         ":extract_api",
2075         ":frontend",
2076         ":index",
2077         ":lex",
2078         ":rewrite",
2079         ":sema",
2080         ":tooling",
2081         "//llvm:BitstreamReader",
2082         "//llvm:FrontendOpenMP",
2083         "//llvm:Support",
2084         "//llvm:config",
2085     ],
2088 filegroup(
2089     name = "python-sources",
2090     srcs = [
2091         "bindings/python/clang/cindex.py",
2092         "bindings/python/clang/enumerations.py",
2093     ],
2096 filegroup(
2097     name = "python-cindex-examples",
2098     srcs = [
2099         "bindings/python/examples/cindex/cindex-dump.py",
2100         "bindings/python/examples/cindex/cindex-includes.py",
2101     ],
2104 cc_binary(
2105     name = "c-index-test",
2106     testonly = 1,
2107     srcs = [
2108         "tools/c-index-test/c-index-test.c",
2109         "tools/c-index-test/core_main.cpp",
2110     ],
2111     copts = [
2112         "-Wno-uninitialized",
2113     ],
2114     stamp = 0,
2115     deps = [
2116         ":ast",
2117         ":basic",
2118         ":codegen",
2119         ":config",
2120         ":frontend",
2121         ":index",
2122         ":lex",
2123         ":libclang",
2124         ":serialization",
2125         "//llvm:Core",
2126         "//llvm:MC",
2127         "//llvm:Support",
2128     ],
2131 cc_binary(
2132     name = "arcmt-test",
2133     testonly = 1,
2134     srcs = ["tools/arcmt-test/arcmt-test.cpp"],
2135     stamp = 0,
2136     deps = [
2137         ":arc_migrate",
2138         ":ast",
2139         ":basic",
2140         ":frontend",
2141         ":frontend_rewrite",
2142         ":lex",
2143         "//llvm:Support",
2144     ],
2147 cc_binary(
2148     name = "c-arcmt-test",
2149     testonly = 1,
2150     srcs = ["tools/c-arcmt-test/c-arcmt-test.c"],
2151     copts = select({
2152         "@platforms//os:windows": [],
2153         "//conditions:default": ["-std=gnu99"],
2154     }),
2155     stamp = 0,
2156     deps = [
2157         ":codegen",
2158         ":libclang",
2159         "//llvm:MC",
2160         "//llvm:Support",
2161     ],
2164 cc_binary(
2165     name = "clang-import-test",
2166     testonly = 1,
2167     srcs = glob([
2168         "tools/clang-import-test/*.cpp",
2169         "tools/clang-import-test/*.h",
2170     ]),
2171     stamp = 0,
2172     deps = [
2173         ":ast",
2174         ":basic",
2175         ":codegen",
2176         ":driver",
2177         ":frontend",
2178         ":lex",
2179         ":parse",
2180         "//llvm:Core",
2181         "//llvm:Support",
2182         "//llvm:TargetParser",
2183     ],
2186 expand_template(
2187     name = "clang_main",
2188     out = "clang-driver.cpp",
2189     substitutions = {
2190         "@TOOL_NAME@": "clang",
2191     },
2192     template = "//llvm:cmake/modules/llvm-driver-template.cpp.in",
2195 cc_library(
2196     name = "clang-driver",
2197     srcs = glob([
2198         "tools/driver/*.cpp",
2199         "tools/driver/*.h",
2200     ]) + ["clang-driver.cpp"],
2201     copts = [
2202         # Disable stack frame size checks in the driver because
2203         # clang::ensureStackAddressSpace allocates a large array on the stack.
2204         "$(STACK_FRAME_UNLIMITED)",
2205     ],
2206     deps = [
2207         ":analysis",
2208         ":ast",
2209         ":basic",
2210         ":codegen",
2211         ":config",
2212         ":driver",
2213         ":frontend",
2214         ":frontend_rewrite",
2215         ":frontend_tool",
2216         ":lex",
2217         ":parse",
2218         ":sema",
2219         ":serialization",
2220         ":static_analyzer_frontend",
2221         "//llvm:AllTargetsAsmParsers",
2222         "//llvm:AllTargetsCodeGens",
2223         "//llvm:BitReader",
2224         "//llvm:BitWriter",
2225         "//llvm:CodeGen",
2226         "//llvm:Core",
2227         "//llvm:IPO",
2228         "//llvm:MC",
2229         "//llvm:MCParser",
2230         "//llvm:Option",
2231         "//llvm:Support",
2232         "//llvm:Target",
2233         "//llvm:TargetParser",
2234         "//llvm:config",
2235     ],
2238 cc_binary(
2239     name = "clang",
2240     srcs = [],
2241     stamp = 0,
2242     deps = [
2243         ":clang-driver",
2244     ],
2247 cc_binary(
2248     name = "diagtool",
2249     srcs = glob([
2250         "tools/diagtool/*.cpp",
2251         "tools/diagtool/*.h",
2252     ]),
2253     stamp = 0,
2254     deps = [
2255         ":basic",
2256         ":frontend",
2257         ":lex",
2258         ":sema",
2259         "//llvm:Support",
2260     ],
2263 filegroup(
2264     name = "exploded_graph_rewriter",
2265     testonly = 1,
2266     data = ["utils/analyzer/exploded-graph-rewriter.py"],
2269 filegroup(
2270     name = "module-deps-to-rsp",
2271     testonly = 1,
2272     data = ["utils/module-deps-to-rsp.py"],
2275 filegroup(
2276     name = "hmaptool",
2277     testonly = 1,
2278     data = ["utils/hmaptool/hmaptool"],
2281 binary_alias(
2282     name = "clang++",
2283     binary = ":clang",
2286 cc_binary(
2287     name = "clang-check",
2288     srcs = ["tools/clang-check/ClangCheck.cpp"],
2289     stamp = 0,
2290     deps = [
2291         ":ast",
2292         ":codegen",
2293         ":driver",
2294         ":frontend",
2295         ":frontend_rewrite",
2296         ":serialization",
2297         ":static_analyzer_frontend",
2298         ":tooling",
2299         ":tooling_syntax",
2300         "//llvm:Option",
2301         "//llvm:Support",
2302     ],
2305 cc_binary(
2306     name = "clang-format",
2307     srcs = [
2308         "tools/clang-format/ClangFormat.cpp",
2309     ],
2310     stamp = 0,
2311     deps = [
2312         ":basic",
2313         ":format",
2314         ":frontend",
2315         ":rewrite",
2316         "//llvm:Support",
2317     ],
2320 cc_binary(
2321     name = "clang-diff",
2322     srcs = glob(["tools/clang-diff/*.cpp"]),
2323     stamp = 0,
2324     deps = [
2325         ":ast-diff",
2326         ":tooling",
2327         "//llvm:Support",
2328     ],
2331 cc_binary(
2332     name = "clang-offload-bundler",
2333     srcs = glob(["tools/clang-offload-bundler/*.cpp"]),
2334     stamp = 0,
2335     deps = [
2336         ":basic",
2337         ":driver",
2338         ":tooling",
2339         "//llvm:BitWriter",
2340         "//llvm:Core",
2341         "//llvm:Object",
2342         "//llvm:Support",
2343         "//llvm:TargetParser",
2344     ],
2347 cc_binary(
2348     name = "clang-offload-packager",
2349     srcs = glob(["tools/clang-offload-packager/*.cpp"]),
2350     stamp = 0,
2351     deps = [
2352         ":basic",
2353         "//llvm:BinaryFormat",
2354         "//llvm:Object",
2355         "//llvm:Support",
2356     ],
2359 gentbl(
2360     name = "linker_wrapper_opts_gen",
2361     tbl_outs = [(
2362         "-gen-opt-parser-defs",
2363         "tools/clang-linker-wrapper/LinkerWrapperOpts.inc",
2364     )],
2365     tblgen = "//llvm:llvm-tblgen",
2366     td_file = "tools/clang-linker-wrapper/LinkerWrapperOpts.td",
2367     td_srcs = [
2368         "tools/clang-linker-wrapper/LinkerWrapperOpts.td",
2369         "//llvm:include/llvm/Option/OptParser.td",
2370     ],
2373 cc_binary(
2374     name = "clang-linker-wrapper",
2375     srcs = [
2376         "tools/clang-linker-wrapper/ClangLinkerWrapper.cpp",
2377         "tools/clang-linker-wrapper/OffloadWrapper.cpp",
2378         "tools/clang-linker-wrapper/OffloadWrapper.h",
2379     ],
2380     copts = [
2381         "-I$(GENDIR)/$(WORKSPACE_ROOT)/clang/tools/clang-linker-wrapper",
2382     ],
2383     stamp = 0,
2384     toolchains = [
2385         ":workspace_root",
2386     ],
2387     deps = [
2388         ":basic",
2389         ":linker_wrapper_opts_gen",
2390         "//llvm:AllTargetsAsmParsers",
2391         "//llvm:Analysis",
2392         "//llvm:BinaryFormat",
2393         "//llvm:BitWriter",
2394         "//llvm:CodeGen",
2395         "//llvm:Core",
2396         "//llvm:IRReader",
2397         "//llvm:LTO",
2398         "//llvm:MC",
2399         "//llvm:Object",
2400         "//llvm:Option",
2401         "//llvm:Passes",
2402         "//llvm:Support",
2403         "//llvm:Target",
2404         "//llvm:TargetParser",
2405         "//llvm:TransformUtils",
2406     ],
2409 cc_binary(
2410     name = "clang-refactor",
2411     srcs = glob([
2412         "tools/clang-refactor/*.cpp",
2413         "tools/clang-refactor/*.h",
2414     ]),
2415     stamp = 0,
2416     deps = [
2417         ":ast",
2418         ":basic",
2419         ":format",
2420         ":frontend",
2421         ":lex",
2422         ":rewrite",
2423         ":tooling",
2424         ":tooling_refactoring",
2425         "//llvm:Support",
2426     ],
2429 cc_binary(
2430     name = "clang-rename",
2431     srcs = glob(["tools/clang-rename/*.cpp"]),
2432     stamp = 0,
2433     deps = [
2434         ":basic",
2435         ":frontend",
2436         ":rewrite",
2437         ":tooling",
2438         ":tooling_refactoring",
2439         "//llvm:Support",
2440     ],
2443 cc_binary(
2444     name = "clang-repl",
2445     srcs = glob(["tools/clang-repl/*.cpp"]),
2446     stamp = 0,
2447     deps = [
2448         ":basic",
2449         ":frontend",
2450         ":interpreter",
2451         ":tooling",
2452         "//llvm:Core",
2453         "//llvm:LineEditor",
2454         "//llvm:Option",
2455         "//llvm:OrcJIT",
2456         "//llvm:Support",
2457     ],
2460 cc_binary(
2461     name = "clang-extdef-mapping",
2462     srcs = glob(["tools/clang-extdef-mapping/*.cpp"]),
2463     stamp = 0,
2464     deps = [
2465         ":ast",
2466         ":basic",
2467         ":crosstu",
2468         ":frontend",
2469         ":tooling",
2470         "//llvm:Support",
2471     ],
2474 gentbl(
2475     name = "ScanDepsTableGen",
2476     strip_include_prefix = "tools/clang-scan-deps",
2477     tbl_outs = [(
2478         "-gen-opt-parser-defs",
2479         "tools/clang-scan-deps/Opts.inc",
2480     )],
2481     tblgen = "//llvm:llvm-tblgen",
2482     td_file = "tools/clang-scan-deps/Opts.td",
2483     td_srcs = ["//llvm:include/llvm/Option/OptParser.td"],
2486 expand_template(
2487     name = "clang-scan-deps-main",
2488     out = "clang-scan-deps-driver.cpp",
2489     substitutions = {
2490         "@TOOL_NAME@": "clang_scan_deps",
2491     },
2492     template = "//llvm:cmake/modules/llvm-driver-template.cpp.in",
2495 cc_binary(
2496     name = "clang-scan-deps",
2497     srcs = glob(["tools/clang-scan-deps/*.cpp"]) + ["clang-scan-deps-driver.cpp"],
2498     stamp = 0,
2499     deps = [
2500         ":ScanDepsTableGen",
2501         ":driver",
2502         ":frontend",
2503         ":tooling",
2504         ":tooling_dependency_scanning",
2505         "//llvm:Support",
2506         "//llvm:TargetParser",
2507     ],
2510 cc_library(
2511     name = "extract_api",
2512     srcs = glob([
2513         "lib/ExtractAPI/**/*.cpp",
2514         "lib/ExtractAPI/**/*.h",
2515     ]),
2516     hdrs = glob(["include/clang/ExtractAPI/**/*.h"]),
2517     includes = ["include"],
2518     deps = [
2519         ":ast",
2520         ":basic",
2521         ":frontend",
2522         ":index",
2523         ":lex",
2524         "//llvm:Option",
2525         "//llvm:Support",
2526         "//llvm:TargetParser",
2527     ],