Skip to content

Commit 0fb9bd5

Browse files
committed
Fixup #14021 (Manual: document improved path matching for suppressions, file filters, exclusions)
1 parent 0b4c55a commit 0fb9bd5

1 file changed

Lines changed: 15 additions & 22 deletions

File tree

man/manual.md

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -105,32 +105,23 @@ need to use both approaches. Later chapters will describe this in more detail.
105105

106106
With `--file-filter=<str>` you can set a file filter and only those files matching the filter will be checked.
107107

108-
For example: if you want to check only those files and folders starting from a subfolder src/ that start with "test"
109-
you have to type:
108+
For example:
110109

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

113-
Cppcheck first collects all files in src/ and will apply the filter after that. So the filter must start with the given
114-
start folder.
112+
You can use `**`, `*` and `?` in the file filter.
115113

116-
### Excluding a file or folder from checking
117-
118-
To exclude a file or folder, there are two options. The first option is to only provide the paths and files you want to
119-
check:
120-
121-
cppcheck src/a src/b
114+
The given file filter would mean for example that `src/test1.cpp` and `src/test/file1.cpp` are checked, but `src/file2.cpp` is not checked.
122115

123-
All files under src/a and src/b are then checked.
116+
### Excluding a file or folder from checking
124117

125-
The second option is to use -i, which specifies the files/paths to ignore. With this command no files in src/c are
126-
checked:
118+
The option `-i` specifies files/paths to ignore. With this command no files in `src/c` are checked:
127119

128120
cppcheck -isrc/c src
129121

130-
This option is only valid when supplying an input directory. To ignore multiple directories supply the -i flag for each
131-
directory individually. The following command ignores both the src/b and src/c directories:
122+
The `-i` option is not used during preprocessing, it can't be used to exclude headers that are included from checking.
132123

133-
cppcheck -isrc/b -isrc/c
124+
You can use `**`, `*` and `?` to specify excluded folders/files.
134125

135126
### Clang parser (experimental)
136127

@@ -475,19 +466,19 @@ The format for an error suppression is one of:
475466
[error id]:[filename2]
476467
[error id]
477468

478-
The `error id` is the id that you want to suppress. The id of a warning is shown in brackets in the normal cppcheck text output. The suppression `error id` may contain \* to match any sequence of tokens.
469+
The `error id` is the id that you want to suppress. The id of a warning is shown in brackets in the normal cppcheck text output. The suppression `error id` may contain `*` and/or `?`.
470+
471+
The filename pattern may contain `**`, `*` or `?`.
479472

480-
The filename may include the wildcard characters \* or ?, which matches any sequence of characters or any single character respectively.
481-
It is recommended to use forward-slash `/` as path separator on all operating systems. The filename must match the filename in the reported warning exactly.
482-
For instance, if the warning contains a relative path, then the suppression must match that relative path.
473+
It is recommended to use forward-slash `/` as path separator on all operating systems.
483474

484-
## Command line suppression
475+
### Command line suppression
485476

486477
The `--suppress=` command line option is used to specify suppressions on the command line. Example:
487478

488479
cppcheck --suppress=memleak:src/file1.cpp src/
489480

490-
## Suppressions in a file
481+
### Suppressions in a file
491482

492483
You can create a suppressions file for example as follows:
493484

@@ -524,6 +515,8 @@ The usage of the suppressions file is as follows:
524515

525516
cppcheck --suppress-xml=suppressions.xml src/
526517

518+
The `id` and `fileName` patterns may `**`, `*` or `?`.
519+
527520
## Inline suppressions
528521

529522
Suppressions can also be added directly in the code by adding comments that contain special keywords.

0 commit comments

Comments
 (0)