0

Clarify how to run the Clang static analyzer checks

The existing Clang static analyzer docs mention Clang
flags to use, but it wasn't immediately clear to me
how to actually use those to analyze Chromium code.
This CL adds a paragraph talking about how to execute
the analyzer checks using clang-tidy.

Bug: None
Change-Id: Icef2072f5dd55db96adbbdf72d12329fbde1e767
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3417921
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Andrew Williams <awillia@chromium.org>
Cr-Commit-Position: refs/heads/main@{#964010}
This commit is contained in:
Andrew Williams
2022-01-27 13:56:23 +00:00
committed by Chromium LUCI CQ
parent 92a7f8558e
commit 042e060af6
2 changed files with 14 additions and 0 deletions

@ -31,6 +31,17 @@ As of this writing, the checker suites we support are
[cplusplus](https://clang-analyzer.llvm.org/available_checks.html#cplusplus_checkers), and
[deadcode](https://clang-analyzer.llvm.org/available_checks.html#deadcode_checkers).
To easily run these checks against Chromium code via clang-tidy, follow
[these](clang_tidy.md#evaluating_running-clang_tidy-across-chromium)
instructions to pull down `tricium_clang_tidy.py` and then pass the following
argument when invoking the script (`-*` disables all checks and then the
remaining check name globs enable each category of checks):
```
--tidy_checks="-*,clang-analyzer-core*,clang-analyzer-cplusplus*,clang-analyzer-unix*,clang-analyzer-deadcode*"
```
A full list of Clang analyzer checks can be found in the
[Clang-Tidy Checks List](https://clang.llvm.org/extra/clang-tidy/checks/list.html).
## Addressing false positives
Some of the errors you encounter will be false positives, which occurs when the

@ -83,6 +83,9 @@ $ ${chromium_build}/recipes/recipe_modules/tricium_clang_tidy/resources/tricium_
--all
```
To only run clang-tidy against certain files, replace the `--all` parameter with
the individual file paths.
All clang-tidy checks are run on Linux builds of Chromium, so please set up your
`args.gn` to build Linux.