From a56645a30a577614363a021fe864a084a375a07d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 27 Nov 2026 13:01:49 +0100 Subject: [PATCH 1/4] Fix #15276 (manual: improve the build) --- .github/workflows/buildman.yml | 22 +- .gitignore | 1 + man/build-html.sh | 15 +- man/build-pdf.sh | 18 +- man/buildman.sh | 14 +- man/checkers/premium-misra-config.md | 3 + man/checkers/unknownMacro.md | 4 + man/manual-premium.md | 1590 -------------------------- man/manual.md | 174 ++- 9 files changed, 230 insertions(+), 1611 deletions(-) delete mode 100644 man/manual-premium.md diff --git a/.github/workflows/buildman.yml b/.github/workflows/buildman.yml index e84cf4bffd9..579d31ca84b 100644 --- a/.github/workflows/buildman.yml +++ b/.github/workflows/buildman.yml @@ -26,17 +26,17 @@ jobs: - run: | mkdir output - - uses: docker://pandoc/latex:3.6.3 - with: - args: --output=output/manual.html man/manual.md - - - uses: docker://pandoc/latex:3.6.3 - with: - args: --output=output/manual.pdf man/manual.md - - - uses: docker://pandoc/latex:3.6.3 - with: - args: --output=output/manual-premium.pdf man/manual-premium.md + # buildman.sh runs in the pandoc container. The LaTeX packages used by manual-style.tex + # and the DejaVu fonts are not included in the image. + - name: Build manuals + run: | + docker run --rm -v "$GITHUB_WORKSPACE:/data" -w /data/man --entrypoint sh pandoc/latex:3.6.3 -c ' + set -e + tlmgr --repository https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2024/tlnet-final install titlesec newverbs + apk add --no-cache font-dejavu + ./buildman.sh + chown -R '"$(id -u):$(id -g)"' .' + cp man/*.pdf man/*.html man/manual.css output/ - uses: actions/upload-artifact@v7 with: diff --git a/.gitignore b/.gitignore index 9dd585fcac9..e99599a4186 100644 --- a/.gitignore +++ b/.gitignore @@ -83,6 +83,7 @@ stage # Manual folder /man/manual.log +/man/appendix-*.md /man/manual.tex /man/*.pdf /man/*.html diff --git a/man/build-html.sh b/man/build-html.sh index d9c4aa1c9c3..ad1342e81a9 100755 --- a/man/build-html.sh +++ b/man/build-html.sh @@ -1,3 +1,14 @@ #!/bin/sh -echo Building $1.html -pandoc $1.md -o $1.html -s --number-sections --toc --css manual.css +# Usage: +# ./build-html.sh NAME # NAME.md -> NAME.html +# ./build-html.sh NAME INPUT... [pandoc options] +# # INPUT... -> NAME.html +name=$1 +shift +if [ $# -eq 0 ]; then + set -- "$name.md" +fi +echo Building $name.html +pandoc "$@" -o $name.html -s --number-sections --toc --css manual.css \ + --lua-filter=filters/include-files.lua \ + --lua-filter=filters/manual.lua diff --git a/man/build-pdf.sh b/man/build-pdf.sh index 648b010645d..4789b96ad9e 100755 --- a/man/build-pdf.sh +++ b/man/build-pdf.sh @@ -1,7 +1,17 @@ #!/bin/sh +# Usage: +# ./build-pdf.sh NAME # NAME.md -> NAME.pdf +# ./build-pdf.sh NAME INPUT... [pandoc options] +# # INPUT... -> NAME.pdf +# # This uses installed fonts, which vary between systems # Segoe UI and Consolas are standard in Windows 10, DejaVu is more common on Linux -echo Building $1.pdf +name=$1 +shift +if [ $# -eq 0 ]; then + set -- "$name.md" +fi +echo Building $name.pdf MainFont="Segoe UI" MonoFont="Consolas" @@ -20,7 +30,7 @@ fi # echo Using $MainFont / $MonoFont -pandoc $1.md -o $1.pdf -s --number-sections --toc \ +pandoc "$@" -o $name.pdf -s --number-sections --toc \ --pdf-engine=xelatex \ --listings \ -f markdown \ @@ -29,4 +39,6 @@ pandoc $1.md -o $1.pdf -s --number-sections --toc \ -V geometry:a4paper \ -V geometry:margin=2.4cm \ -V subparagraph \ - -H manual-style.tex + -H manual-style.tex \ + --lua-filter=filters/include-files.lua \ + --lua-filter=filters/manual.lua diff --git a/man/buildman.sh b/man/buildman.sh index cd198071ff5..f941790f057 100755 --- a/man/buildman.sh +++ b/man/buildman.sh @@ -3,8 +3,18 @@ # sudo apt-get install pandoc texlive-latex-base texlive-fonts-recommended texlive-latex-extra # For Windows you can use the MiKTeX installer https://miktex.org/download -./build-pdf.sh manual -./build-html.sh manual +set -e + +# The documentation of all checkers is added as an appendix +./make-appendix.sh "Checkers" checkers/*.md > appendix-checkers.md + +# manual.md contains the content for both the open source and the premium +# manual, the metadata file selects which one is built. +./build-pdf.sh manual manual.md appendix-checkers.md --metadata-file=manual-opensource.yaml +./build-html.sh manual manual.md appendix-checkers.md --metadata-file=manual-opensource.yaml + +./build-pdf.sh manual-premium manual.md appendix-checkers.md --metadata-file=manual-premium.yaml +./build-html.sh manual-premium manual.md appendix-checkers.md --metadata-file=manual-premium.yaml ./build-pdf.sh reference-cfg-format ./build-html.sh reference-cfg-format diff --git a/man/checkers/premium-misra-config.md b/man/checkers/premium-misra-config.md index 367e45a2b44..a77f2f873f2 100644 --- a/man/checkers/premium-misra-config.md +++ b/man/checkers/premium-misra-config.md @@ -1,3 +1,5 @@ +::: {.content-visible when-profile="premium"} + # premium-misra-config **Message**: Unknown constant x, please review cppcheck options
@@ -48,3 +50,4 @@ If the code depends on preprocessor macros that are not defined: cppcheck -DMISSING_MACRO=value file.c ``` +::: diff --git a/man/checkers/unknownMacro.md b/man/checkers/unknownMacro.md index e0b352eab63..c68f250985f 100644 --- a/man/checkers/unknownMacro.md +++ b/man/checkers/unknownMacro.md @@ -36,7 +36,9 @@ cppcheck should just ignore the keyword then an `-DKEYWORD=` option is suggested Warning: +``` canu-2.2/src/seqrequester/src/seqrequester/generate.H:72:41: error: There is an unknown macro here somewhere. Configuration is required. If F_U64 is a macro then please configure it. [unknownMacro] +``` Fix: @@ -53,7 +55,9 @@ void AES_128::hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) Warning: +``` botan-2.19.5+dfsg/src/lib/block/aes/aes_power8/aes_power8.cpp:103:1: error: There is an unknown macro here somewhere. Configuration is required. If BOTAN_FUNC_ISA is a macro then please configure it. [unknownMacro] +``` Fix: diff --git a/man/manual-premium.md b/man/manual-premium.md deleted file mode 100644 index 69395e60dfc..00000000000 --- a/man/manual-premium.md +++ /dev/null @@ -1,1590 +0,0 @@ ---- -title: Cppcheck Premium manual -author: Cppcheck team, Cppcheck Solutions AB -lang: en -documentclass: report ---- - -# Introduction - -Cppcheck is an analysis tool for C/C++ code. It provides unique code analysis to detect bugs and focuses on detecting -undefined behaviour and dangerous coding constructs. The goal is to detect only real errors in the code, and generate -as few false positives (wrongly reported warnings) as possible. Cppcheck is designed to analyze your C/C++ code even -if it has non-standard syntax, as is common in for example embedded projects. - -Supported code and platforms: - -- Cppcheck checks non-standard code that contains various compiler extensions, inline assembly code, etc. -- Cppcheck should be compilable by any compiler that supports C++11 or later. -- Cppcheck is cross-platform and is used in various posix/windows/etc environments. - -The checks in Cppcheck are not perfect. There are bugs that should be found, that Cppcheck fails to detect. - -## About static analysis - -The kinds of bugs that you can find with static analysis are: - -- Undefined behavior -- Using dangerous code patterns -- Coding style - -There are many bugs that you can not find with static analysis. Static analysis tools do not have human knowledge about -what your program is intended to do. If the output from your program is valid but unexpected, then in most cases this is -not detected by static analysis tools. For instance, if your small program writes "Helo" on the screen instead of "Hello", -it is unlikely that any tool will complain about that. - -Static analysis should be used as a complement in your quality assurance. It does not replace any of: - -- Careful design -- Testing -- Dynamic analysis -- Fuzzing - -# Getting started - -## GUI - -It is not required but creating a new project file is a good first step. There are a few options you can tweak to get -good results. - -In the project settings dialog, the first option you see is "Import project". It is recommended that you use this -feature if you can. Cppcheck can import: - -- Visual studio solution / project -- Compile database, which can be generated from CMake/qbs/etc build files -- Borland C++ Builder 6 - -When you have filled out the project settings and clicked on OK, the Cppcheck analysis will start. - -## Command line - -### First test - -Here is some simple code: - - int main() - { - char a[10]; - a[10] = 0; - return 0; - } - -If you save that into `file1.c` and execute: - - cppcheck file1.c - -The output from Cppcheck will then be: - - Checking file1.c... - [file1.c:4]: (error) Array 'a[10]' index 10 out of bounds - -### Checking all files in a folder - -Normally a program has many source files. Cppcheck can check all source files in a directory: - - cppcheck path - -If `path` is a folder, then Cppcheck will recursively check all source files in this folder: - - Checking path/file1.cpp... - 1/2 files checked 50% done - Checking path/file2.cpp... - 2/2 files checked 100% done - -### Check files manually or use project file - -With Cppcheck you can check files manually by specifying files/paths to check and settings. Or you can use a build -environment, such as CMake or Visual Studio. - -We don't know which approach (project file or manual configuration) will give you the best results. It is recommended -that you try both. It is possible that you will get different results so that to find the largest amount of bugs you -need to use both approaches. Later chapters will describe this in more detail. - -### Check files matching a given file filter - -With `--file-filter=` you can configure file filter(s) and then only those files matching the filter will be checked. - -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 - -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: - -- a file with relative path `test1.c` is not checked. -- a file with relative path `src/test2.c` can be checked. -- a file with relative path `src/test3.cpp` is not checked. - -### Ignore files matching a given pattern - -With `-i ` you can configure filename/directory patterns that should be ignored. - -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. - -> *Note*: If you want to filter out warnings for a header file, then `-i` will not work. Use suppressions instead. - -You can use `**`, `*` and `?` in the pattern to specify excluded folders/files. - -- `**` matches zero or more characters, including path separators. -- `*` matches zero or more characters, excluding path separators. -- `?` matches any single character except path separators. - -A use case for `-i` is to check a project, but exclude certain files/folders: - - cppcheck --project=compile_commands.json -itest - -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: - -- a file with relative path `test1.cpp` can be checked. -- a file with relative path `test/somefile.cpp` is not checked - -## Severities - -The possible severities for messages are: - -**error** - -when code is executed there is either undefined behavior or other error, such as a memory leak or resource leak - -**warning** - -when code is executed there might be undefined behavior - -**style** - -stylistic issues, such as unused functions, redundant code, constness, operator precedence, possible mistakes. - -**performance** - -run time performance suggestions based on common knowledge, though it is not certain any measurable speed difference -will be achieved by fixing these messages. - -**portability** - -portability warnings. Implementation defined behavior. 64-bit portability. Some undefined behavior that probably works -"as you want", etc. - -**information** - -configuration problems, which does not relate to the syntactical correctness, but the used Cppcheck configuration could -be improved. - -## Possible speedup analysis of template code - -Cppcheck instantiates the templates in your code. - -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: - - template - void a() - { - a(); - } - - void foo() - { - a<0>(); - } - -Cppcheck output: - - test.cpp:4:5: information: TemplateSimplifier: max template - recursion (100) reached for template 'a<101>'. You might - want to limit Cppcheck recursion. [templateRecursion] - a(); - ^ - -As you can see Cppcheck has instantiated `a` until `a<101>` was reached -and then it bails out. - -To limit template recursion, you can: - -- add template specialisation -- configure Cppcheck, which can be done in the GUI project file dialog - -Example code with template specialisation: - - template - void a() - { - a(); - } - - void foo() - { - a<0>(); - } - - #ifdef __cppcheck__ - template<> void a<3>() {} - #endif - -You can pass `-D__cppcheck__` when checking this code. - -# Cppcheck build folder - -Using a Cppcheck build folder is not mandatory but it is recommended. - -Cppcheck save analyzer information in that folder. - -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. - -On the command line you configure that through `--cppcheck-build-dir=path`. Example: - - mkdir b - - # All files are analyzed - cppcheck --cppcheck-build-dir=b src - - # Faster! Results of unchanged files are reused - cppcheck --cppcheck-build-dir=b src - -In the GUI it is configured in the project settings. - -# Importing a project - -You can import some project files and build configurations into Cppcheck. - -## Cppcheck GUI project - -You can import and use Cppcheck GUI project files in the command line tool: - - cppcheck --project=foobar.cppcheck - -The Cppcheck GUI has a few options that are not available in the command line directly. To use these options, you can import a GUI project file. -The command line tool usage is kept intentionally simple and the options are therefore limited. - -To ignore certain folders in the project, you can use `-i`. This will skip the analysis of source files in the `foo` folder. - - cppcheck --project=foobar.cppcheck -ifoo - -## Compilation database (CMake etc.) - -Many build systems can generate a compilation database (a JSON file containing compilation commands for each source file). -Example `cmake` command to generate the file: - - cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON . - -When you have a `compile_commands.json` file, you can run Cppcheck like this: - - cppcheck --project=compile_commands.json - -By default only 1 configuration is checked because that is consistent with the compilation. If you want to check more configurations, you can use `--max-configs` or `--force`. For example: - - cppcheck --project=compile_commands.json --force - -To ignore certain folders you can use `-i`. This will skip analysis of source files in the `foo` folder. - - cppcheck --project=compile_commands.json -ifoo - -### `-isystem`, `-I`, `--sysroot` - -We have a [script](https://github.com/cppcheck-opensource/cppcheck/blob/main/tools/tweak-compile-commands.py) that tweaks compile_commands.json. - -You can use it to: - * use `--sysroot` flags in Cppcheck analysis - * use `-isystem` paths in Cppcheck analysis - * remove `-I` paths from the compile_commands.json - -See [script documentation](https://github.com/cppcheck-opensource/cppcheck/blob/main/tools/tweak-compile-commands.md). - -## Visual Studio - -You can run Cppcheck on individual project files (`*.vcxproj`) or on a whole solution (`*.sln`) or (`*.slnx`). - -Running Cppcheck on an entire Visual Studio solution: - - cppcheck --project=foobar.sln - -Running Cppcheck on an entire Visual Studio 2026 solution: - - cppcheck --project=foobar.slnx - -Running Cppcheck on a Visual Studio project: - - cppcheck --project=foobar.vcxproj - -Both options will analyze all available configurations in the project(s). -Limiting on a single configuration: - - cppcheck --project=foobar.sln "--project-configuration=Release|Win32" - -In the `Cppcheck GUI` you have the option to only analyze a single debug configuration. If you want to use this option on the command line, then create a `Cppcheck GUI` project with this activated and then import the GUI project file on the command line. - -To ignore certain folders in the project, you can use `-i`. This will skip analysis of source files in the `foo` folder. - - cppcheck --project=foobar.vcxproj -ifoo - -## C++ Builder 6 - -Running Cppcheck on a C++ Builder 6 project: - - cppcheck --project=foobar.bpr - -To ignore certain folders in the project, you can use `-i`. This will skip analysis of source files in the `foo` folder. - - cppcheck --project=foobar.bpr -ifoo - -## Other - -If you generate a compilation database, then it is possible to import that in Cppcheck. - -### Makefile - -In Linux you can convert a Makefile to a `compile_commands.json` using for instance `bear` (build ear) utility: - - bear -- make - -If you don't use Linux, there are Python scripts that converts a Makefile into a compilation database. - -# Preprocessor settings - -If you use `--project`, then Cppcheck will automatically use the preprocessor settings in the imported project file and -likely you don't have to configure anything extra. - -If you don't use `--project`, then a bit of manual preprocessor configuration might be required. However Cppcheck has -automatic configuration of defines. - -## Automatic configuration of preprocessor defines - -Cppcheck automatically test different combinations of preprocessor defines to achieve as high coverage in the analysis -as possible. - -Here is a file that has 3 bugs (when `x`, `y`, `z` are assigned). - - #ifdef A - x=100/0; - #ifdef B - y=100/0; - #endif - #else - z=100/0; - #endif - - #ifndef C - #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 `--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. - -Example: - - # test all configurations - # all bugs are found - cppcheck test.c - - # only test configuration "-DA" - # No bug is found; because C is not defined the #error will cause a preprocessor error - cppcheck -DA test.c - - # only test configuration "-DA -DC" - # The first bug is found - cppcheck -DA -DC test.c - - # Test all configurations that does not define "A" - # The last bug is found - cppcheck -UA test.c - - # All configurations with "-DA" are tested - # The two first bugs are found - cppcheck --force -DA test.c - - # only test 1 valid configuration - # Bug(s) will be found - cppcheck --max-configs=1 test.c - - # test 2 valid configurations with "X" defined. - # Bug(s) will be found - cppcheck --max-configs=2 -DX test.c - -## Include paths - -To add an include path, use `-I` followed by the path. - -Cppcheck's preprocessor basically handles includes like any other preprocessor. However, while other preprocessors -stop working when they encounter a missing header, Cppcheck will just print an information message and continues -parsing the code. - -The purpose of this behaviour is that Cppcheck is meant to work without necessarily seeing the entire code. -Actually, it is recommended to not give all include paths. -While it is useful for Cppcheck to see the declaration of a class when checking the implementation of its members, -passing standard library headers is discouraged, because the analysis will not work fully and lead to a longer checking -time. For such cases, `.cfg` files are the preferred way to provide information about the implementation of functions and -types to Cppcheck, see below for more information. - -# Platform - -You should use a platform configuration that matches your target environment. - -By default Cppcheck uses native platform configuration that works well if your code is compiled and executed locally. - -Cppcheck has builtin configurations for Unix and Windows targets. You can easily use these with the `--platform` command line flag. - -You can also create your own custom platform configuration in a XML file. Here is an example: - - - - 8 - signed - - 2 - 4 - 4 - 8 - 4 - 8 - 12 - 4 - 4 - 2 - - - -# C/C++ standard - -Use `--std` on the command line to specify a C/C++ standard. - -Cppcheck assumes that the code is compatible with the latest C/C++ standard, but it is possible to override this. - -The available options are: - -- c89: C code is C89 compatible -- c99: C code is C99 compatible -- c11: C code is C11 compatible -- c17: C code is C17 compatible -- c23: C code is C23 compatible (default) -- c++03: C++ code is C++03 compatible -- c++11: C++ code is C++11 compatible -- c++14: C++ code is C++14 compatible -- c++17: C++ code is C++17 compatible -- c++20: C++ code is C++20 compatible -- c++23: C++ code is C++23 compatible -- c++26: C++ code is C++26 compatible (default) - -# Cppcheck build dir - -It's a good idea to use a Cppcheck build dir. On the command line use `--cppcheck-build-dir`. In -the GUI, the build dir is configured in the project options. - -Rechecking code will be much faster. Cppcheck does not analyse unchanged code. The old warnings are -loaded from the build dir and reported again. - -Whole program analysis does not work when multiple threads are used unless you use a Cppcheck -build dir. For instance, the unusedFunction warnings require whole program analysis. - -# Suppressions - -If you want to filter out certain errors from being generated, then it is possible to suppress these. - -If you encounter a false positive, please report it to the Cppcheck team so that the issue can be -fixed. - -## Plain text suppressions - -The format for an error suppression is one of: - - [error id]:[filename]:[line] - [error id]:[filename2] - [error id] - -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 `error id` and `filename` patterns may contain `**`, `*` or `?`. - -- `**` matches zero or more characters, including path separators. -- `*` matches zero or more characters, excluding path separators. -- `?` matches any single character except path separators. - -It is recommended to use forward-slash `/` in the filename pattern as path separator on all operating systems. - -### Command line suppression - -The `--suppress=` command line option is used to specify suppressions on the command line. Example: - - cppcheck --suppress=memleak:src/file1.cpp src/ - -### Suppressions in a file - -You can create a suppressions file for example as follows: - - // suppress memleak and exceptNew errors in the file src/file1.cpp - memleak:src/file1.cpp - exceptNew:src/file1.cpp - - uninitvar // suppress all uninitvar errors in all files - -Note that you may add empty lines and comments in the suppressions file. -Comments must start with `#` or `//` and be at the start of the line, or after the suppression line. - -The usage of the suppressions file is as follows: - - cppcheck --suppressions-list=suppressions.txt src/ - -## XML suppressions - -You can specify suppressions in a XML file, for example as follows: - - - - - uninitvar - src/file1.c - 10 - var - - - -The `id` and `fileName` patterns may contain `**`, `*` or `?`. - -- `**` matches zero or more characters, including path separators. -- `*` matches zero or more characters, excluding path separators. -- `?` matches any single character except path separators. - -The XML format is extensible and may be extended with further attributes in the future. - -The usage of the suppressions file is as follows: - - cppcheck --suppress-xml=suppressions.xml src/ - -### The `` element - -Cppcheck calculates a unique ID for each error, called the hash. The hash depends on the code that -is related to the error, not on where that code is located. This means that the hash for an error -stays the same even when unrelated code elsewhere in the file is added, removed or moved, shifting -the line numbers around. The hash only changes if the related code itself is modified. - -This makes hash-based suppressions more robust than line-based suppressions: once you have -reviewed and suppressed a specific warning, the suppression keeps working even after the file is -edited, as long as the offending code is not changed. - -The hash for an error is included as the `hash` attribute in the [XML output](#the-error-element). -You can copy that value into a `` element in a suppressions XML file: - - - - - uninitvar - src/file1.c - 12345678 - - - -A suppression can use `` on its own, without ``, to suppress a specific error regardless -of its id. It is also possible to combine `` with ``, ``, `` and -``; when several of these are specified, all of them must match for the suppression to -apply. - -## Inline suppressions - -Suppressions can also be added directly in the code by adding comments that contain special keywords. -Note that adding comments sacrifices the readability of the code somewhat. - -This code will normally generate an error message: - - void f() { - char arr[5]; - arr[10] = 0; - } - -The output is: - - cppcheck test.c - [test.c:3]: (error) Array 'arr[5]' index 10 out of bounds - -To activate inline suppressions: - - cppcheck --inline-suppr test.c - -### Format - -You can suppress a warning `aaaa` with: - - // cppcheck-suppress aaaa - -Suppressing multiple ids in one comment by using `[]`: - - // cppcheck-suppress [aaaa, bbbb] - -Suppressing warnings `aaaa` on a block of code: - - // cppcheck-suppress-begin aaaa - ... - // cppcheck-suppress-end aaaa - -Suppressing multiple ids on a block of code: - - // cppcheck-suppress-begin [aaaa, bbbb] - ... - // cppcheck-suppress-end [aaaa, bbbb] - -Suppressing warnings `aaaa` for a whole file: - - // cppcheck-suppress-file aaaa - -Suppressing multiple ids for a whole file: - - // cppcheck-suppress-file [aaaa, bbbb] - -Suppressing warnings `aaaa` where macro is used: - - // cppcheck-suppress-macro aaaa - #define MACRO ... - ... - x = MACRO; // <- aaaa warnings are suppressed here - -Suppressing multiple ids where macro is used: - - // cppcheck-suppress-macro [aaaa, bbbb] - #define MACRO ... - ... - x = MACRO; // <- aaaa and bbbb warnings are suppressed here - -### Comment before code or on same line - -The comment can be put before the code or at the same line as the code. - -Before the code: - - void f() { - char arr[5]; - - // cppcheck-suppress arrayIndexOutOfBounds - arr[10] = 0; - } - -Or at the same line as the code: - - void f() { - char arr[5]; - - arr[10] = 0; // cppcheck-suppress arrayIndexOutOfBounds - } - -The suppression comment and the line of code may be separated by additional comments or empty lines: - - void f() { - char arr[5]; - - // cppcheck-suppress arrayIndexOutOfBounds - - arr[10] = 0; - - // cppcheck-suppress arrayIndexOutOfBounds - // Set the tenth element of arr to zero - arr[10] = 0; - } - -In the example below there are 2 lines with code and 1 suppression comment. The suppression comment only applies to 1 line: `a = b + c;`. - - void f() { - a = b + c; // cppcheck-suppress abc - d = e + f; - } - -As a special case for backwards compatibility, if you have a `{` on its own line and a suppression comment after that, then that will suppress warnings for both the current and next line. This example will suppress `abc` warnings both for `{` and for `a = b + c;`: - - void f() - { // cppcheck-suppress abc - a = b + c; - } - -### Multiple suppressions - -For a line of code there might be several warnings you want to suppress. - -There are several options; - -Using 2 suppression comments before code: - - void f() { - char arr[5]; - - // cppcheck-suppress arrayIndexOutOfBounds - // cppcheck-suppress zerodiv - arr[10] = arr[10] / 0; - } - -Using 1 suppression comment before the code: - - void f() { - char arr[5]; - - // cppcheck-suppress[arrayIndexOutOfBounds,zerodiv] - arr[10] = arr[10] / 0; - } - -Suppression comment on the same line as the code: - - void f() { - char arr[5]; - - arr[10] = arr[10] / 0; // cppcheck-suppress[arrayIndexOutOfBounds,zerodiv] - } - -### Symbol name - -You can specify that the inline suppression only applies to a specific symbol: - - // cppcheck-suppress aaaa symbolName=arr - -Or: - - // cppcheck-suppress[aaaa symbolName=arr, bbbb] - -### Comment about suppression - -You can write comments about a suppression as follows: - - // cppcheck-suppress[warningid] some comment - // cppcheck-suppress warningid ; some comment - // cppcheck-suppress warningid // some comment - -# Generating and using a baseline - -When you first run Cppcheck on an existing codebase it's common to get a -large number of warnings. A "baseline" lets you suppress all of today's -warnings and see only *new* warnings introduced from now on. - -This works by asking Cppcheck to include a content-based `hash` for every warning -(computed from the surrounding code, not the line number), then converting today's -warnings into an XML suppressions file keyed on `id` + `fileName` + `hash`. Because -the hash is based on content rather than line number, warnings stay suppressed even -after unrelated lines above them are added or removed. A warning only reappears if -the code it actually points at changes, or a new warning shows up elsewhere. - -## 1. Generate the baseline - -Run Cppcheck with `--xml` and capture stderr (where Cppcheck writes its XML) to a -file: - -```sh -cppcheck --enable=style --xml src 2> baseline-results.xml -``` - -Use whatever combination of `--enable`/defines/include paths you normally -analyze the project with — the suppressions you get out only cover the -checks you ran. - -## 2. Convert the results into a suppressions file - -A [script](https://github.com/cppcheck-opensource/cppcheck/blob/main/tools/generate-baseline-suppressions.py) can be used to generate the baseline: -```sh -python3 generate-baseline-suppressions.py baseline-results.xml suppressions.xml -``` - -This produces a `suppressions.xml` like: - -```xml - - - - uninitvar - src/file1.c - 12345678 - - -``` - -`suppressions.xml` needs to be shared by everyone who runs Cppcheck on this -codebase, including CI. - -Having a script instead of using some special cppcheck flags has the advantages: - * it's flexible. You can tweak it if needed. - * there is fewer flags for us to maintain and document, and for you to learn. - -## 3. Use the baseline on future runs - -```sh -cppcheck --enable=style --xml --suppress-xml=suppressions.xml src -``` - -Only warnings that aren't in the baseline are reported: new warnings in changed -code, and warnings for checks/files that weren't covered when the baseline was -generated. - -## 4. Refreshing the baseline - -Re-run steps 1-2 whenever you want to accept the current state as the new -baseline (e.g. after cleaning up a batch of warnings, or deliberately accepting a -new one). Regenerating overwrites `suppressions.xml` with an entry for every -warning present at that time. - -## The baseline doesn't need to be kept in sync - -Once code that a baselined warning pointed at is fixed, refactored away, or -deleted, its `suppress` entry in `suppressions.xml` becomes dead: nothing will -ever match it again. You don't need to go find and remove it. - -Cppcheck's `unmatchedSuppression` check (part of `--enable=all`) normally warns -about suppressions that never matched anything, on the theory that a -suppression nobody needs is probably a mistake. But it does *not* fire for -`suppress` entries that carry a `` — which is every entry the baseline -script generates. So a baseline file with plenty of dead entries produces no -noise, and developers never need to prune it by hand — it only needs to be -regenerated (step 4) when you deliberately want to reset what's accepted. - -## Caveats - -- A warning can only be suppressed this way if it carries a `hash` attribute in - the XML output. Almost all checks compute one. Critical errors, i.e. syntax - errors do not get hash and must be fixed. Certain information messages do not - get hash neither. -- Changed Cppcheck options might produce new warnings that are not suppressed - by the baseline. -- Cppcheck upgrades don't affect the hash directly (it isn't version-tagged), - but if a new release for instance changes a check's message wording, the hash - changes with it — so upgrading Cppcheck can resurrect baselined warnings for - checks whose messages were reworded, even though nothing in the analyzed code - changed. - -## Strategies for gradually shrinking the baseline - -A baseline makes it possible to adopt Cppcheck in CI immediately without -fixing everything first, but nothing about it enforces that the accepted set -of warnings actually shrinks over time. - -Generic advice: - -- **Prioritize by severity** Checks like `uninitvar` or - `nullPointer` are more valuable to clear than `style` warnings; a baseline - makes it possible to drive the highest-severity checks to zero first while - deliberately leaving lower-risk ones suppressed longer. -- **Be careful** Every fix is a code change, and every code change carries some - risk of introducing a new bug. It can make sense to leave some things suppressed - to minimize the risk that bugs are introduced in working code. - -# XML output - -Cppcheck can generate output in XML format. Use `--xml` to enable this format. - -A sample command to check a file and output errors in the XML format: - - cppcheck --xml file1.cpp - -Here is a sample report: - - - - - - - - - - - -## The `` element - -Each error is reported in a `` element. Attributes: - -**id** - -id of error, and which are valid symbolnames - -**severity** - -error/warning/style/performance/portability/information - -**msg** - -the error message in short format - -**verbose** - -the error message in long format - -**inconclusive** - -this attribute is only used when the error message is inconclusive - -**cwe** - -CWE ID for the problem; note that this attribute is only used when the CWE ID for the message is known - -**remark** - -Optional attribute. The related remark/justification from a remark comment. - -## The `` element - -All locations related to an error are listed with `` elements. The primary location is listed first. - -Attributes: - -**file** - -filename, both relative and absolute paths are possible - -**file0** - -name of the source file (optional) - -**line** - -line number - -**info** - -short information for each location (optional) - -# Reformatting the text output - -If you want to reformat the output so that it looks different, then you can use templates. - -## Predefined output formats - -To get Visual Studio compatible output, you can use `--template=vs`: - - cppcheck --template=vs samples/arrayIndexOutOfBounds/bad.c - -This output will look like this: - - Checking samples/arrayIndexOutOfBounds/bad.c ... - samples/arrayIndexOutOfBounds/bad.c(6): error: Array - 'a[2]' accessed at index 2, which is out of bounds. - -To get GCC-compatible output, you can use `--template=gcc`: - - cppcheck --template=gcc samples/arrayIndexOutOfBounds/bad.c - -The output will look like this: - - Checking samples/arrayIndexOutOfBounds/bad.c ... - samples/arrayIndexOutOfBounds/bad.c:6:6: warning: Array - 'a[2]' accessed at index 2, which is out of bounds. [arrayIndexOutOfBounds] - a[2] = 0; - ^ - -## User defined output format (single line) - -You can write your own pattern. For instance: - - cppcheck \ - --template="{file}:{line}:{column}: {severity}:{message}" \ - samples/arrayIndexOutOfBounds/bad.c - -The output will then look like this: - - Checking samples/arrayIndexOutOfBounds/bad.c ... - samples/arrayIndexOutOfBounds/bad.c:6:6: error: Array - 'a[2]' accessed at index 2, which is out of bounds. - -A comma separated format: - - cppcheck \ - --template="{file},{line},{severity},{id},{message}" \ - samples/arrayIndexOutOfBounds/bad.c - -The output will look like this: - - Checking samples/arrayIndexOutOfBounds/bad.c ... - samples/arrayIndexOutOfBounds/bad.c,6,error,arrayIndexOutOfBounds, - Array 'a[2]' accessed at index 2, which is out of bounds. - -## User defined output format (multi-line) - -Many warnings have multiple locations. Example code: - - void f(int *p) - { - *p = 3; // line 3 - } - - int main() - { - int *p = 0; // line 8 - f(p); // line 9 - return 0; - } - -There is a possible null pointer dereference at line 3. -Cppcheck can show how it came to that conclusion by showing extra location information. -You need to use both `--template` and `--template-location` at the command line, for example: - - cppcheck \ - --template="{file}:{line}: {severity}: {message}\n{code}" \ - --template-location="{file}:{line}: note: {info}\n{code}" multiline.c - -The output from Cppcheck is: - - Checking multiline.c ... - multiline.c:3: warning: Possible null pointer dereference: p - *p = 3; - ^ - multiline.c:8: note: Assignment 'p=0', assigned value is 0 - int *p = 0; - ^ - multiline.c:9: note: Calling function 'f', 1st argument 'p' value is 0 - f(p); - ^ - multiline.c:3: note: Null pointer dereference - *p = 3; - ^ - -The first line in the warning is formatted by the `--template` format. - -The other lines in the warning are formatted by the `--template-location` format. - -### Format specifiers for `--template` - -The available specifiers for `--template` are: - -**{file}** - -File name - -**{line}** - -Line number - -**{column}** - -Column number - -**{callstack}** - -Write all locations. Each location is written in `[{file}:{line}]` format and the locations are separated by `->`. For instance it might look like: `[multiline.c:8] -> [multiline.c:9] -> [multiline.c:3]` - -**{inconclusive:text}** - -If warning is inconclusive, then the given text is written. The given text can be any text that does not contain `}`. Example: `{inconclusive:inconclusive,}` - -**{severity}** - -error/warning/style/performance/portability/information - -**{message}** - -The warning message - -**{id}** - -Warning id - -**{remark}** - -The remark text if a remark comment has been provided - -**{code}** - -The real code - -**\\t** - -Tab - -**\\n** - -Newline - -**\\r** - -Carriage return - -### Format specifiers for `--template-location` - -The available specifiers for `--template-location` are: - -**{file}** - -File name - -**{line}** - -Line number - -**{column}** - -Column number - -**{info}** - -Information message about the current location - -**{code}** - -The real code - -**\\t** - -Tab - -**\\n** - -Newline - -**\\r** - -Carriage return - -# Justifications for warnings in the report - -You can add remark comments in the source code that justify why there is a warning/violation. - -Such a remark comment shall: - -- start with REMARK. -- can either be added above the source code that generates the warning, or after the code on the same line. - -Example code: - - void foo(void) { - // REMARK Initialize x with 0 - int x = 0; - } - -In Cppcheck text output, the remarks are not shown by default, you can use `--template` option `{remark}` to show remarks: - - $ ./cppcheck --enable=style \ - --template="{file}:{line}: {message} [{id}]\\n{remark}" test1.c - - Checking test1.c ... - test1.c:4: Variable 'x' is assigned a value that is never used. [unreadVariable] - Initialize x with 0 - -In XML output, the comment text is provided in a `remark` attribute: - - $ ./cppcheck --enable=style --xml test1.c - ... - remark="Initialize x with 0" - ... - -# Addons - -Addons are scripts that analyse Cppcheck dump files to check compatibility with secure coding standards and to locate issues. - -Cppcheck is distributed with a few addons which are listed below. - -## Supported addons - -### `namingng.py` - -[`namingng.py`](https://github.com/cppcheck-opensource/cppcheck/blob/main/addons/namingng.py) allows you to configure and check naming conventions. - -You need to have a configuration file that defines your naming conventions. By default the filename `namingng.config.json` is used but there is an option so you can use any filename you want. - -Example configuration of naming conventions: - - { - "RE_VARNAME": ["[a-z]*[a-zA-Z0-9_]*\\Z"], - "RE_PRIVATE_MEMBER_VARIABLE": null, - "RE_FUNCTIONNAME": ["[a-z0-9A-Z]*\\Z"], - "_comment": "comments can be added to the config with underscore-prefixed keys", - "include_guard": { - "input": "path", - "prefix": "GUARD_", - "case": "upper", - "max_linenr": 5, - "RE_HEADERFILE": "[^/].*\\.h\\Z", - "required": true - }, - "var_prefixes": {"uint32_t": "ui32"}, - "function_prefixes": {"uint16_t": "ui16", - "uint32_t": "ui32"} - } - -### `threadsafety.py` - -[`threadsafety.py`](https://github.com/cppcheck-opensource/cppcheck/blob/main/addons/threadsafety.py) analyses Cppcheck dump files to locate thread safety issues like static local objects used by multiple threads. - -### `y2038.py` - -[`y2038.py`](https://github.com/cppcheck-opensource/cppcheck/blob/main/addons/y2038.py) checks source code for [year 2038 problem](https://en.wikipedia.org/wiki/Year_2038_problem) safety. - -## Running addons - -Addons can be executed with the `--addon` option: - - cppcheck --addon=namingng.py somefile.c - -Likewise, if you have created your own script, you can execute that: - - cppcheck --addon=mychecks.py somefile.c - -You can configure how you want to execute an addon in a JSON file. For example: - - { - "script": "mychecks.py", - "args": [ - "--some-option" - ], - "ctu": false - } - -To use that JSON file to execute your addon, use the `--addon` option: - - cppcheck --addon=mychecks.json somefile.c - -Cppcheck search for addons in the local folder first and then in the installation folder. A different path can be specified explicitly, for instance: - - cppcheck --addon=path/to/my-addon.py somefile.c - -# Library configuration - -When external libraries are used, such as WinAPI, POSIX, gtk, Qt, etc., Cppcheck has no information about functions, types, or macros contained in those libraries. Cppcheck then fails to detect various problems in the code, or might even abort the analysis. But this can be fixed by using the appropriate configuration files. - -Cppcheck already contains configurations for several libraries. They can be loaded as described below. Note that the configuration for the standard libraries of C and C++, `std.cfg`, is always loaded by Cppcheck. If you create or update a configuration file for a popular library, we would appreciate if you supplied it to the Cppcheck project. - -## Using a `.cfg` file - -To use a `.cfg` file shipped with Cppcheck, pass the `--library=` option. The table below shows the currently existing libraries: - -| `.cfg` file | Library | Comment | -| --- | --- | --- | -| `avr.cfg` | | | -| `bento4.cfg` | [Bento4](http://www.bento4.com/) | | -| `boost.cfg` | [Boost](http://www.boost.org/) | | -| `bsd.cfg` | [BSD](https://www.freebsd.org/) | | -| `cairo.cfg` | [cairo](https://www.cairographics.org/) | | -| `cppcheck-lib.cfg` | [Cppcheck](http://cppcheck.net/) | Used in selfcheck of the Cppcheck code base | -| `cppunit.cfg` | [CppUnit](https://sourceforge.net/projects/cppunit/) | | -| `dpdk.cfg` | | | -| `embedded_sql.cfg` | | | -| `emscripten.cfg` | | | -| `ginac.cfg` | | | -| `gnu.cfg` | [GNU](https://www.gnu.org/) | | -| `googletest.cfg` | [GoogleTest](https://github.com/google/googletest) | | -| `gtk.cfg` | [GTK](https://www.gtk.org/) | | -| `icu.cfg` | | | -| `kde.cfg` | [KDE](https://kde.org/) | | -| `libcerror.cfg` | [libcerror](https://github.com/libyal/libcerror) | | -| `libcurl.cfg` | [libcurl](https://curl.se/libcurl/) | | -| `libsigc++.cfg` | [libsigc++](https://github.com/libsigcplusplus/libsigcplusplus) | | -| `lua.cfg` | | | -| `mfc.cfg` | [MFC](https://learn.microsoft.com/en-us/cpp/mfc/mfc-desktop-applications) | | -| `microsoft_atl.cfg` | [ATL](https://learn.microsoft.com/en-us/cpp/atl/active-template-library-atl-concepts) | | -| `microsoft_gsl.cfg` | [Microsoft.GSL](https://github.com/microsoft/gsl) | | -| `microsoft_sal.cfg` | [SAL annotations](https://learn.microsoft.com/en-us/cpp/c-runtime-library/sal-annotations) | | -| `microsoft_unittest.cfg` | [CppUnitTest](https://learn.microsoft.com/en-us/visualstudio/test/microsoft-visualstudio-testtools-cppunittestframework-api-reference) | | -| `motif.cfg` | | | -| `nspr.cfg` | | | -| `ntl.cfg` | | | -| `opencv2.cfg` | [OpenCV](https://opencv.org/) | | -| `opengl.cfg` | [OpenGL](https://opengl.org/) | | -| `openmp.cfg` | [OpenMP](https://www.openmp.org/) | | -| `openssl.cfg` | [OpenSSL](https://www.openssl.org/) | | -| `pcre.cfg` | [PCRE](https://pcre.org/) | | -| `posix.cfg` | [POSIX](https://pubs.opengroup.org/onlinepubs/9699919799/) | | -| `python.cfg` | | | -| `qt.cfg` | [Qt](https://doc.qt.io/qt.html) | | -| `ruby.cfg` | | | -| `sdl.cfg` | | | -| `sfml.cfg` | | | -| `sqlite3.cfg` | [SQLite](https://www.sqlite.org/) | | -| `std.cfg` | C/C++ standard library | Loaded by default | -| `tinyxml2.cfg` | [TinyXML-2](https://github.com/leethomason/tinyxml2) | | -| `vcl.cfg` | | | -| `windows.cfg` | [Win32 API](https://learn.microsoft.com/en-us/windows/win32/) | | -| `wxsqlite3.cfg` | | | -| `wxsvg.cfg` | | | -| `wxwidgets.cfg` | [wxWidgets](https://www.wxwidgets.org/) | | -| `zephyr.cfg` | | | -| `zlib.cfg` | [zlib](https://www.zlib.net) | | - -## Creating a custom `.cfg` file - -You can create and use your own `.cfg` files for your projects. Use `--check-library` to get hints about what you should configure. - -You can use the `Library Editor` in the `Cppcheck GUI` to edit configuration files. It is available in the `View` menu. - -The `.cfg` file format is documented in the `Reference: Cppcheck .cfg format` () document. - -# HTML report - -You can convert the XML output from Cppcheck into a HTML report. You'll need Python and the pygments module () for this to work. In the Cppcheck source tree there is a folder htmlreport that contains a script that transforms a Cppcheck XML file into HTML output. - -This command generates the help screen: - - htmlreport/cppcheck-htmlreport -h - -The output screen says: - - Usage: cppcheck-htmlreport [options] - - Options: - -h, --help show this help message and exit - --file=FILE The cppcheck xml output file to read defects from. - Default is reading from stdin. - --report-dir=REPORT_DIR - The directory where the html report content is written. - --source-dir=SOURCE_DIR|URL - Base directory where source code files can be found, or - a URL to a remote GitHub/GitLab repository including a - branch, e.g.: - --source-dir=https://github.com///blob// - -Example usage: - - cppcheck gui/test.cpp --xml 2> err.xml - cppcheck-htmlreport --file=err.xml --report-dir=test1 --source-dir=. - -or - - cppcheck gui/test.cpp --xml 2> err.xml - cppcheck-htmlreport --file=err.xml --report-dir=test1 \ - --source-dir=https://github.com///blob// - -## Choosing between local annotated HTML and remote repository links - -`cppcheck-htmlreport` supports two modes for linking to source files: - -- Local annotated HTML files (default when `--source-dir` is a filesystem path) -- Remote GitHub/GitLab links (when `--source-dir` is a URL) - -Pointing `--source-dir` to a filesystem path generates local annotated HTML files. -This is useful when you need a fully self-contained report that works offline, -includes inline annotations, and is ideal for small or medium projects where -generation is fast. -Using a remote GitHub/GitLab URL avoids generating per-file HTML and keeps the -summary report lightweight and fast to produce. This mode is ideal when the -source is already hosted online and local duplication is unnecessary. -Remote mode is especially helpful when the HTML report may be public or widely -distributed but the source code should remain private, since access control is -handled by the hosting service. -In general, local mode fits air-gapped environments, while remote mode works -best for CI workflows and large or private repositories. - -# Check level - -## Reduced - -The "reduced" check level performs a limited data flow analysis. If developers -want to run Cppcheck directly during development and require faster results -than "normal" provides, then this reduced checking can be an option. - -## Normal - -The "normal" check level is chosen by default. Our aim is that this checking level will provide an effective checking in "reasonable" time. - -The "normal" check level should be useful during active development: - -- checking files while you edit them. -- block changes to the repo -- etc. - -## Exhaustive - -When you can wait longer for the results you can enable the "exhaustive" checking, by using the option `--check-level=exhaustive`. - -Exhaustive checking level should be useful for scenarios where you can wait for results. For instance: - -- nightly builds -- etc. - -# Speeding up analysis - -## Limit preprocessor configurations - -For performance reasons it might be a good idea to limit preprocessor configurations to check. - -## Limit ValueFlow: max `if` count - -The command line option `--performance-valueflow-max-if-count` adjusts the max count for number of `if` in a function. - -When that limit is exceeded, there is a limitation of data flow in that function. It is not drastic: - -- Analysis of other functions are not affected. -- It's only for some specific data flow analysis, we have data flow analysis that is always executed. -- All checks are always executed. There can still be plenty of warnings in the limited function. - -There is data flow analysis that slows down exponentially when number of `if` increase. And the limit is intended to avoid that analysis time explodes. - -## GUI options - -In the GUI there are various options to limit analysis. - -In the GUI: - -- Open the project dialog. -- In the "Analysis" tab there are several options. - -If you want to use these limitations on the command line too, you can import the GUI project file with `--project`. - -# Cppcheck Premium - -## Bug hunting - -This is analysis that is more noisy than normal analysis. Most warnings will be false positives (Cppcheck will wrongly claim that there are bugs). The design goal is to not have more than roughly 5 to 10 false positives in each file. - -It is not intended to be used in normal CI or regular static analysis by developers. The noise makes it useless for that. - -It is intended to be used when you are looking for bugs and you really can accept noise. For example: - -- You have developed a brand new feature and want to ensure that there are no bugs. -- Maybe as part of release testing your product you can run bug hunting on modified files. -- Etc. - -Technically, analysis that is "sound" will detect all bugs. Analysis that is "soundy" has the goal to detect most bugs and it tries to keep the noise at an reasonable level. - -The Cppcheck bug hunting analysis is "soundy". - -Command: - - cppcheck --premium=bughunting ... - -## Coding standards - -Command to activate Autosar checkers: - - cppcheck --premium=autosar ... - -Command to activate Cert C checkers: - - cppcheck --premium=cert-c ... - -Command to activate Cert C++ checkers: - - cppcheck --premium=cert-c++ ... - -Command to activate Misra C 2012 checkers: - - cppcheck --premium=misra-c-2012 ... - -Command to activate Misra C 2023 checkers: - - cppcheck --premium=misra-c-2023 ... - -Command to activate Misra C 2025 checkers: - - cppcheck --premium=misra-c-2025 ... - -Command to activate Misra C++ 2008 checkers: - - cppcheck --premium=misra-c++-2008 ... - -Command to activate Misra C++ 2023 checkers: - - cppcheck --premium=misra-c++-2023 ... - -### Checking all C and C++ files - -The `cert-c` and `misra-c-*` coding standards target C and therefore the checkers only check C files by default. - -The `autosar`, `cert-c++` and `misra-c++-*` coding standards target C++ and therefore the checkers only check C++ files by default. - -If you want to check all files, you can append `:all` to the coding standard. Example: - - # Misra C checkers are executed on C files, not on C++ files - cppcheck --premium=misra-c-2025 path - - # Misra C checkers are executed on C and C++ files - cppcheck --premium=misra-c-2025:all path - -## Compliance report - -### Command line - -There is a tool `compliance-report` that is distributed with Cppcheck Premium. To see -all available options, run `compliance-report` in a terminal with no options. - -Below is example usage to generate a Misra C 2012 compliance report. - -`cppcheck --premium=misra-c-2012 --xml-version=3 src 2> results.xml` - -`compliance-report --misra-c-2012 --project-name=Device --project-version=2.3 --output-file=report.html results.xml` - -Description of the options: - -- `--misra-c-2012`: Generate a compliance report for misra-c-2012 -- `--project-name`: The name of the project -- `--project-version`: The version of the project -- `--output-file`: HTML filename that the report should be written to -- `results.xml`: The XML output from Cppcheck - -## Metrics - -To generate metrics, add option `--premium=metrics`. The metrics are saved in the XML v3 report. -Example: - - cppcheck --premium=metrics test.c --xml-version=3 2> res.xml - -We provide a small simple python script that creates a metrics report in CSV format: - - python3 HISReport.py -f res.xml -j path/to/cppcheck-id-mapping.json -o test.csv - -The `cppcheck-id-mapping.json` is provided in the Cppcheck premium installation folder, i.e. -`/opt/cppcheckpremium` or `C:\Program Files\Cppcheck Premium`. - -We do not have a ready-made solution to generate a HTML/pdf report. You can easily tweak our -`HISReport.py` script so that it generates HTML and get the report exactly as you want. - -## Licenses - -### Commercial terms - -Information about Cppcheck Premium licenses: - - -### Installation / registration - -This is described on the Cppcheck Premium website: - - -### License file path - -There are predefined paths where the premium addon search for license files. If you want to -provide an arbitrary license file path on the command line, you can use the option -`--premium-license-file`. Example: - - cppcheck --premium-license-file=path/to/file.lic test.cpp - -If an explicit path is provided like this, then premium addon does not search for license -files in the predefined paths. - -### Troubleshooting - -#### Step 1: check `premiumaddon` debug output - -If your license does not work, you can get some details about the license validation by executing -`premiumaddon` binary with the `--debug` option. - -Windows: - - premiumaddon.exe --debug - -Linux/Mac: - - premiumaddon --debug - -These commands can be executed from an arbitrary folder. - -#### Step 2: clean up Cppcheck build dir - -Command line: -If you use `--cppcheck-build-dir`, then remove all files in the specified folder and recheck. - -Cppcheck GUI: -The GUI normally by default creates a Cppcheck build dir. Clear all results and recheck. -You can clear all results by clicking on the brush icon in the toolbar. Or by open `Edit` menu and selecting menu item `Clear results`. - -#### Step 3: remove `cppcheck-premium-loc` files - -If you have `cppcheck-premium-loc` files in your project folders, those should be removed. - -If such files are generated during analysis, then review your scripts to check why those files are generated. diff --git a/man/manual.md b/man/manual.md index 2a8d42722ce..cf5d83487bb 100644 --- a/man/manual.md +++ b/man/manual.md @@ -1,7 +1,4 @@ --- -title: Cppcheck manual -subtitle: Version 2.23 dev -author: Cppcheck team lang: en documentclass: report --- @@ -1184,6 +1181,8 @@ Cppcheck is distributed with a few addons which are listed below. ## Supported addons +::: {.content-visible when-profile="opensource"} + ### `misra.py` [`misra.py`](https://github.com/cppcheck-opensource/cppcheck/blob/main/addons/misra.py) is used to verify compliance with MISRA C 2012, a proprietary set of guidelines to avoid questionable code, developed for embedded systems. @@ -1206,6 +1205,8 @@ To use that `misra.json` in Cppcheck analysis, use option `--addon=misra.json`: Misra checkers in open source Cppcheck only cover MISRA rules partially and for full coverage use Cppcheck Premium. +::: + ### `namingng.py` [`namingng.py`](https://github.com/cppcheck-opensource/cppcheck/blob/main/addons/namingng.py) allows you to configure and check naming conventions. @@ -1448,3 +1449,170 @@ In the GUI: - In the "Analysis" tab there are several options. If you want to use these limitations on the command line too, you can import the GUI project file with `--project`. + +::: {.content-visible when-profile="premium"} + +# Cppcheck Premium + +## Bug hunting + +This is analysis that is more noisy than normal analysis. Most warnings will be false positives (Cppcheck will wrongly claim that there are bugs). The design goal is to not have more than roughly 5 to 10 false positives in each file. + +It is not intended to be used in normal CI or regular static analysis by developers. The noise makes it useless for that. + +It is intended to be used when you are looking for bugs and you really can accept noise. For example: + +- You have developed a brand new feature and want to ensure that there are no bugs. +- Maybe as part of release testing your product you can run bug hunting on modified files. +- Etc. + +Technically, analysis that is "sound" will detect all bugs. Analysis that is "soundy" has the goal to detect most bugs and it tries to keep the noise at an reasonable level. + +The Cppcheck bug hunting analysis is "soundy". + +Command: + + cppcheck --premium=bughunting ... + +## Coding standards + +Command to activate Autosar checkers: + + cppcheck --premium=autosar ... + +Command to activate Cert C checkers: + + cppcheck --premium=cert-c ... + +Command to activate Cert C++ checkers: + + cppcheck --premium=cert-c++ ... + +Command to activate Misra C 2012 checkers: + + cppcheck --premium=misra-c-2012 ... + +Command to activate Misra C 2023 checkers: + + cppcheck --premium=misra-c-2023 ... + +Command to activate Misra C 2025 checkers: + + cppcheck --premium=misra-c-2025 ... + +Command to activate Misra C++ 2008 checkers: + + cppcheck --premium=misra-c++-2008 ... + +Command to activate Misra C++ 2023 checkers: + + cppcheck --premium=misra-c++-2023 ... + +### Checking all C and C++ files + +The `cert-c` and `misra-c-*` coding standards target C and therefore the checkers only check C files by default. + +The `autosar`, `cert-c++` and `misra-c++-*` coding standards target C++ and therefore the checkers only check C++ files by default. + +If you want to check all files, you can append `:all` to the coding standard. Example: + + # Misra C checkers are executed on C files, not on C++ files + cppcheck --premium=misra-c-2025 path + + # Misra C checkers are executed on C and C++ files + cppcheck --premium=misra-c-2025:all path + +## Compliance report + +### Command line + +There is a tool `compliance-report` that is distributed with Cppcheck Premium. To see +all available options, run `compliance-report` in a terminal with no options. + +Below is example usage to generate a Misra C 2012 compliance report. + +`cppcheck --premium=misra-c-2012 --xml-version=3 src 2> results.xml` + +`compliance-report --misra-c-2012 --project-name=Device --project-version=2.3 --output-file=report.html results.xml` + +Description of the options: + +- `--misra-c-2012`: Generate a compliance report for misra-c-2012 +- `--project-name`: The name of the project +- `--project-version`: The version of the project +- `--output-file`: HTML filename that the report should be written to +- `results.xml`: The XML output from Cppcheck + +## Metrics + +To generate metrics, add option `--premium=metrics`. The metrics are saved in the XML v3 report. +Example: + + cppcheck --premium=metrics test.c --xml-version=3 2> res.xml + +We provide a small simple python script that creates a metrics report in CSV format: + + python3 HISReport.py -f res.xml -j path/to/cppcheck-id-mapping.json -o test.csv + +The `cppcheck-id-mapping.json` is provided in the Cppcheck premium installation folder, i.e. +`/opt/cppcheckpremium` or `C:\Program Files\Cppcheck Premium`. + +We do not have a ready-made solution to generate a HTML/pdf report. You can easily tweak our +`HISReport.py` script so that it generates HTML and get the report exactly as you want. + +## Licenses + +### Commercial terms + +Information about Cppcheck Premium licenses: + + +### Installation / registration + +This is described on the Cppcheck Premium website: + + +### License file path + +There are predefined paths where the premium addon search for license files. If you want to +provide an arbitrary license file path on the command line, you can use the option +`--premium-license-file`. Example: + + cppcheck --premium-license-file=path/to/file.lic test.cpp + +If an explicit path is provided like this, then premium addon does not search for license +files in the predefined paths. + +### Troubleshooting + +#### Step 1: check `premiumaddon` debug output + +If your license does not work, you can get some details about the license validation by executing +`premiumaddon` binary with the `--debug` option. + +Windows: + + premiumaddon.exe --debug + +Linux/Mac: + + premiumaddon --debug + +These commands can be executed from an arbitrary folder. + +#### Step 2: clean up Cppcheck build dir + +Command line: +If you use `--cppcheck-build-dir`, then remove all files in the specified folder and recheck. + +Cppcheck GUI: +The GUI normally by default creates a Cppcheck build dir. Clear all results and recheck. +You can clear all results by clicking on the brush icon in the toolbar. Or by open `Edit` menu and selecting menu item `Clear results`. + +#### Step 3: remove `cppcheck-premium-loc` files + +If you have `cppcheck-premium-loc` files in your project folders, those should be removed. + +If such files are generated during analysis, then review your scripts to check why those files are generated. + +::: From 49cd8640b350fe43465153421734647d998ee167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 27 Nov 2026 13:06:11 +0100 Subject: [PATCH 2/4] manual: add files missing from the previous commit Lua filters, make-appendix.sh and the metadata files for the open source and premium manuals. Co-Authored-By: Claude Opus 5.5 --- man/filters/include-files.LICENSE | 21 ++++ man/filters/include-files.lua | 128 +++++++++++++++++++++++ man/filters/manual.lua | 164 ++++++++++++++++++++++++++++++ man/make-appendix.sh | 30 ++++++ man/manual-opensource.yaml | 5 + man/manual-premium.yaml | 4 + 6 files changed, 352 insertions(+) create mode 100644 man/filters/include-files.LICENSE create mode 100644 man/filters/include-files.lua create mode 100644 man/filters/manual.lua create mode 100755 man/make-appendix.sh create mode 100644 man/manual-opensource.yaml create mode 100644 man/manual-premium.yaml diff --git a/man/filters/include-files.LICENSE b/man/filters/include-files.LICENSE new file mode 100644 index 00000000000..294026bf1e5 --- /dev/null +++ b/man/filters/include-files.LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Pandoc Extensions + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/man/filters/include-files.lua b/man/filters/include-files.lua new file mode 100644 index 00000000000..69b5f5e40fc --- /dev/null +++ b/man/filters/include-files.lua @@ -0,0 +1,128 @@ +--- include-files.lua – filter to include Markdown files +--- +--- Copyright: © 2019–2021 Albert Krewinkel +--- License: MIT – see LICENSE file for details + +-- Module pandoc.path is required and was added in version 2.12 +PANDOC_VERSION:must_be_at_least '2.12' + +local pandoc = require 'pandoc' +local List = require 'pandoc.List' +local path = require 'pandoc.path' +local system = require 'pandoc.system' + +--- Get include auto mode +local include_auto = false +local function get_vars (meta) + if meta['include-auto'] then + include_auto = true + end +end + +--- Keep last heading level found +local last_heading_level = 0 +local function update_last_level(header) + last_heading_level = header.level +end + +--- Update contents of included file +local function update_contents(blocks, shift_by, include_path) + local update_contents_filter = { + -- Shift headings in block list by given number + Header = function (header) + if shift_by then + header.level = header.level + shift_by + end + return header + end, + -- If link paths are relative then prepend include file path + Link = function (link) + if path.is_relative(link.target) and string.sub(path.filename(link.target), 1, 1) ~= '#' and not string.find(link.target, "https?://") then + link.target = path.normalize(path.join({include_path, link.target})) + end + return link + end, + -- If image paths are relative then prepend include file path + Image = function (image) + if path.is_relative(image.src) then + image.src = path.normalize(path.join({include_path, image.src})) + end + return image + end, + -- Update path for include-code-files.lua filter style CodeBlocks + CodeBlock = function (cb) + if cb.attributes.include and path.is_relative(cb.attributes.include) then + cb.attributes.include = + path.normalize(path.join({include_path, cb.attributes.include})) + end + return cb + end + } + + return pandoc.walk_block(pandoc.Div(blocks), update_contents_filter).content +end + +--- Filter function for code blocks +local transclude +function transclude (cb) + -- ignore code blocks which are not of class "include". + if not cb.classes:includes 'include' then + return + end + + -- Markdown is used if this is nil. + local format = cb.attributes['format'] + + -- Attributes shift headings + local shift_heading_level_by = 0 + local shift_input = cb.attributes['shift-heading-level-by'] + if shift_input then + shift_heading_level_by = tonumber(shift_input) + else + if include_auto then + -- Auto shift headings + shift_heading_level_by = last_heading_level + end + end + + --- keep track of level before recusion + local buffer_last_heading_level = last_heading_level + + local blocks = List:new() + for line in cb.text:gmatch('[^\n]+') do + if line:sub(1,2) ~= '//' then + local fh = io.open(line) + if not fh then + io.stderr:write("Cannot open file " .. line .. " | Skipping includes\n") + else + -- read file as the given format with global reader options + local contents = pandoc.read( + fh:read '*a', + format, + PANDOC_READER_OPTIONS + ).blocks + last_heading_level = 0 + -- recursive transclusion + contents = system.with_working_directory( + path.directory(line), + function () + return pandoc.walk_block( + pandoc.Div(contents), + { Header = update_last_level, CodeBlock = transclude } + ) + end).content + --- reset to level before recursion + last_heading_level = buffer_last_heading_level + blocks:extend(update_contents(contents, shift_heading_level_by, + path.directory(line))) + fh:close() + end + end + end + return blocks +end + +return { + { Meta = get_vars }, + { Header = update_last_level, CodeBlock = transclude } +} diff --git a/man/filters/manual.lua b/man/filters/manual.lua new file mode 100644 index 00000000000..2a09b14931f --- /dev/null +++ b/man/filters/manual.lua @@ -0,0 +1,164 @@ +--- manual.lua - pandoc filter for the Cppcheck manuals +--- +--- Run it after include-files.lua: +--- +--- pandoc --lua-filter=filters/include-files.lua --lua-filter=filters/manual.lua ... +--- +--- 1. Conditional content, using the Quarto syntax +--- (https://quarto.org/docs/authoring/conditional.html) with profiles: +--- +--- ::: {.content-visible when-profile="premium"} +--- Only in the premium manual +--- ::: +--- +--- ::: {.content-hidden when-profile="premium"} +--- Not in the premium manual +--- ::: +--- +--- `unless-profile` is also supported. The profile is set by the metadata +--- field `profile`, see manual-opensource.yaml and manual-premium.yaml. +--- +--- 2. Included files: a Div with class `.included-file` and an identifier made +--- from the file path (see make-appendix.sh) wraps an included file. +--- - Only the first heading of the file is numbered and listed in the TOC. +--- - Heading identifiers are prefixed with the Div identifier. +--- - Links to the file (e.g. "[x](checkers/uninitvar.md)") point to the Div. +--- +--- 3. Raw html `
` is replaced by a line break, raw html is dropped in +--- pdf output. +--- +--- 4. Appendices: level 1 headings with class `.appendix` are appendices. In +--- LaTeX output `\appendix` is added before the first one, so the chapter +--- heading says "Appendix A". In other formats the headings in the +--- appendix are numbered "Appendix A", "A.1", "A.2", ... + +local profile = nil + +local function file_id(target) + return 'file-' .. target:gsub('[^%w]', '-') +end + +local function get_profile(meta) + if meta.profile then + profile = pandoc.utils.stringify(meta.profile) + end +end + +local function conditional(div) + local visible + if div.classes:includes('content-visible') then + visible = true + elseif div.classes:includes('content-hidden') then + visible = false + else + return nil + end + for key, _ in pairs(div.attributes) do + if key ~= 'when-profile' and key ~= 'unless-profile' then + error('manual.lua: unsupported condition "' .. key .. '"') + end + end + if not profile then + error('manual.lua: conditional content found but no profile is set, use --metadata-file=manual-.yaml') + end + local when = div.attributes['when-profile'] + local unless = div.attributes['unless-profile'] + local match = (when == nil or when == profile) and (unless == nil or unless ~= profile) + if match == visible then + return div.content + end + return {} +end + +local function included_file(div) + if not div.classes:includes('included-file') then + return nil + end + local first = true + return pandoc.walk_block(div, { + Header = function (h) + -- Each included file is parsed separately, make the identifiers unique + if h.identifier ~= '' then + h.identifier = div.identifier .. '-' .. h.identifier + end + if first then + first = false + else + h.classes:insert('unnumbered') + h.classes:insert('unlisted') + end + return h + end + }) +end + +-- Appendix numbering, used for formats other than LaTeX +local appendix_count = 0 +local appendix_letter = nil +local section_numbers = {} + +local function appendix(h) + if h.level == 1 then + if not h.classes:includes('appendix') then + appendix_letter = nil + return nil + end + appendix_count = appendix_count + 1 + if FORMAT:match('latex') then + if appendix_count == 1 then + return { pandoc.RawBlock('latex', '\\appendix'), h } + end + return nil + end + appendix_letter = string.char(string.byte('A') + appendix_count - 1) + section_numbers = {} + h.attributes['number'] = 'Appendix ' .. appendix_letter + return h + end + if appendix_letter and not h.classes:includes('unnumbered') then + section_numbers[h.level] = (section_numbers[h.level] or 0) + 1 + for level = h.level + 1, 6 do + section_numbers[level] = nil + end + local number = appendix_letter + for level = 2, h.level do + number = number .. '.' .. (section_numbers[level] or 0) + end + h.attributes['number'] = number + return h + end +end + +local function document(doc) + local file_ids = {} + doc:walk({ + Div = function (div) + if div.classes:includes('included-file') then + file_ids[div.identifier] = true + end + end + }) + + return doc:walk({ + Link = function (link) + local id = file_id(link.target) + if file_ids[id] then + link.target = '#' .. id + return link + end + end, + RawInline = function (raw) + if raw.format == 'html' and raw.text:match('^$') then + return pandoc.LineBreak() + end + end, + Header = appendix + }) +end + +return { + { Meta = get_profile }, + { Div = conditional }, + { Div = included_file }, + { Pandoc = document }, +} diff --git a/man/make-appendix.sh b/man/make-appendix.sh new file mode 100755 index 00000000000..64f94ff0877 --- /dev/null +++ b/man/make-appendix.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# Generate a markdown file with an appendix chapter that includes the given +# markdown files. The chapter heading gets "Appendix A" etc, see +# filters/manual.lua. The result is meant to be passed to pandoc after the manual, +# together with filters/include-files.lua and filters/manual.lua. +# +# Usage: +# ./make-appendix.sh TITLE FILE... > appendix.md +# +# Example: +# ./make-appendix.sh "Checkers" checkers/*.md > appendix-checkers.md +# pandoc manual.md appendix-checkers.md --metadata-file=manual-premium.yaml \ +# --lua-filter=filters/include-files.lua --lua-filter=filters/manual.lua \ +# -o manual-premium.pdf + +if [ $# -lt 2 ]; then + echo "Usage: $0 TITLE FILE..." >&2 + exit 1 +fi + +title=$1 +shift + +printf '# %s {.appendix}\n\n' "$title" +# Sort case insensitive, independent of locale +printf '%s\n' "$@" | LC_ALL=C sort -f | while read -r f; do + # The identifier must match file_id() in filters/manual.lua + id=file-$(printf '%s' "$f" | sed 's/[^A-Za-z0-9]/-/g') + printf '::: {#%s .included-file}\n\n```{.include shift-heading-level-by=1}\n%s\n```\n\n:::\n\n' "$id" "$f" +done diff --git a/man/manual-opensource.yaml b/man/manual-opensource.yaml new file mode 100644 index 00000000000..11a74c578f0 --- /dev/null +++ b/man/manual-opensource.yaml @@ -0,0 +1,5 @@ +# Metadata for the open source manual: pandoc --metadata-file=manual-opensource.yaml +profile: opensource +title: Cppcheck manual +subtitle: Version 2.23 dev +author: Cppcheck team diff --git a/man/manual-premium.yaml b/man/manual-premium.yaml new file mode 100644 index 00000000000..96b08b9ce40 --- /dev/null +++ b/man/manual-premium.yaml @@ -0,0 +1,4 @@ +# Metadata for the Cppcheck Premium manual: pandoc --metadata-file=manual-premium.yaml +profile: premium +title: Cppcheck Premium manual +author: Cppcheck team, Cppcheck Solutions AB From b2deedc8976ee6084d048d5701484ec2d95eb8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 27 Nov 2026 13:28:25 +0100 Subject: [PATCH 3/4] shellcheck --- man/make-appendix.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/man/make-appendix.sh b/man/make-appendix.sh index 64f94ff0877..eea2ecc947f 100755 --- a/man/make-appendix.sh +++ b/man/make-appendix.sh @@ -21,10 +21,12 @@ fi title=$1 shift +fence='```' + printf '# %s {.appendix}\n\n' "$title" # Sort case insensitive, independent of locale printf '%s\n' "$@" | LC_ALL=C sort -f | while read -r f; do # The identifier must match file_id() in filters/manual.lua id=file-$(printf '%s' "$f" | sed 's/[^A-Za-z0-9]/-/g') - printf '::: {#%s .included-file}\n\n```{.include shift-heading-level-by=1}\n%s\n```\n\n:::\n\n' "$id" "$f" + printf '::: {#%s .included-file}\n\n%s{.include shift-heading-level-by=1}\n%s\n%s\n\n:::\n\n' "$id" "$fence" "$f" "$fence" done From 853d338812aea905ae747cf36db070b3438c0df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 27 Nov 2026 16:58:21 +0100 Subject: [PATCH 4/4] manual: put checker messages containing <...> in backticks Pandoc treats , and as raw html and drops them. Co-Authored-By: Claude Opus 5.5 --- man/checkers/checkLibraryUseIgnore.md | 2 +- man/checkers/leakUnsafeArgAlloc.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/man/checkers/checkLibraryUseIgnore.md b/man/checkers/checkLibraryUseIgnore.md index ace4e9ec3e6..5d8d420e625 100644 --- a/man/checkers/checkLibraryUseIgnore.md +++ b/man/checkers/checkLibraryUseIgnore.md @@ -1,6 +1,6 @@ # checkLibraryUseIgnore -**Message**: --check-library: Function f() should have / configuration
+**Message**: `--check-library: Function f() should have / configuration`
**Category**: Configuration
**Severity**: Information
**Language**: C/C++ diff --git a/man/checkers/leakUnsafeArgAlloc.md b/man/checkers/leakUnsafeArgAlloc.md index fd3f9ba2049..696a5c9fd48 100644 --- a/man/checkers/leakUnsafeArgAlloc.md +++ b/man/checkers/leakUnsafeArgAlloc.md @@ -1,6 +1,6 @@ # leakUnsafeArgAlloc -**Message**: Unsafe allocation. If shared_ptr() throws, memory could be leaked. Use make_shared() instead.
+**Message**: `Unsafe allocation. If shared_ptr() throws, memory could be leaked. Use make_shared() instead.`
**Category**: Correctness
**Severity**: Warning (inconclusive)
**Language**: C++