You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Typically a `compile_commands.json` contains absolute paths. However no matter if `compile_commands.json` contains absolute paths or relative paths, the option `--file-filter=src/*.c` would mean that:
122
+
* a file with relative path `test1.c` is not checked.
123
+
* a file with relative path `src/test2.c` can be checked.
124
+
* a file with relative path `src/test3.cpp` is not checked.
122
125
123
-
All files under src/a and src/b are then checked.
126
+
### Excluding a file or folder from checking
124
127
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:
128
+
The option `-i` specifies a pattern to files/folders to exclude. With this command no files in `src/c` are checked:
127
129
128
130
cppcheck -isrc/c src
129
131
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:
132
+
The `-i` option is not used during preprocessing, it can't be used to exclude headers that are included.
133
+
134
+
You can use `**`, `*` and `?` in the pattern to specify excluded folders/files.
135
+
`**`: matches zero or more characters, including path separators
136
+
`*`: matches zero or more characters, excluding path separators
137
+
`?`: matches any single character except path separators
138
+
139
+
A use case for `-i` is to check a project, but exclude certain files/folders:
132
140
133
-
cppcheck -isrc/b -isrc/c
141
+
cppcheck --project=compile_commands.json -itest
142
+
143
+
Typically a `compile_commands.json` contains absolute paths. However no matter if `compile_commands.json` contains absolute paths or relative paths, the option `-itest` would mean that:
144
+
* a file with relative path `test1.cpp` can be checked.
145
+
* a file with relative path `test/somefile.cpp` is not checked
134
146
135
147
### Clang parser (experimental)
136
148
@@ -475,19 +487,22 @@ The format for an error suppression is one of:
475
487
[error id]:[filename2]
476
488
[error id]
477
489
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.
490
+
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.
491
+
492
+
The `error id` and `filename` patterns may contain `**`, `*` or `?`.
493
+
`**`: matches zero or more characters, including path separators
494
+
`*`: matches zero or more characters, excluding path separators
495
+
`?`: matches any single character except path separators
479
496
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.
497
+
It is recommended to use forward-slash `/` in the filename pattern as path separator on all operating systems.
483
498
484
-
## Command line suppression
499
+
###Command line suppression
485
500
486
501
The `--suppress=` command line option is used to specify suppressions on the command line. Example:
487
502
488
503
cppcheck --suppress=memleak:src/file1.cpp src/
489
504
490
-
## Suppressions in a file
505
+
###Suppressions in a file
491
506
492
507
You can create a suppressions file for example as follows:
493
508
@@ -518,6 +533,11 @@ You can specify suppressions in a XML file, for example as follows:
518
533
</suppress>
519
534
</suppressions>
520
535
536
+
The `id` and `fileName` patterns may contain `**`, `*` or `?`.
537
+
`**`: matches zero or more characters, including path separators
538
+
`*`: matches zero or more characters, excluding path separators
539
+
`?`: matches any single character except path separators
540
+
521
541
The XML format is extensible and may be extended with further attributes in the future.
0 commit comments