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")
12 default_visibility = ["//visibility:public"],
13 features = ["layering_check"],
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 //...
22 name = "enable_static_analyzer",
23 build_setting_default = True,
27 name = "static_analyzer_enabled",
29 ":enable_static_analyzer": "true",
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",
40 "//conditions:default": {
41 "#cmakedefine01 CLANG_TIDY_ENABLE_STATIC_ANALYZER": "#define CLANG_TIDY_ENABLE_STATIC_ANALYZER 0",
44 template = "clang-tidy-config.h.cmake",
45 visibility = ["//visibility:private"],
49 name = "confusable_table_builder",
50 srcs = ["misc/ConfusableTable/BuildConfusableTable.cpp"],
51 visibility = ["//visibility:private"],
52 deps = ["//llvm:Support"],
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"],
66 hdrs = [":confusables_inc"],
72 srcs = glob(["*.cpp"]) + [":config"],
78 "//clang:frontend_rewrite",
81 "//clang:serialization",
82 "//clang:static_analyzer_checkers_gen",
84 "//clang:tooling_core",
86 ":static_analyzer_enabled": [
87 "//clang:static_analyzer_core",
88 "//clang:static_analyzer_frontend",
90 "//conditions:default": [],
102 "//clang:serialization",
104 "//clang:tooling_core",
105 "//clang:tooling_inclusions",
106 "//clang-tools-extra/include-cleaner:include_cleaner",
111 name = "portability",
114 "//llvm:TargetParser",
125 "//clang:transformer",
130 name = "readability",
181 "//clang:transformer",
207 name = "concurrency",
217 name = "linuxkernel",
234 "//clang:static_analyzer_checkers",
235 "//clang:static_analyzer_core",
236 "//clang:static_analyzer_frontend",
266 name = "cppcoreguidelines",
281 ":cppcoreguidelines",
286 "//clang:transformer",
291 name = "performance",
318 ":cppcoreguidelines",
341 ":cppcoreguidelines",
358 ":static_analyzer_enabled": [":mpi"],
359 "//conditions:default": [],
364 srcs = ["tool/ClangTidyMain.cpp"],
365 hdrs = ["tool/ClangTidyMain.h"],
376 srcs = ["tool/ClangTidyToolMain.cpp"],
382 name = "run-clang-tidy",
383 src = "tool/run-clang-tidy.py",
384 out = "run-clang-tidy",
385 data = [":clang-tidy"],