llvm-project/clang-tools-extra
Baranov Victor ed26993976
[clang-tidy] Improve "-quiet" option by suppressing "xxx warnings generated" (#154012)
Before this change, `-quiet` mode in clang-tidy generated meaningless
messages `xxx warnings generated` in output:
```cpp
// main.cpp
#include <iostream>

int main() {
  std::cout << 42;
}
```
```console
> clang-tidy -checks='-*,readability-magic-numbers' -quiet main.cpp

82 warnings generated.
main.cpp:4:16: warning: 42 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
    4 |   std::cout << 42;
      |                ^
```

As you can see, `82 warnings generated.` does not say much `quiet` mode,
this patch removes this message completely:

```console
> ./build/bin/clang-tidy -p build -checks='-*,readability-magic-numbers' -quiet main.cpp

main.cpp:4:16: warning: 42 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
    4 |   std::cout << 42;
      |                ^
```

In contrast, when running without `quiet`, It gives some meaningful
information because we know how many messages were suppressed thus
calculating total messages count:
```console
> clang-tidy -checks='-*,readability-magic-numbers' main.cpp

82 warnings generated.
main.cpp:4:16: warning: 42 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
    4 |   std::cout << 42;
      |                ^
Suppressed 81 warnings (81 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
```

Fixes #47042
2025-08-19 21:47:51 +03:00
..
2024-09-19 07:54:06 -04:00

//===----------------------------------------------------------------------===//
// Clang Tools repository
//===----------------------------------------------------------------------===//

Welcome to the repository of extra Clang Tools.  This repository holds tools
that are developed as part of the LLVM compiler infrastructure project and the
Clang frontend.  These tools are kept in a separate "extra" repository to
allow lighter weight checkouts of the core Clang codebase.

All discussion regarding Clang, Clang-based tools, and code in this repository
should be held using the standard Clang forums:
  https://discourse.llvm.org/c/clang
  https://discourse.llvm.org/c/clang/clang-tidy/71
  https://discourse.llvm.org/c/clang/clangd/34

Code review for this tree should take place on Github:
  https://github.com/llvm/llvm-project/pulls?q=label%3Aclang-tools-extra

If you find a bug in these tools, please file it in the LLVM bug tracker:
  https://github.com/llvm/llvm-project/issues/