diff --git a/man/manual.md b/man/manual.md index 1e8aaa94f68..988a26d8349 100644 --- a/man/manual.md +++ b/man/manual.md @@ -105,15 +105,18 @@ need to use both approaches. Later chapters will describe this in more detail. With `--file-filter=` 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 @@ -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. @@ -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: @@ -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. @@ -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 . @@ -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. @@ -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