Introduce gcc warnings as checkers - #5056
Merged
Merged
Conversation
bruntib
force-pushed
the
add_gcc_warnings_as_checkers
branch
from
August 31, 2026 07:20
46544fa to
efa2ec9
Compare
bruntib
marked this pull request as ready for review
August 31, 2026 12:38
barnabasdomozi
requested changes
Aug 31, 2026
barnabasdomozi
left a comment
Collaborator
There was a problem hiding this comment.
Please update the documentation in docs/analyzer/checker_and_analyzer_configuration.md as well.
E.g. it still refers to gcc-double-free instead of gcc-analyzer-double-free.
| assert actual_name.startswith('-Wanalyzer') | ||
| return actual_name.replace("-Wanalyzer", "gcc") | ||
| assert actual_name.startswith('-W') | ||
| return actual_name.replace("-W", "gcc-") |
Collaborator
There was a problem hiding this comment.
Only the first occurrence should be replaced, not all.
Consider:
Suggested change
| return actual_name.replace("-W", "gcc-") | |
| return actual_name.replace("-W", "gcc-", 1) |
| assert codechecker_name.startswith('gcc') | ||
| return codechecker_name.replace("gcc", "-Wanalyzer") | ||
| assert codechecker_name.startswith('gcc-') | ||
| return codechecker_name.replace("gcc-", "-W") |
Collaborator
There was a problem hiding this comment.
Suggested change
| return codechecker_name.replace("gcc-", "-W") | |
| return codechecker_name.replace("gcc-", "-W", 1) |
| assert codechecker_name.startswith('gcc') | ||
| return codechecker_name.replace("gcc", "-Wno-analyzer") | ||
| assert codechecker_name.startswith('gcc-') | ||
| return codechecker_name.replace("gcc-", "-Wno-") |
Collaborator
There was a problem hiding this comment.
Suggested change
| return codechecker_name.replace("gcc-", "-Wno-") | |
| return codechecker_name.replace("gcc-", "-Wno-", 1) |
Gcc has its own checkers that can be enabled as warnings: -Wanalyzer-<checker_name>. However, all other warnings can be considered as checkers. Until this patch the -Wanalyzer-<checker_name> checkers could have been enabled in CodeChecker as --enable gcc-<checker_name>. This patch makes it possible to enable all other warnings as checkers: --enable gcc-<warnings_name>. The problem is that both gcc static analyzers and gcc warning names have the following transformation in CodeChecker: -Wanalyzer-<name> -> gcc-<name> -W<name> -> gcc-<name> Theoretically it's possible to generate the inverse transformation, because static analyzer names and warning names are disjoint. But we decided to preserve all original names for the checkers: -Wanalyzer-<name> -> gcc-analyzer-<name> -W<name> -> gcc-<name> This is a backward incompatible change.
bruntib
force-pushed
the
add_gcc_warnings_as_checkers
branch
from
August 31, 2026 13:56
efa2ec9 to
00ef974
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gcc has its own checkers that can be enabled as warnings: -Wanalyzer-<checker_name>. However, all other warnings can be considered as checkers.
Until this patch the -Wanalyzer-<checker_name> checkers could have been enabled in CodeChecker as --enable gcc-<checker_name>. This patch makes it possible to enable all other warnings as checkers: --enable gcc-<warnings_name>.
The problem is that both gcc static analyzers and gcc warning names have the following transformation in CodeChecker:
-Wanalyzer- -> gcc-
-W -> gcc-
Theoretically it's possible to generate the inverse transformation, because static analyzer names and warning names are disjoint. But we decided to preserve all original names for the checkers:
-Wanalyzer- -> gcc-analyzer-
-W -> gcc-
This is a backward incompatible change.