From 3c0cdedf272407b6dcea52e9d5a0cdb443065698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 16 Sep 2026 13:21:44 +0200 Subject: [PATCH 01/10] Fix #13290 (Import project: -isystem in compile_commands.json) --- tools/tweak-compile-commands.md | 169 +++++++++++++++++++++++++ tools/tweak-compile-commands.py | 218 ++++++++++++++++++++++++++++++++ 2 files changed, 387 insertions(+) create mode 100644 tools/tweak-compile-commands.md create mode 100755 tools/tweak-compile-commands.py diff --git a/tools/tweak-compile-commands.md b/tools/tweak-compile-commands.md new file mode 100644 index 00000000000..95bf07654a9 --- /dev/null +++ b/tools/tweak-compile-commands.md @@ -0,0 +1,169 @@ +# tweak-compile-commands.py + +## NAME + +tweak-compile-commands.py - tweak `-isystem`/`--sysroot`/`-I` handling in a `compile_commands.json` file + +## SYNOPSIS + +``` +tools/tweak-compile-commands.py COMPILE_COMMANDS [-o OUTPUT | -i] + [--isystem-to-i] [--exclude-folder FOLDER ...] + [--remove-include-path PATH ...] +``` + +## DESCRIPTION + +Cppcheck internally does not have handling of `--sysroot` and skips +`-isystem` paths. + +In many cases the system headers should not be included in Cppcheck +analysis, it is preferable to use `--library` instead. The headers +do not provide the knowledge needed for static analysis, i.e. they +can say what types the arguments to a function has but the header +do not provide the semantics of the functions. + +However sometimes you do want to include system headers in Cppcheck +analysis. And you need to have handling of `--sysroot` and +`-isystem`. This script will tweak the compile_commands.json file. + +### SYSROOT + +Example build command such as: + +``` +gcc --sysroot /a/b -isystem /opt/x -c foo.c +``` + +gcc searches both `/opt/x` *and* `/a/b/opt/x` for headers. + +`tweak-compile-commands.py` rewrites each build command in a +`compile_commands.json` file so this implicit behaviour is spelled out +explicitly: for every command that has a `--sysroot` argument, every +existing `-isystem PATH` argument gets a matching, explicit +`-isystem SYSROOT/PATH` argument added right after it. Commands without a +`--sysroot` argument are left unchanged. + +### ISYSTEM + +The script has an option `--isystem-to-i`, this tells the script to +convert `-isystem` arguments to `-I`. This will effectively tell +Cppcheck to not ignore the path. + +The option `--exclude-folder` can be used to skip certain folders. Use +that for a folder if Cppcheck option `--library` can be used instead. + +### REMOVE -I + +The script also has `--remove-include-path`, the script will remove +any `-I PATH` argument whose path contains a given string. This is +useful for stripping include paths that Cppcheck should not see at all. + +## ARGUMENTS + +`COMPILE_COMMANDS` +: Path to the `compile_commands.json` file to read. + +## OPTIONS + +`-o OUTPUT`, `--output OUTPUT` +: Write the result to `OUTPUT` instead of stdout. Cannot be combined with + `-i`. + +`-i`, `--in-place` +: Overwrite `COMPILE_COMMANDS` with the result. Cannot be combined with + `-o`. + +`--isystem-to-i` +: Also convert `-isystem PATH` arguments to `-I PATH`, except for paths + excluded with `--exclude-folder`. Has no effect on its own if not given + (the sysroot tweak still applies). + +`--exclude-folder FOLDER` +: When used with `--isystem-to-i`, keep any `-isystem` argument as + `-isystem` (instead of converting it to `-I`) if `FOLDER` is one of the + path's folder components (an exact match of a path segment, not a + substring). May be given multiple times. Ignored if `--isystem-to-i` is + not given. + +`--remove-include-path PATH` +: Remove any `-I` argument whose path contains `PATH` as a substring. May be + given multiple times; a path is removed if it matches any of them. + Independent of `--isystem-to-i`/`--exclude-folder`, and applies after them, + so a path converted from `-isystem` to `-I` can also be removed by this + option. + +With neither `-o` nor `-i`, the resulting JSON is written to stdout, and +the input file is left untouched. A summary (`tweaked N of M entries`) is +always printed to stderr. + +## EXAMPLES + +Preview the sysroot tweak without touching any file: + +``` +$ tools/tweak-compile-commands.py compile_commands.json +``` + +Apply the sysroot tweak in place: + +``` +$ tools/tweak-compile-commands.py -i compile_commands.json +``` + +Apply the sysroot tweak and convert `-isystem` to `-I`, keeping any path +that goes through a `lib1` or `lib2` folder as `-isystem`: + +``` +$ tools/tweak-compile-commands.py -i compile_commands.json \ + --isystem-to-i --exclude-folder lib1 --exclude-folder lib2 +``` + +Given this input entry: + +```json +{ + "command": "gcc --sysroot /a/b -isystem /opt/x -isystem /path/lib1/include -c foo.c -o foo.o" +} +``` + +the last command above produces: + +```json +{ + "command": "gcc --sysroot /a/b -I /opt/x -I /a/b/opt/x -isystem /path/lib1/include -isystem /a/b/path/lib1/include -c foo.c -o foo.o" +} +``` + +Note that `/path/lib1/include` is kept as `-isystem` (matching +`--exclude-folder lib1`), and so is its sysroot-relative duplicate +`/a/b/path/lib1/include`, since it also contains a `lib1` folder component. + +Remove all `-I` include paths that go through `/path/lib1`: + +``` +$ tools/tweak-compile-commands.py -i compile_commands.json \ + --remove-include-path /path/lib1 +``` + +Given this input entry: + +```json +{ + "command": "gcc -I /opt/x -I /path/lib1/include -c foo.c -o foo.o" +} +``` + +the command above produces: + +```json +{ + "command": "gcc -I /opt/x -c foo.c -o foo.o" +} +``` + +## EXIT STATUS + +Exits with a non-zero status and a traceback if `COMPILE_COMMANDS` cannot +be read or does not contain valid JSON. Otherwise exits 0, even if no +entries needed changes. diff --git a/tools/tweak-compile-commands.py b/tools/tweak-compile-commands.py new file mode 100755 index 00000000000..987286d2372 --- /dev/null +++ b/tools/tweak-compile-commands.py @@ -0,0 +1,218 @@ +#!/usr/bin/env python3 +# +# Tweaks a compile_commands.json file: for every build command that has a +# --sysroot argument, each existing -isystem argument gets a matching extra +# -isystem argument pointing into the sysroot. This is useful when a +# compiler resolves -isystem paths relative to --sysroot internally (as +# part of its built-in search path handling) but a tool consuming +# compile_commands.json (such as Cppcheck) does not, so the sysroot-relative +# path needs to be spelled out explicitly. +# +# Example: +# --sysroot /a/b -isystem /opt/x +# => +# --sysroot /a/b -isystem /opt/x -isystem /a/b/opt/x +# +# Optionally, --isystem-to-i converts -isystem arguments to -I, which can be +# useful since Cppcheck otherwise treats -isystem headers as "system" +# headers and skips some checks in them. Paths whose folder name matches one +# of the --exclude-folder values are left as -isystem. For example, with +# --isystem-to-i --exclude-folder lib1: +# -isystem /opt/x -isystem /path/lib1/include +# => +# -I /opt/x -isystem /path/lib1/include +# +# Optionally, --remove-include-path removes -I arguments whose path contains +# the given path. For example, with --remove-include-path /path/lib1: +# -I /opt/x -I /path/lib1/include +# => +# -I /opt/x +# +# Usage: +# tools/tweak-compile-commands.py compile_commands.json -o out.json +# tools/tweak-compile-commands.py -i compile_commands.json +# tools/tweak-compile-commands.py -i compile_commands.json --isystem-to-i --exclude-folder lib1 +# tools/tweak-compile-commands.py -i compile_commands.json --remove-include-path /path/lib1 +# +# With neither -o nor -i, the result is written to stdout. + +import argparse +import json +import shlex +import sys + + +def find_sysroot(tokens): + for i, tok in enumerate(tokens): + if tok == '--sysroot' and i + 1 < len(tokens): + return tokens[i + 1] + if tok.startswith('--sysroot='): + return tok[len('--sysroot='):] + return None + + +def join_sysroot(sysroot, path): + return sysroot.rstrip('/') + '/' + path.lstrip('/') + + +def add_isystem_sysroot(tokens, sysroot): + result = [] + i = 0 + n = len(tokens) + while i < n: + tok = tokens[i] + if tok == '-isystem' and i + 1 < n: + path = tokens[i + 1] + result.append(tok) + result.append(path) + result.append('-isystem') + result.append(join_sysroot(sysroot, path)) + i += 2 + continue + if tok.startswith('-isystem') and tok != '-isystem': + path = tok[len('-isystem'):] + result.append(tok) + result.append('-isystem' + join_sysroot(sysroot, path)) + i += 1 + continue + result.append(tok) + i += 1 + return result + + +def is_excluded(path, exclude_folders): + parts = path.replace('\\', '/').split('/') + return any(part in exclude_folders for part in parts if part) + + +def convert_isystem_to_i(tokens, exclude_folders): + result = [] + i = 0 + n = len(tokens) + while i < n: + tok = tokens[i] + if tok == '-isystem' and i + 1 < n: + path = tokens[i + 1] + result.append(tok if is_excluded(path, exclude_folders) else '-I') + result.append(path) + i += 2 + continue + if tok.startswith('-isystem') and tok != '-isystem': + path = tok[len('-isystem'):] + result.append(tok if is_excluded(path, exclude_folders) else '-I' + path) + i += 1 + continue + result.append(tok) + i += 1 + return result + + +def matches_remove_path(path, remove_paths): + normalized = path.replace('\\', '/') + return any(remove_path.replace('\\', '/') in normalized for remove_path in remove_paths) + + +def remove_include_paths(tokens, remove_paths): + result = [] + i = 0 + n = len(tokens) + while i < n: + tok = tokens[i] + if tok == '-I' and i + 1 < n: + path = tokens[i + 1] + if matches_remove_path(path, remove_paths): + i += 2 + continue + result.append(tok) + result.append(path) + i += 2 + continue + if tok.startswith('-I') and tok != '-I': + path = tok[len('-I'):] + if matches_remove_path(path, remove_paths): + i += 1 + continue + result.append(tok) + i += 1 + continue + result.append(tok) + i += 1 + return result + + +def tweak_entry(entry, isystem_to_i, exclude_folders, remove_include_path): + if 'command' in entry: + tokens = shlex.split(entry['command']) + elif 'arguments' in entry: + tokens = entry['arguments'] + else: + return False + + changed = False + + sysroot = find_sysroot(tokens) + if sysroot is not None: + tokens = add_isystem_sysroot(tokens, sysroot) + changed = True + + if isystem_to_i: + new_tokens = convert_isystem_to_i(tokens, exclude_folders) + if new_tokens != tokens: + tokens = new_tokens + changed = True + + if remove_include_path: + new_tokens = remove_include_paths(tokens, remove_include_path) + if new_tokens != tokens: + tokens = new_tokens + changed = True + + if not changed: + return False + + if 'command' in entry: + entry['command'] = shlex.join(tokens) + else: + entry['arguments'] = tokens + return True + + +def main(): + parser = argparse.ArgumentParser( + description='Add sysroot-relative -isystem arguments to build commands in a compile_commands.json file.') + parser.add_argument('compile_commands', help='path to the compile_commands.json file to read') + group = parser.add_mutually_exclusive_group() + group.add_argument('-o', '--output', help='write the result to this file instead of stdout') + group.add_argument('-i', '--in-place', action='store_true', help='overwrite the input file with the result') + parser.add_argument('--isystem-to-i', action='store_true', + help='convert -isystem arguments to -I (except excluded folders)') + parser.add_argument('--exclude-folder', action='append', default=[], metavar='FOLDER', + help='folder name to keep as -isystem when using --isystem-to-i; can be given multiple times') + parser.add_argument('--remove-include-path', action='append', default=[], metavar='PATH', + help='remove -I arguments whose path contains PATH; can be given multiple times') + args = parser.parse_args() + + with open(args.compile_commands, encoding='utf-8') as f: + entries = json.load(f) + + changed = 0 + for entry in entries: + if tweak_entry(entry, args.isystem_to_i, args.exclude_folder, args.remove_include_path): + changed += 1 + + out = json.dumps(entries, indent=2) + '\n' + + if args.in_place: + with open(args.compile_commands, 'w', encoding='utf-8') as f: + f.write(out) + elif args.output: + with open(args.output, 'w', encoding='utf-8') as f: + f.write(out) + else: + sys.stdout.write(out) + + print('tweaked {} of {} entries'.format(changed, len(entries)), file=sys.stderr) + + +if __name__ == '__main__': + main() From 4838093f5bc7f44be22a81e6193bd5dc2afafcf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 16 Sep 2026 14:11:34 +0200 Subject: [PATCH 02/10] options --- tools/tweak-compile-commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tweak-compile-commands.md b/tools/tweak-compile-commands.md index 95bf07654a9..f90131746c6 100644 --- a/tools/tweak-compile-commands.md +++ b/tools/tweak-compile-commands.md @@ -2,7 +2,7 @@ ## NAME -tweak-compile-commands.py - tweak `-isystem`/`--sysroot`/`-I` handling in a `compile_commands.json` file +tweak-compile-commands.py - tweak `-isystem`/`--sysroot`/`-I` options in a `compile_commands.json` file ## SYNOPSIS From 3495c901c45e7366d1e86811de9b793a4ae0a90d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 16 Sep 2026 14:27:14 +0200 Subject: [PATCH 03/10] 2 --- tools/tweak-compile-commands.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tools/tweak-compile-commands.md b/tools/tweak-compile-commands.md index f90131746c6..cfc5a19cc10 100644 --- a/tools/tweak-compile-commands.md +++ b/tools/tweak-compile-commands.md @@ -14,9 +14,6 @@ tools/tweak-compile-commands.py COMPILE_COMMANDS [-o OUTPUT | -i] ## DESCRIPTION -Cppcheck internally does not have handling of `--sysroot` and skips -`-isystem` paths. - In many cases the system headers should not be included in Cppcheck analysis, it is preferable to use `--library` instead. The headers do not provide the knowledge needed for static analysis, i.e. they @@ -47,8 +44,7 @@ existing `-isystem PATH` argument gets a matching, explicit ### ISYSTEM The script has an option `--isystem-to-i`, this tells the script to -convert `-isystem` arguments to `-I`. This will effectively tell -Cppcheck to not ignore the path. +convert `-isystem` arguments to `-I`. The option `--exclude-folder` can be used to skip certain folders. Use that for a folder if Cppcheck option `--library` can be used instead. From 038227a64ba0cbbfb96d537f8c8787fbbabddaaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 16 Sep 2026 14:39:31 +0200 Subject: [PATCH 04/10] 2 --- tools/tweak-compile-commands.md | 8 +++++--- tools/tweak-compile-commands.py | 31 +++++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/tools/tweak-compile-commands.md b/tools/tweak-compile-commands.md index cfc5a19cc10..25514872d8f 100644 --- a/tools/tweak-compile-commands.md +++ b/tools/tweak-compile-commands.md @@ -38,8 +38,10 @@ gcc searches both `/opt/x` *and* `/a/b/opt/x` for headers. `compile_commands.json` file so this implicit behaviour is spelled out explicitly: for every command that has a `--sysroot` argument, every existing `-isystem PATH` argument gets a matching, explicit -`-isystem SYSROOT/PATH` argument added right after it. Commands without a -`--sysroot` argument are left unchanged. +`-isystem SYSROOT/PATH` argument added right after it, and the `--sysroot` +argument is then removed (it is no longer needed since the sysroot-relative +paths are now spelled out explicitly). Commands without a `--sysroot` +argument are left unchanged. ### ISYSTEM @@ -127,7 +129,7 @@ the last command above produces: ```json { - "command": "gcc --sysroot /a/b -I /opt/x -I /a/b/opt/x -isystem /path/lib1/include -isystem /a/b/path/lib1/include -c foo.c -o foo.o" + "command": "gcc -I /opt/x -I /a/b/opt/x -isystem /path/lib1/include -isystem /a/b/path/lib1/include -c foo.c -o foo.o" } ``` diff --git a/tools/tweak-compile-commands.py b/tools/tweak-compile-commands.py index 987286d2372..4e57cfaf33f 100755 --- a/tools/tweak-compile-commands.py +++ b/tools/tweak-compile-commands.py @@ -2,16 +2,17 @@ # # Tweaks a compile_commands.json file: for every build command that has a # --sysroot argument, each existing -isystem argument gets a matching extra -# -isystem argument pointing into the sysroot. This is useful when a -# compiler resolves -isystem paths relative to --sysroot internally (as -# part of its built-in search path handling) but a tool consuming -# compile_commands.json (such as Cppcheck) does not, so the sysroot-relative -# path needs to be spelled out explicitly. +# -isystem argument pointing into the sysroot, and the --sysroot argument +# itself is then removed. This is useful when a compiler resolves -isystem +# paths relative to --sysroot internally (as part of its built-in search +# path handling) but a tool consuming compile_commands.json (such as +# Cppcheck) does not, so the sysroot-relative path needs to be spelled out +# explicitly instead. # # Example: # --sysroot /a/b -isystem /opt/x # => -# --sysroot /a/b -isystem /opt/x -isystem /a/b/opt/x +# -isystem /opt/x -isystem /a/b/opt/x # # Optionally, --isystem-to-i converts -isystem arguments to -I, which can be # useful since Cppcheck otherwise treats -isystem headers as "system" @@ -55,6 +56,23 @@ def join_sysroot(sysroot, path): return sysroot.rstrip('/') + '/' + path.lstrip('/') +def remove_sysroot_arg(tokens): + result = [] + i = 0 + n = len(tokens) + while i < n: + tok = tokens[i] + if tok == '--sysroot' and i + 1 < n: + i += 2 + continue + if tok.startswith('--sysroot='): + i += 1 + continue + result.append(tok) + i += 1 + return result + + def add_isystem_sysroot(tokens, sysroot): result = [] i = 0 @@ -153,6 +171,7 @@ def tweak_entry(entry, isystem_to_i, exclude_folders, remove_include_path): sysroot = find_sysroot(tokens) if sysroot is not None: tokens = add_isystem_sysroot(tokens, sysroot) + tokens = remove_sysroot_arg(tokens) changed = True if isystem_to_i: From deb7a7ad799c34242ecdaf467733f425d0f566a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 16 Sep 2026 16:33:19 +0200 Subject: [PATCH 05/10] readme.md --- tools/readme.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/readme.md b/tools/readme.md index 4f914b3cce6..3a2de757199 100644 --- a/tools/readme.md +++ b/tools/readme.md @@ -83,3 +83,9 @@ message. Script to compare the error IDs in the expected `testrunner` output (without executing it) with the `--errorlist` output. It will report missing test coverage for an ID and missing IDs in the `--errorlist` output. + +### * tools/tweak-compile-commands.py + +Script to tweak `-isystem`/`--sysroot`/`-I` options in a `compile_commands.json` file, for example to make +implicit `--sysroot`-relative `-isystem` paths explicit, convert `-isystem` to `-I`, or remove unwanted include +paths. See `tools/tweak-compile-commands.md` for details. From 9e8aab635a8fb5aadec7770a7dba92b8248df680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 16 Sep 2026 16:50:31 +0200 Subject: [PATCH 06/10] manual --- man/manual.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/man/manual.md b/man/manual.md index 93d67e8f402..28f1748259e 100644 --- a/man/manual.md +++ b/man/manual.md @@ -308,6 +308,13 @@ To ignore certain folders you can use `-i`. This will skip analysis of source fi cppcheck --project=compile_commands.json -ifoo +### `-isystem`, `-I`, `--sysroot` + +Cppcheck needs to have flexible handling of include paths from compile_commands.json, and this is achieved with a script +that can tweak the compile_commands.json file. + +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`). From ff4bb7cb196521496e1b97e6326dfb08987a7b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 16 Sep 2026 16:51:37 +0200 Subject: [PATCH 07/10] manual-premium.md --- man/manual-premium.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/man/manual-premium.md b/man/manual-premium.md index 9175ef47c8a..effd5ebbcfa 100644 --- a/man/manual-premium.md +++ b/man/manual-premium.md @@ -307,6 +307,13 @@ To ignore certain folders you can use `-i`. This will skip analysis of source fi cppcheck --project=compile_commands.json -ifoo +### `-isystem`, `-I`, `--sysroot` + +Cppcheck needs to have flexible handling of include paths from compile_commands.json, and this is achieved with a script +that can tweak the compile_commands.json file. + +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`). @@ -1166,6 +1173,7 @@ To use a `.cfg` file shipped with Cppcheck, pass the `--library=` option. T | `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` | | | From 3c8cfee2d894ff9d7bf603574e34a1a8285ec67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 16 Sep 2026 17:14:04 +0200 Subject: [PATCH 08/10] releasenotes --- releasenotes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes.txt b/releasenotes.txt index 2b3f4865397..1652fe61215 100644 --- a/releasenotes.txt +++ b/releasenotes.txt @@ -20,7 +20,7 @@ Changed interface: - Infrastructure & dependencies: -- +- compile_commands.json - flexible handling of -isystem, --sysroot and -I flags through the script tweak-compile_commands.py. Other: - Added configuration file for Microsoft.GSL (Guideline Support Library). From ea51b953c3ce693900d1a7c8d948ca640e824409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 16 Sep 2026 20:05:51 +0200 Subject: [PATCH 09/10] man --- man/manual.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/man/manual.md b/man/manual.md index 28f1748259e..6227ce0abb0 100644 --- a/man/manual.md +++ b/man/manual.md @@ -310,8 +310,12 @@ To ignore certain folders you can use `-i`. This will skip analysis of source fi ### `-isystem`, `-I`, `--sysroot` -Cppcheck needs to have flexible handling of include paths from compile_commands.json, and this is achieved with a script -that can tweak the compile_commands.json file. +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). From 71f257cccc5c52398f4a5558d4b4ba6f634477e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 16 Sep 2026 20:24:24 +0200 Subject: [PATCH 10/10] premium --- man/manual-premium.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/man/manual-premium.md b/man/manual-premium.md index effd5ebbcfa..07eeab86094 100644 --- a/man/manual-premium.md +++ b/man/manual-premium.md @@ -309,8 +309,12 @@ To ignore certain folders you can use `-i`. This will skip analysis of source fi ### `-isystem`, `-I`, `--sysroot` -Cppcheck needs to have flexible handling of include paths from compile_commands.json, and this is achieved with a script -that can tweak the compile_commands.json file. +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).