Skip to content

Commit a36c464

Browse files
committed
Fixed #14266 (documentation: clarify how -i works)
1 parent 9ab1585 commit a36c464

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

cli/cmdlineparser.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,9 +1837,10 @@ void CmdLineParser::printHelp(bool premium) const
18371837
" this is not needed.\n"
18381838
" --include=<file>\n"
18391839
" Force inclusion of a file before the checked file.\n"
1840-
" -i <str> Exclude source files or directories matching str from\n"
1841-
" the check. This applies only to source files so header\n"
1842-
" files included by source files are not matched.\n"
1840+
" -i <str> Skip translation units whose *source filename* matches\n"
1841+
" '<str>'. '<str>' can be a filename or directory.\n"
1842+
" Note: If you want to prevent warnings in some headers,\n"
1843+
" use suppressions instead.\n"
18431844
" --inconclusive Allow that Cppcheck reports even though the analysis is\n"
18441845
" inconclusive.\n"
18451846
" There are false positives with this option. Each result\n"

man/manual.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@ Typically a `compile_commands.json` contains absolute paths. However no matter i
126126
* a file with relative path `src/test2.c` can be checked.
127127
* a file with relative path `src/test3.cpp` is not checked.
128128

129-
### Excluding a file or folder from checking
129+
### Exclude files matching a given pattern
130130

131-
The option `-i` specifies a pattern to files/folders to exclude. With this command no files in `src/c` are checked:
131+
With `-i <str>` you can configure filename/directory patterns that should be excluded from checking.
132132

133-
cppcheck -isrc/c src
133+
> *Note*: If you want to filter out warnings for a header file then `-i` will not work. The option `--suppress` should be used instead.
134134
135-
The `-i` option is not used during preprocessing, it can't be used to exclude headers that are included.
135+
Translation units are skipped if their *source filename* matches the exclusion pattern. This filtering happens *before* preprocessing, and the exclusion patterns are not applied during preprocessing or analysis.
136136

137137
You can use `**`, `*` and `?` in the pattern to specify excluded folders/files.
138138
`**`: matches zero or more characters, including path separators

0 commit comments

Comments
 (0)