Skip to content

Commit 5b9e4ef

Browse files
committed
update manual-premium.md
1 parent 79bdf05 commit 5b9e4ef

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

man/manual-premium.md

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,18 @@ need to use both approaches. Later chapters will describe this in more detail.
104104

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

107-
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:
108-
109-
cppcheck src/ --file-filter=src/test*
110-
111107
You can use `**`, `*` and `?` in the file filter pattern.
112108
`**`: matches zero or more characters, including path separators
113109
`*`: matches zero or more characters, excluding path separators
114110
`?`: matches any single character except path separators
115111

112+
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:
113+
114+
cppcheck src/ --file-filter=src/test*
115+
116+
Cppcheck first collects all files in the specified directory, then applies the filter. Therefore, the filter pattern
117+
must include the directory path you specified.
118+
116119
A common use case for `--file-filter` is to check a project, but only check certain files:
117120

118121
cppcheck --project=compile_commands.json --file-filter=src/*.c
@@ -122,13 +125,13 @@ Typically a `compile_commands.json` contains absolute paths. However no matter i
122125
* a file with relative path `src/test2.c` can be checked.
123126
* a file with relative path `src/test3.cpp` is not checked.
124127

125-
### Excluding a file or folder from checking
128+
### Ignore files matching a given pattern
126129

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

129-
cppcheck -isrc/c src
132+
A file that is ignored will not be checked directly (the complete translation unit is skipped). Any header #include'd from a source file which is not ignored is checked indirectly, regardless if the header is ignored.
130133

131-
The `-i` option is not used during preprocessing, it can't be used to exclude headers that are included.
134+
> *Note*: If you want to filter out warnings for a header file then `-i` will not work. Use suppressions instead.
132135
133136
You can use `**`, `*` and `?` in the pattern to specify excluded folders/files.
134137
`**`: matches zero or more characters, including path separators
@@ -149,8 +152,8 @@ By default Cppcheck uses an internal C/C++ parser. However there is an experimen
149152

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

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

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

191194
Cppcheck instantiates the templates in your code.
192195

193-
If your templates are recursive this can lead to slow analysis that uses a lot
194-
of memory. Cppcheck will write information messages when there are potential
195-
problems.
196+
If your templates are recursive, this can lead to slow analysis and high memory usage. Cppcheck will write information
197+
messages when there are potential problems.
196198

197199
Example code:
198200

@@ -249,7 +251,7 @@ Using a Cppcheck build folder is not mandatory but it is recommended.
249251

250252
Cppcheck save analyzer information in that folder.
251253

252-
The advantages are;
254+
The advantages are:
253255

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

286288
## CMake
287289

288-
Generate a compile database:
290+
Generate a compile database (a JSON file containing compilation commands for each source file):
289291

290292
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
291293

@@ -368,9 +370,12 @@ Here is a file that has 3 bugs (when x,y,z are assigned).
368370
#error C must be defined
369371
#endif
370372

373+
The flag `-D` tells Cppcheck that a name is defined. Cppcheck will only analyze configurations that
374+
contain this define.
375+
376+
The flag `-U` tells Cppcheck that a name is not defined. Cppcheck will only analyze configurations
377+
that does not contain this define.
371378

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

@@ -476,7 +481,8 @@ build dir. For instance, the unusedFunction warnings require whole program analy
476481

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

479-
If you encounter a false positive, then please report it to the Cppcheck team so that it can be fixed.
484+
If you encounter a false positive, please report it to the Cppcheck team so that the issue can be
485+
fixed.
480486

481487
## Plain text suppressions
482488

@@ -1034,7 +1040,7 @@ Example configuration of naming conventions:
10341040

10351041
### y2038.py
10361042

1037-
[y2038.py](https://github.com/danmar/cppcheck/blob/main/addons/y2038.py) checks Linux systems for [year 2038 problem](https://en.wikipedia.org/wiki/Year_2038_problem) safety. This required [modified environment](https://github.com/3adev/y2038). See complete description [here](https://github.com/danmar/cppcheck/blob/main/addons/doc/y2038.txt).
1043+
[y2038.py](https://github.com/danmar/cppcheck/blob/main/addons/y2038.py) checks source code for [year 2038 problem](https://en.wikipedia.org/wiki/Year_2038_problem) safety.
10381044

10391045
## Running Addons
10401046

@@ -1073,6 +1079,7 @@ Cppcheck already contains configurations for several libraries. They can be load
10731079
## Using a .cfg file
10741080

10751081
To use a .cfg file shipped with cppcheck, pass the `--library=<lib>` option. The table below shows the currently existing libraries:
1082+
10761083
| .cfg file | Library | Comment |
10771084
| ----------------- | ------------- | ------------- |
10781085
| avr.cfg | | |
@@ -1082,7 +1089,7 @@ To use a .cfg file shipped with cppcheck, pass the `--library=<lib>` option. The
10821089
| cairo.cfg | [cairo](https://www.cairographics.org/) | |
10831090
| cppcheck-lib.cfg | [Cppcheck](http://cppcheck.net/) | Used in selfcheck of |
10841091
| | |the Cppcheck code base |
1085-
| cppunit.cfg | [CppUnit](https://sourceforge.net/projects/cppunit/) |
1092+
| cppunit.cfg | [CppUnit](https://sourceforge.net/projects/cppunit/) | |
10861093
| dpdk.cfg | | |
10871094
| embedded_sql.cfg | | |
10881095
| emscripten.cfg | | |
@@ -1115,7 +1122,7 @@ To use a .cfg file shipped with cppcheck, pass the `--library=<lib>` option. The
11151122
| sdl.cfg | | |
11161123
| sfml.cfg | | |
11171124
| sqlite3.cfg | [SQLite](https://www.sqlite.org/) | |
1118-
| std.cfg | C/C++ standard library | Loaded by default
1125+
| std.cfg | C/C++ standard library | Loaded by default |
11191126
| tinyxml2.cfg | [TinyXML-2](https://github.com/leethomason/tinyxml2) | |
11201127
| vcl.cfg | | |
11211128
| windows.cfg | [Win32 API](https://learn.microsoft.com/en-us/windows/win32/) | |

0 commit comments

Comments
 (0)