Skip to content

Introduce gcc warnings as checkers - #5056

Merged
bruntib merged 1 commit into
Ericsson:masterfrom
bruntib:add_gcc_warnings_as_checkers
Aug 31, 2026
Merged

Introduce gcc warnings as checkers#5056
bruntib merged 1 commit into
Ericsson:masterfrom
bruntib:add_gcc_warnings_as_checkers

Conversation

@bruntib

@bruntib bruntib commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

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.

@bruntib bruntib added this to the release 6.29.0 milestone Aug 30, 2026
@bruntib
bruntib requested a review from barnabasdomozi August 30, 2026 21:21
@bruntib
bruntib force-pushed the add_gcc_warnings_as_checkers branch from 46544fa to efa2ec9 Compare August 31, 2026 07:20
@bruntib
bruntib marked this pull request as ready for review August 31, 2026 12:38

@barnabasdomozi barnabasdomozi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
bruntib force-pushed the add_gcc_warnings_as_checkers branch from efa2ec9 to 00ef974 Compare August 31, 2026 13:56
@bruntib
bruntib requested a review from dkrupp as a code owner August 31, 2026 13:56
@bruntib
bruntib requested a review from barnabasdomozi August 31, 2026 13:56

@barnabasdomozi barnabasdomozi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bruntib
bruntib merged commit 4035004 into Ericsson:master Aug 31, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants