[llvm][llvm-readobj] Add NT_ARM_GCS Linux core note type (#117545)
[llvm-project.git] / utils / bazel / llvm-project-overlay / clang-tools-extra / clang-tidy / BUILD.bazel
blobdb53df08fecc86aeddb62866526a125956a8a8a6
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:common_settings.bzl", "bool_flag")
6 load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
7 load("@bazel_skylib//rules:native_binary.bzl", "native_binary")
8 load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
9 load("defs.bzl", "clang_tidy_library")
11 package(
12     default_visibility = ["//visibility:public"],
13     features = ["layering_check"],
16 licenses(["notice"])
18 # Include static analyzer checks in clang-tidy. Usage:
19 #   $ bazel build --@llvm-project//clang-tools-extra/clang-tidy:enable_static_analyzer=true //...
20 #   $ bazel build --@llvm-project//clang-tools-extra/clang-tidy:enable_static_analyzer=false //...
21 bool_flag(
22     name = "enable_static_analyzer",
23     build_setting_default = True,
26 config_setting(
27     name = "static_analyzer_enabled",
28     flag_values = {
29         ":enable_static_analyzer": "true",
30     },
33 expand_template(
34     name = "config",
35     out = "clang-tidy-config.h",
36     substitutions = select({
37         ":static_analyzer_enabled": {
38             "#cmakedefine01 CLANG_TIDY_ENABLE_STATIC_ANALYZER": "#define CLANG_TIDY_ENABLE_STATIC_ANALYZER 1",
39         },
40         "//conditions:default": {
41             "#cmakedefine01 CLANG_TIDY_ENABLE_STATIC_ANALYZER": "#define CLANG_TIDY_ENABLE_STATIC_ANALYZER 0",
42         },
43     }),
44     template = "clang-tidy-config.h.cmake",
45     visibility = ["//visibility:private"],
48 cc_binary(
49     name = "confusable_table_builder",
50     srcs = ["misc/ConfusableTable/BuildConfusableTable.cpp"],
51     visibility = ["//visibility:private"],
52     deps = ["//llvm:Support"],
55 genrule(
56     name = "confusables_inc",
57     srcs = ["misc/ConfusableTable/confusables.txt"],
58     outs = ["Confusables.inc"],
59     cmd = "$(location :confusable_table_builder) $(SRCS) $(OUTS)",
60     tools = [":confusable_table_builder"],
61     visibility = ["//visibility:private"],
64 cc_library(
65     name = "confusables",
66     hdrs = [":confusables_inc"],
67     include_prefix = ".",
70 clang_tidy_library(
71     name = "lib",
72     srcs = glob(["*.cpp"]) + [":config"],
73     hdrs = glob(["*.h"]),
74     includes = ["."],
75     deps = [
76         "//clang:analysis",
77         "//clang:format",
78         "//clang:frontend_rewrite",
79         "//clang:rewrite",
80         "//clang:sema",
81         "//clang:serialization",
82         "//clang:static_analyzer_checkers_gen",
83         "//clang:tooling",
84         "//clang:tooling_core",
85     ] + select({
86         ":static_analyzer_enabled": [
87             "//clang:static_analyzer_core",
88             "//clang:static_analyzer_frontend",
89         ],
90         "//conditions:default": [],
91     }),
94 clang_tidy_library(
95     name = "misc",
96     deps = [
97         ":confusables",
98         ":lib",
99         ":utils",
100         "//clang:analysis",
101         "//clang:format",
102         "//clang:serialization",
103         "//clang:tooling",
104         "//clang:tooling_core",
105         "//clang:tooling_inclusions",
106         "//clang-tools-extra/include-cleaner:include_cleaner",
107     ],
110 clang_tidy_library(
111     name = "portability",
112     deps = [
113         ":lib",
114         "//llvm:TargetParser",
115     ],
118 clang_tidy_library(
119     name = "utils",
120     deps = [
121         ":lib",
122         "//clang:analysis",
123         "//clang:sema",
124         "//clang:tooling",
125         "//clang:transformer",
126     ],
129 clang_tidy_library(
130     name = "readability",
131     deps = [
132         ":lib",
133         ":utils",
134         "//clang:analysis",
135         "//clang:tooling",
136     ],
139 clang_tidy_library(
140     name = "google",
141     deps = [
142         ":lib",
143         ":readability",
144         ":utils",
145     ],
148 clang_tidy_library(
149     name = "fuchsia",
150     deps = [
151         ":google",
152         ":lib",
153     ],
156 clang_tidy_library(
157     name = "llvm",
158     deps = [
159         ":lib",
160         ":readability",
161         ":utils",
162         "//clang:tooling",
163     ],
166 clang_tidy_library(
167     name = "llvmlibc",
168     deps = [
169         ":lib",
170         ":portability",
171         ":utils",
172     ],
175 clang_tidy_library(
176     name = "abseil",
177     deps = [
178         ":lib",
179         ":utils",
180         "//clang:tooling",
181         "//clang:transformer",
182     ],
185 clang_tidy_library(
186     name = "altera",
187     deps = [":lib"],
190 clang_tidy_library(
191     name = "android",
192     deps = [
193         ":lib",
194         ":utils",
195     ],
198 clang_tidy_library(
199     name = "boost",
200     deps = [
201         ":lib",
202         ":utils",
203     ],
206 clang_tidy_library(
207     name = "concurrency",
208     deps = [":lib"],
211 clang_tidy_library(
212     name = "darwin",
213     deps = [":lib"],
216 clang_tidy_library(
217     name = "linuxkernel",
218     deps = [":lib"],
221 clang_tidy_library(
222     name = "modernize",
223     deps = [
224         ":lib",
225         ":utils",
226         "//clang:tooling",
227     ],
230 clang_tidy_library(
231     name = "mpi",
232     deps = [
233         ":lib",
234         "//clang:static_analyzer_checkers",
235         "//clang:static_analyzer_core",
236         "//clang:static_analyzer_frontend",
237         "//clang:tooling",
238     ],
241 clang_tidy_library(
242     name = "objc",
243     deps = [
244         ":lib",
245         ":utils",
246     ],
249 clang_tidy_library(
250     name = "openmp",
251     deps = [
252         ":lib",
253         ":utils",
254     ],
257 clang_tidy_library(
258     name = "zircon",
259     deps = [
260         ":lib",
261         ":utils",
262     ],
265 clang_tidy_library(
266     name = "cppcoreguidelines",
267     deps = [
268         ":lib",
269         ":misc",
270         ":modernize",
271         ":performance",
272         ":readability",
273         ":utils",
274         "//clang:analysis",
275     ],
278 clang_tidy_library(
279     name = "bugprone",
280     deps = [
281         ":cppcoreguidelines",
282         ":lib",
283         ":utils",
284         "//clang:analysis",
285         "//clang:tooling",
286         "//clang:transformer",
287     ],
290 clang_tidy_library(
291     name = "performance",
292     deps = [
293         ":lib",
294         ":utils",
295         "//clang:analysis",
296         "//clang:tooling",
297     ],
300 clang_tidy_library(
301     name = "cert",
302     deps = [
303         ":bugprone",
304         ":concurrency",
305         ":google",
306         ":lib",
307         ":misc",
308         ":performance",
309         ":readability",
310         ":utils",
311     ],
314 clang_tidy_library(
315     name = "hicpp",
316     deps = [
317         ":bugprone",
318         ":cppcoreguidelines",
319         ":google",
320         ":lib",
321         ":misc",
322         ":modernize",
323         ":performance",
324         ":readability",
325     ],
328 clang_tidy_library(
329     name = "plugin",
330     deps = [":lib"],
333 CHECKS = [
334     ":abseil",
335     ":altera",
336     ":android",
337     ":boost",
338     ":bugprone",
339     ":cert",
340     ":concurrency",
341     ":cppcoreguidelines",
342     ":darwin",
343     ":fuchsia",
344     ":google",
345     ":hicpp",
346     ":linuxkernel",
347     ":llvm",
348     ":llvmlibc",
349     ":misc",
350     ":modernize",
351     ":objc",
352     ":openmp",
353     ":performance",
354     ":portability",
355     ":readability",
356     ":zircon",
357 ] + select({
358     ":static_analyzer_enabled": [":mpi"],
359     "//conditions:default": [],
362 cc_library(
363     name = "tool",
364     srcs = ["tool/ClangTidyMain.cpp"],
365     hdrs = ["tool/ClangTidyMain.h"],
366     deps = CHECKS + [
367         ":lib",
368         ":utils",
369         "//clang:tooling",
370         "//llvm:Support",
371     ],
374 cc_binary(
375     name = "clang-tidy",
376     srcs = ["tool/ClangTidyToolMain.cpp"],
377     stamp = 0,
378     deps = [":tool"],
381 native_binary(
382     name = "run-clang-tidy",
383     src = "tool/run-clang-tidy.py",
384     out = "run-clang-tidy",
385     data = [":clang-tidy"],