[clang-tools-extra] [clang-tidy] add option to avoid "no checks enabled" error (PR #96122)

Julian Schmidt via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 20 04:47:28 PDT 2024


================
@@ -651,7 +659,7 @@ int clangTidyMain(int argc, const char **argv) {
     return 0;
   }
 
-  if (EnabledChecks.empty()) {
+  if (EnabledChecks.empty() && !AllowNoChecks) {
     llvm::errs() << "Error: no checks enabled.\n";
     llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true);
     return 1;
----------------
5chmidti wrote:

I think it would be better to exit clang-tidy at this point, when there are no checks present and `AllowNoChecks` is enabled. The current behavior of this PR for invoking `clang-tidy` to check a file would be:
- if no checks are enabled and `AllowNoChecks` is true
  - continue executing clang-tidy even though no checks are enabled

I think it should be:
- if no checks are enabled
  - if `AllowNoChecks` is true then `return 0`, else error out with `return 1`

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


More information about the cfe-commits mailing list