-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[clang-tidy] Fix bazel build after #131804 (lazy style). #159289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang-tidy] Fix bazel build after #131804 (lazy style). #159289
Conversation
This PR provides a quick fix for the bazel builds that got broken by llvm#131804. That PR introduced a new CMake option that enables custom clang-tidy checks that are provided by cmake-query. This PR disables those checks, which is the minimal fix. A more proper fix would introduce a new `custom` check that is added to the tool if a particular flag value is set; however, the library depends on clang-query, which isn't part of the bazel build, yet, and I don't want to spend the time now to make all of that work as well. The discussion in the PR provides my current state in case somebody wants to pick up that work. Signed-off-by: Ingo Müller <[email protected]>
The following are some changes I did locally that create a diff --git a/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel
index f779be14ee46..ea48231bf981 100644
--- a/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel
@@ -15,6 +15,21 @@ package(
licenses(["notice"])
+# Include query-based custom checks in clang-tidy. Usage:
+# $ bazel build --@llvm-project//clang-tools-extra/clang-tidy:enable_query_based_custom_checks=true //...
+# $ bazel build --@llvm-project//clang-tools-extra/clang-tidy:enable_query_based_custom_checks=false //...
+bool_flag(
+ name = "enable_query_based_custom_checks",
+ build_setting_default = True,
+)
+
+config_setting(
+ name = "query_based_custom_checks_enabled",
+ flag_values = {
+ ":enable_query_based_custom_checks": "true",
+ },
+)
+
# Include static analyzer checks in clang-tidy. Usage:
# $ bazel build --@llvm-project//clang-tools-extra/clang-tidy:enable_static_analyzer=true //...
# $ bazel build --@llvm-project//clang-tools-extra/clang-tidy:enable_static_analyzer=false //...
@@ -40,6 +55,13 @@ expand_template(
"//conditions:default": {
"#cmakedefine01 CLANG_TIDY_ENABLE_STATIC_ANALYZER": "#define CLANG_TIDY_ENABLE_STATIC_ANALYZER 0",
},
+ }) | select({
+ ":query_based_custom_checks_enabled": {
+ "#cmakedefine01 CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS": "#define CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS 1",
+ },
+ "//conditions:default": {
+ "#cmakedefine01 CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS": "#define CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS 0",
+ },
}),
template = "clang-tidy-config.h.cmake",
visibility = ["//visibility:private"],
@@ -209,6 +231,15 @@ clang_tidy_library(
deps = [":lib"],
)
+clang_tidy_library(
+ name = "custom",
+ deps = [
+ ":lib",
+ ":utils",
+ "//clang:ast_matchers_dynamic",
+ ],
+)
+
clang_tidy_library(
name = "darwin",
deps = [":lib"],
@@ -359,6 +390,9 @@ CHECKS = [
] + select({
":static_analyzer_enabled": [":mpi"],
"//conditions:default": [],
+}) + select({
+ ":query_based_custom_checks_enabled": [":custom"],
+ "//conditions:default": [],
})
cc_library( |
Is this related to #131804 (comment)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I think disabling this new option is good enough for now.
Yes, as per the title. Why? |
I tried to understand context of what this fix was. |
…tyle)." (#159382) Reverts llvm/llvm-project#159289. This is a fix for #131804, which is being reverted.
…9289) This PR provides a quick fix for the bazel builds that got broken by llvm#131804. That PR introduced a new CMake option that enables custom clang-tidy checks that are provided by cmake-query. This PR disables those checks, which is the minimal fix. A more proper fix would introduce a new `custom` check that is added to the tool if a particular flag value is set; however, the library depends on clang-query, which isn't part of the bazel build, yet, and I don't want to spend the time now to make all of that work as well. The discussion in the PR provides my current state in case somebody wants to pick up that work. Signed-off-by: Ingo Müller <[email protected]>
…llvm#159382) Reverts llvm#159289. This is a fix for llvm#131804, which is being reverted.
This PR provides a quick fix for the bazel builds that got broken by #131804. That PR introduced a new CMake option that enables custom clang-tidy checks that are provided by cmake-query. This PR disables those checks, which is the minimal fix. A more proper fix would introduce a new
custom
check that is added to the tool if a particular flag value is set; however, the library depends on clang-query, which isn't part of the bazel build, yet, and I don't want to spend the time now to make all of that work as well. The discussion in the PR provides my current state in case somebody wants to pick up that work.