Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ The main Bazel rule for CodeChecker is `codechecker_test()`.

### Clang-tidy

Clang-tidy is a fast static analyzer/linter for the C family of languages. This
repository provides Bazel aspect `clang_tidy_aspect()` and rule `clang_tidy_test()`
Clang-tidy is a fast static analyzer/linter for the C family of languages.
This repository provides Bazel rule `clang_tidy_test()`
to run clang-tidy natively (without CodeChecker).

Find more information about LLVM clang-tidy:
Expand Down Expand Up @@ -313,9 +313,10 @@ codechecker_test(

The following rules are _not_ using CodeChecker.

### Clang-tidy: `clang_tidy_aspect()` and `clang_tidy_test()`
### Clang-tidy: `clang_tidy_test()`

The Bazel rule `clang_tidy_test()` runs clang-tidy natively without CodeChecker. To use it, add the following to your BUILD file:
The Bazel rule `clang_tidy_test()` runs clang-tidy natively without CodeChecker.
To use it, add the following to your BUILD file:

```python
load(
Expand All @@ -331,15 +332,11 @@ clang_tidy_test(
)
```

You can also run clang-tidy via the Bazel aspect `clang_tidy_aspect()` that can be invoked from the command line by passing the following parameter to Bazel build/test: `--aspects @codechecker_bazel//src:clang.bzl%clang_tidy_aspect`:

```bash
bazel build ... --aspects @codechecker_bazel//src:clang.bzl%clang_tidy_aspect --output_groups=report
```

### Clang Static Analyzer: `clang_analyze_test()`

The Bazel rule `clang_analyze_test()` runs The Clang Static Analyzer natively without CodeChecker. To use it, add the following to your BUILD file:
The Bazel rule `clang_analyze_test()` runs The Clang Static Analyzer
natively without CodeChecker.
To use it, add the following to your BUILD file:

```python
load(
Expand All @@ -355,6 +352,9 @@ clang_analyze_test(
)
```

> [!Note]
> Currently `clang_analyze_test()` rule does not support CTU (Cross Translation Unit) analysis.

### Generating a compilation database: `compile_commands()`

As generating a compilation database for C/C++ is a known pain point for bazel, this repository defines the Bazel rule `compile_commands()` rule which can be used independently of CodeChecker. The implementation is based on https://github.com/grailbio/bazel-compilation-database with some fixes on some tricky edge cases. To use it, include the following in your BUILD file:
Expand Down Expand Up @@ -420,7 +420,3 @@ After that you can find all artifacts in `bazel-bin` directory:

# compile_commands.json for compile_commands_pass
cat bazel-bin/test/compile_commands_pass/compile_commands.json

To run `clang_tidy_aspect()` on all C/C++ code:

bazel build ... --aspects @codechecker_bazel//src:clang.bzl%clang_tidy_aspect --output_groups=report
Loading