[clang-tools-extra] [llvm] [clang-tidy] Remove 'clang-analyzer-*' checks from default checks. (PR #157306)

via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 21 14:01:14 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- clang-tools-extra/test/clang-tidy/infrastructure/clang-analyzer-soft-deprecation.cpp clang-tools-extra/test_here.cpp test_warning.cpp clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index b85867def..bbed906de 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -646,16 +646,18 @@ int clangTidyMain(int argc, const char **argv) {
 
   // Check for soft deprecation warning for clang-analyzer-* checks
   if (!Quiet) {
-    bool HasAnalyzerChecks = llvm::any_of(EnabledChecks, [](const std::string &Check) {
-      return StringRef(Check).starts_with("clang-analyzer-");
-    });
+    bool HasAnalyzerChecks =
+        llvm::any_of(EnabledChecks, [](const std::string &Check) {
+          return StringRef(Check).starts_with("clang-analyzer-");
+        });
 
     if (!HasAnalyzerChecks) {
-      // Check if user explicitly mentioned clang-analyzer-* in their configuration
+      // Check if user explicitly mentioned clang-analyzer-* in their
+      // configuration
       bool ExplicitlyMentioned = false;
       std::vector<clang::tidy::ClangTidyOptionsProvider::OptionsSource>
           RawOptions = OptionsProvider->getRawOptions(FilePath);
-      
+
       for (const auto &[Opts, Source] : RawOptions) {
         if (Opts.Checks) {
           GlobList CheckGlobs(*Opts.Checks);
@@ -665,15 +667,17 @@ int clangTidyMain(int argc, const char **argv) {
               break;
             }
           }
-          if (ExplicitlyMentioned) break;
+          if (ExplicitlyMentioned)
+            break;
         }
       }
 
       // Only show warning if user is using default checks or wildcard patterns
-      // that would have included clang-analyzer-* in the past  
+      // that would have included clang-analyzer-* in the past
       bool ShouldWarn = false;
       if (!ExplicitlyMentioned && !EnabledChecks.empty()) {
-        // Show warning if using defaults (no -checks specified and no config file checks)
+        // Show warning if using defaults (no -checks specified and no config
+        // file checks)
         if (Checks.getNumOccurrences() == 0) {
           bool HasConfigChecks = false;
           for (const auto &[Opts, Source] : RawOptions) {
@@ -691,8 +695,8 @@ int clangTidyMain(int argc, const char **argv) {
           // Check command line checks
           if (Checks.getNumOccurrences() > 0) {
             StringRef CheckStr = Checks;
-            if ((CheckStr == "*" || CheckStr.starts_with("*,") || 
-                 CheckStr.contains(",*,") || CheckStr.ends_with(",*")) && 
+            if ((CheckStr == "*" || CheckStr.starts_with("*,") ||
+                 CheckStr.contains(",*,") || CheckStr.ends_with(",*")) &&
                 !CheckStr.contains("clang-analyzer-")) {
               ShouldWarn = true;
             }
@@ -702,8 +706,8 @@ int clangTidyMain(int argc, const char **argv) {
             for (const auto &[Opts, Source] : RawOptions) {
               if (Opts.Checks) {
                 StringRef CheckStr = *Opts.Checks;
-                if ((CheckStr == "*" || CheckStr.starts_with("*,") || 
-                     CheckStr.contains(",*,") || CheckStr.ends_with(",*")) && 
+                if ((CheckStr == "*" || CheckStr.starts_with("*,") ||
+                     CheckStr.contains(",*,") || CheckStr.ends_with(",*")) &&
                     !CheckStr.contains("clang-analyzer-")) {
                   ShouldWarn = true;
                   break;
diff --git a/test_warning.cpp b/test_warning.cpp
index 2846e7130..85af7b469 100644
--- a/test_warning.cpp
+++ b/test_warning.cpp
@@ -1,4 +1,2 @@
 // Simple test file for testing clang-tidy soft deprecation warning
-int main() {
-    return 0;
-}
\ No newline at end of file
+int main() { return 0; }
\ No newline at end of file

``````````

</details>


https://github.com/llvm/llvm-project/pull/157306


More information about the llvm-commits mailing list