Skip to content
Merged
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
34 changes: 20 additions & 14 deletions man/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,18 @@ need to use both approaches. Later chapters will describe this in more detail.

With `--file-filter=<str>` you can configure file filter(s) and then only those files matching the filter will be checked.

For example, this command below means that `src/test1.cpp` and `src/test/file1.cpp` could be checked, but `src/file2.cpp` will not be checked:

cppcheck src/ --file-filter=src/test*

You can use `**`, `*` and `?` in the file filter pattern.
`**`: matches zero or more characters, including path separators
`*`: matches zero or more characters, excluding path separators
`?`: matches any single character except path separators

For example, this command below means that `src/test1.cpp` could be checked, but `src/file2.cpp` and `src/test/file1.cpp` will not be checked:

cppcheck src/ --file-filter=src/test*

Cppcheck first collects all files in the specified directory, then applies the filter. Therefore, the filter pattern
must include the directory path you specified.

A common use case for `--file-filter` is to check a project, but only check certain files:

cppcheck --project=compile_commands.json --file-filter=src/*.c
Expand Down Expand Up @@ -150,8 +153,8 @@ By default Cppcheck uses an internal C/C++ parser. However there is an experimen

Install `clang`. Then use Cppcheck option `--clang`.

Technically, Cppcheck will execute `clang` with its `-ast-dump` option. The Clang output is then imported and converted into
the normal Cppcheck format. And then normal Cppcheck analysis is performed on that.
Cppcheck executes clang with the -ast-dump option, imports the output, converts it to Cppcheck's internal format, and then
performs standard analysis.

You can also pass a custom Clang executable to the option by using for example `--clang=clang-10`. You can also pass it
with a path. On Windows it will append the `.exe` extension unless you use a path.
Expand Down Expand Up @@ -191,9 +194,8 @@ be improved.

Cppcheck instantiates the templates in your code.

If your templates are recursive this can lead to slow analysis that uses a lot
of memory. Cppcheck will write information messages when there are potential
problems.
If your templates are recursive, this can lead to slow analysis and high memory usage. Cppcheck will write information
messages when there are potential problems.

Example code:

Expand Down Expand Up @@ -250,7 +252,7 @@ Using a Cppcheck build folder is not mandatory but it is recommended.

Cppcheck save analyzer information in that folder.

The advantages are;
The advantages are:

- It speeds up the analysis as it makes incremental analysis possible. Only changed files are analyzed when you recheck.
- Whole program analysis also when multiple threads are used.
Expand Down Expand Up @@ -286,7 +288,7 @@ To ignore certain folders in the project you can use `-i`. This will skip the an

## CMake

Generate a compile database:
Generate a compile database (a JSON file containing compilation commands for each source file):

cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .

Expand Down Expand Up @@ -369,9 +371,12 @@ Here is a file that has 3 bugs (when x,y,z are assigned).
#error C must be defined
#endif

The flag `-D` tells Cppcheck that a name is defined. Cppcheck will only analyze configurations that
contain this define.

The flag `-U` tells Cppcheck that a name is not defined. Cppcheck will only analyze configurations
that does not contain this define.

The flag `-D` tells Cppcheck that a name is defined. There will be no Cppcheck analysis without this define.
The flag `-U` tells Cppcheck that a name is not defined. There will be no Cppcheck analysis with this define.
The flag `--force` and `--max-configs` is used to control how many combinations are checked. When `-D` is used,
Cppcheck will only check 1 configuration unless these are used.

Expand Down Expand Up @@ -477,7 +482,8 @@ build dir. For instance, the unusedFunction warnings require whole program analy

If you want to filter out certain errors from being generated, then it is possible to suppress these.

If you encounter a false positive, then please report it to the Cppcheck team so that it can be fixed.
If you encounter a false positive, please report it to the Cppcheck team so that the issue can be
fixed.

## Plain text suppressions

Expand Down