Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

ingomueller-net
Copy link
Contributor

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.

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]>
@llvmbot llvmbot added the bazel "Peripheral" support tier build system: utils/bazel label Sep 17, 2025
@ingomueller-net
Copy link
Contributor Author

The following are some changes I did locally that create a custom check enabled by a flag. However, it does not build yet because it cannot find the headers of clang-query, which would need more work.

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(

@vbvictor
Copy link
Contributor

Is this related to #131804 (comment)?

Copy link
Member

@akuegel akuegel left a 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.

@ingomueller-net ingomueller-net merged commit 01ee9fe into llvm:main Sep 17, 2025
12 checks passed
@ingomueller-net
Copy link
Contributor Author

Is this related to #131804 (comment)?

Yes, as per the title. Why?

@vbvictor
Copy link
Contributor

vbvictor commented Sep 17, 2025

Is this related to #131804 (comment)?

Yes, as per the title. Why?

I tried to understand context of what this fix was.
Appeared to be to different issues: Bazel and Cmake

ingomueller-net added a commit that referenced this pull request Sep 17, 2025
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Sep 17, 2025
…tyle)." (#159382)

Reverts llvm/llvm-project#159289.

This is a fix for #131804, which is being reverted.
kimsh02 pushed a commit to kimsh02/llvm-project that referenced this pull request Sep 19, 2025
…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]>
kimsh02 pushed a commit to kimsh02/llvm-project that referenced this pull request Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bazel "Peripheral" support tier build system: utils/bazel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants