From 49ef56b74ce4eacc04fc85ddb3c507ff4d967840 Mon Sep 17 00:00:00 2001 From: fdniel97 Date: Sat, 2 May 2026 23:45:59 +0200 Subject: [PATCH 1/8] added gcc warnings to checker lsit and added them also to corresponding json file --- .../analyzers/gcc/analyzer.py | 12 +- .../analyzers/gcc/result_handler.py | 7 +- config/labels/analyzers/gcc.json | 449 +++++++++++++++++- 3 files changed, 463 insertions(+), 5 deletions(-) diff --git a/analyzer/codechecker_analyzer/analyzers/gcc/analyzer.py b/analyzer/codechecker_analyzer/analyzers/gcc/analyzer.py index 0636fbeedf..c1b10034bd 100644 --- a/analyzer/codechecker_analyzer/analyzers/gcc/analyzer.py +++ b/analyzer/codechecker_analyzer/analyzers/gcc/analyzer.py @@ -106,11 +106,19 @@ def get_analyzer_checkers(cls): try: output = subprocess.check_output(command, env=environ) + context = analyzer_context.get_context() + + blacklisted_checkers = context.checker_labels.checkers_by_labels( + ["blacklist:true"], cls.ANALYZER_NAME) + # Still contains the help message we need to remove. for entry in output.decode().split('\n'): warning_name, _, description = entry.strip().partition(' ') - # GCC Static Analyzer names start with -Wanalyzer. - if warning_name.startswith('-Wanalyzer'): + # Skip blacklisted warnings, warnings with equal signs in their name and the generic -W flag. + if '=' in warning_name or warning_name == '-W' or warning_name in blacklisted_checkers: + continue + # GCC Static Analyzer names and warning names start with -W. + if warning_name.startswith('-W'): # Rename the checkers interally (similarly to how we # support cppcheck) renamed_checker_name = \ diff --git a/analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py b/analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py index bbe2f2781c..73f3afc611 100644 --- a/analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py +++ b/analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py @@ -29,8 +29,11 @@ def actual_name_to_codechecker_name(actual_name: str): - assert actual_name.startswith('-Wanalyzer') - return actual_name.replace("-Wanalyzer", "gcc") + assert actual_name.startswith('-W') + if actual_name.startswith('-Wanalyzer'): + return actual_name.replace("-Wanalyzer", "gcc") + else: + return actual_name.replace("-W", "gcc-diagnostic-") def codechecker_name_to_actual_name(codechecker_name: str): diff --git a/config/labels/analyzers/gcc.json b/config/labels/analyzers/gcc.json index 706663ab6e..4d8399c7f4 100644 --- a/config/labels/analyzers/gcc.json +++ b/config/labels/analyzers/gcc.json @@ -245,6 +245,453 @@ "doc_url:https://gcc.gnu.org/onlinedocs/gcc/Static-Analyzer-Options.html#index-Wanalyzer-write-to-string-literal", "profile:extreme", "severity:HIGH" - ] + ], + "gcc-diagnostic-NSObject-attribute": [ ], + "gcc-diagnostic-abi": [ ], + "gcc-diagnostic-abi-tag": [ ], + "gcc-diagnostic-abi=": [ ], + "gcc-diagnostic-absolute-value": [ ], + "gcc-diagnostic-address": [ ], + "gcc-diagnostic-address-of-packed-member": [ ], + "gcc-diagnostic-aggregate-return": [ ], + "gcc-diagnostic-aggressive-loop-optimizations": [ ], + "gcc-diagnostic-aliasing": [ ], + "gcc-diagnostic-align-commons": [ ], + "gcc-diagnostic-aligned-new=[none|global|all]": [ ], + "gcc-diagnostic-all": [ ], + "gcc-diagnostic-alloc-size": [ ], + "gcc-diagnostic-alloc-size-larger-than=": [ ], + "gcc-diagnostic-alloc-zero": [ ], + "gcc-diagnostic-alloca": [ ], + "gcc-diagnostic-alloca-larger-than=": [ ], + "gcc-diagnostic-ampersand": [ ], + "gcc-diagnostic-analyzer-allocation-size": [ ], + "gcc-diagnostic-analyzer-deref-before-check": [ ], + "gcc-diagnostic-analyzer-double-fclose": [ ], + "gcc-diagnostic-analyzer-double-free": [ ], + "gcc-diagnostic-analyzer-exposure-through-output-file": [ ], + "gcc-diagnostic-analyzer-exposure-through-uninit-copy": [ ], + "gcc-diagnostic-analyzer-fd-access-mode-mismatch": [ ], + "gcc-diagnostic-analyzer-fd-double-close": [ ], + "gcc-diagnostic-analyzer-fd-leak": [ ], + "gcc-diagnostic-analyzer-fd-phase-mismatch": [ ], + "gcc-diagnostic-analyzer-fd-type-mismatch": [ ], + "gcc-diagnostic-analyzer-fd-use-after-close": [ ], + "gcc-diagnostic-analyzer-fd-use-without-check": [ ], + "gcc-diagnostic-analyzer-file-leak": [ ], + "gcc-diagnostic-analyzer-free-of-non-heap": [ ], + "gcc-diagnostic-analyzer-imprecise-fp-arithmetic": [ ], + "gcc-diagnostic-analyzer-infinite-loop": [ ], + "gcc-diagnostic-analyzer-infinite-recursion": [ ], + "gcc-diagnostic-analyzer-jump-through-null": [ ], + "gcc-diagnostic-analyzer-malloc-leak": [ ], + "gcc-diagnostic-analyzer-mismatching-deallocation": [ ], + "gcc-diagnostic-analyzer-null-argument": [ ], + "gcc-diagnostic-analyzer-null-dereference": [ ], + "gcc-diagnostic-analyzer-out-of-bounds": [ ], + "gcc-diagnostic-analyzer-overlapping-buffers": [ ], + "gcc-diagnostic-analyzer-possible-null-argument": [ ], + "gcc-diagnostic-analyzer-possible-null-dereference": [ ], + "gcc-diagnostic-analyzer-putenv-of-auto-var": [ ], + "gcc-diagnostic-analyzer-shift-count-negative": [ ], + "gcc-diagnostic-analyzer-shift-count-overflow": [ ], + "gcc-diagnostic-analyzer-stale-setjmp-buffer": [ ], + "gcc-diagnostic-analyzer-symbol-too-complex": [ ], + "gcc-diagnostic-analyzer-tainted-allocation-size": [ ], + "gcc-diagnostic-analyzer-tainted-array-index": [ ], + "gcc-diagnostic-analyzer-tainted-assertion": [ ], + "gcc-diagnostic-analyzer-tainted-divisor": [ ], + "gcc-diagnostic-analyzer-tainted-offset": [ ], + "gcc-diagnostic-analyzer-tainted-size": [ ], + "gcc-diagnostic-analyzer-too-complex": [ ], + "gcc-diagnostic-analyzer-undefined-behavior-strtok": [ ], + "gcc-diagnostic-analyzer-unsafe-call-within-signal-handler": [ ], + "gcc-diagnostic-analyzer-use-after-free": [ ], + "gcc-diagnostic-analyzer-use-of-pointer-in-stale-stack-frame": [ ], + "gcc-diagnostic-analyzer-use-of-uninitialized-value": [ ], + "gcc-diagnostic-analyzer-va-arg-type-mismatch": [ ], + "gcc-diagnostic-analyzer-va-list-exhausted": [ ], + "gcc-diagnostic-analyzer-va-list-leak": [ ], + "gcc-diagnostic-analyzer-va-list-use-after-va-end": [ ], + "gcc-diagnostic-analyzer-write-to-const": [ ], + "gcc-diagnostic-analyzer-write-to-string-literal": [ ], + "gcc-diagnostic-arith-conversion": [ ], + "gcc-diagnostic-array-bounds": [ ], + "gcc-diagnostic-array-bounds=<0,2>": [ ], + "gcc-diagnostic-array-compare": [ ], + "gcc-diagnostic-array-parameter": [ ], + "gcc-diagnostic-array-parameter=<0,2>": [ ], + "gcc-diagnostic-array-temporaries": [ ], + "gcc-diagnostic-assign-intercept": [ ], + "gcc-diagnostic-attribute-alias": [ ], + "gcc-diagnostic-attribute-alias=<0,2>": [ ], + "gcc-diagnostic-attribute-warning": [ ], + "gcc-diagnostic-attributes": [ ], + "gcc-diagnostic-bad-function-cast": [ ], + "gcc-diagnostic-bidi-chars": [ ], + "gcc-diagnostic-bidi-chars=": [ ], + "gcc-diagnostic-bool-compare": [ ], + "gcc-diagnostic-bool-operation": [ ], + "gcc-diagnostic-builtin-declaration-mismatch": [ ], + "gcc-diagnostic-builtin-macro-redefined": [ ], + "gcc-diagnostic-c++-compat": [ ], + "gcc-diagnostic-c++0x-compat": [ ], + "gcc-diagnostic-c++11-compat": [ ], + "gcc-diagnostic-c++11-extensions": [ ], + "gcc-diagnostic-c++14-compat": [ ], + "gcc-diagnostic-c++14-extensions": [ ], + "gcc-diagnostic-c++17-compat": [ ], + "gcc-diagnostic-c++17-extensions": [ ], + "gcc-diagnostic-c++1z-compat": [ ], + "gcc-diagnostic-c++20-compat": [ ], + "gcc-diagnostic-c++20-extensions": [ ], + "gcc-diagnostic-c++23-extensions": [ ], + "gcc-diagnostic-c++26-extensions": [ ], + "gcc-diagnostic-c++2a-compat": [ ], + "gcc-diagnostic-c-binding-type": [ ], + "gcc-diagnostic-c11-c23-compat": [ ], + "gcc-diagnostic-c90-c99-compat": [ ], + "gcc-diagnostic-c99-c11-compat": [ ], + "gcc-diagnostic-calloc-transposed-args": [ ], + "gcc-diagnostic-cannot-profile": [ ], + "gcc-diagnostic-cast-align": [ ], + "gcc-diagnostic-cast-align=strict": [ ], + "gcc-diagnostic-cast-function-type": [ ], + "gcc-diagnostic-cast-qual": [ ], + "gcc-diagnostic-cast-result": [ ], + "gcc-diagnostic-cast-user-defined": [ ], + "gcc-diagnostic-catch-value": [ ], + "gcc-diagnostic-catch-value=<0,3>": [ ], + "gcc-diagnostic-changes-meaning": [ ], + "gcc-diagnostic-char-subscripts": [ ], + "gcc-diagnostic-character-truncation": [ ], + "gcc-diagnostic-chkp": [ ], + "gcc-diagnostic-class-conversion": [ ], + "gcc-diagnostic-class-memaccess": [ ], + "gcc-diagnostic-clobbered": [ ], + "gcc-diagnostic-comma-subscript": [ ], + "gcc-diagnostic-comment": [ ], + "gcc-diagnostic-comments": [ ], + "gcc-diagnostic-compare-distinct-pointer-types": [ ], + "gcc-diagnostic-compare-reals": [ ], + "gcc-diagnostic-complain-wrong-lang": [ ], + "gcc-diagnostic-conditionally-supported": [ ], + "gcc-diagnostic-conversion": [ ], + "gcc-diagnostic-conversion-extra": [ ], + "gcc-diagnostic-conversion-null": [ ], + "gcc-diagnostic-coverage-invalid-line-number": [ ], + "gcc-diagnostic-coverage-mismatch": [ ], + "gcc-diagnostic-coverage-too-many-conditions": [ ], + "gcc-diagnostic-cpp": [ ], + "gcc-diagnostic-ctad-maybe-unsupported": [ ], + "gcc-diagnostic-ctor-dtor-privacy": [ ], + "gcc-diagnostic-dangling-else": [ ], + "gcc-diagnostic-dangling-pointer": [ ], + "gcc-diagnostic-dangling-pointer=<0,2>": [ ], + "gcc-diagnostic-dangling-reference": [ ], + "gcc-diagnostic-date-time": [ ], + "gcc-diagnostic-declaration-after-statement": [ ], + "gcc-diagnostic-declaration-missing-parameter-type": [ ], + "gcc-diagnostic-delete-incomplete": [ ], + "gcc-diagnostic-delete-non-virtual-dtor": [ ], + "gcc-diagnostic-deprecated": [ ], + "gcc-diagnostic-deprecated-copy": [ ], + "gcc-diagnostic-deprecated-copy-dtor": [ ], + "gcc-diagnostic-deprecated-declarations": [ ], + "gcc-diagnostic-deprecated-enum-enum-conversion": [ ], + "gcc-diagnostic-deprecated-enum-float-conversion": [ ], + "gcc-diagnostic-designated-init": [ ], + "gcc-diagnostic-disabled-optimization": [ ], + "gcc-diagnostic-discarded-array-qualifiers": [ ], + "gcc-diagnostic-discarded-qualifiers": [ ], + "gcc-diagnostic-div-by-zero": [ ], + "gcc-diagnostic-do-subscript": [ ], + "gcc-diagnostic-double-promotion": [ ], + "gcc-diagnostic-duplicate-decl-specifier": [ ], + "gcc-diagnostic-duplicated-branches": [ ], + "gcc-diagnostic-duplicated-cond": [ ], + "gcc-diagnostic-effc++": [ ], + "gcc-diagnostic-elaborated-enum-base": [ ], + "gcc-diagnostic-empty-body": [ ], + "gcc-diagnostic-endif-labels": [ ], + "gcc-diagnostic-enum-compare": [ ], + "gcc-diagnostic-enum-conversion": [ ], + "gcc-diagnostic-enum-int-mismatch": [ ], + "gcc-diagnostic-error-implicit-function-declaration": [ ], + "gcc-diagnostic-exceptions": [ ], + "gcc-diagnostic-expansion-to-defined": [ ], + "gcc-diagnostic-extra": [ ], + "gcc-diagnostic-extra-semi": [ ], + "gcc-diagnostic-flex-array-member-not-at-end": [ ], + "gcc-diagnostic-float-conversion": [ ], + "gcc-diagnostic-float-equal": [ ], + "gcc-diagnostic-format": [ ], + "gcc-diagnostic-format-contains-nul": [ ], + "gcc-diagnostic-format-diag": [ ], + "gcc-diagnostic-format-extra-args": [ ], + "gcc-diagnostic-format-nonliteral": [ ], + "gcc-diagnostic-format-overflow<0,2>": [ ], + "gcc-diagnostic-format-overflow=<0,2>": [ ], + "gcc-diagnostic-format-security": [ ], + "gcc-diagnostic-format-signedness": [ ], + "gcc-diagnostic-format-truncation": [ ], + "gcc-diagnostic-format-truncation=<0,2>": [ ], + "gcc-diagnostic-format-y2k": [ ], + "gcc-diagnostic-format-zero-length": [ ], + "gcc-diagnostic-format=<0,2>": [ ], + "gcc-diagnostic-frame-address": [ ], + "gcc-diagnostic-frame-larger-than=": [ ], + "gcc-diagnostic-free-nonheap-object": [ ], + "gcc-diagnostic-function-elimination": [ ], + "gcc-diagnostic-global-module": [ ], + "gcc-diagnostic-hardened": [ ], + "gcc-diagnostic-hsa": [ ], + "gcc-diagnostic-if-not-aligned": [ ], + "gcc-diagnostic-ignored-attributes": [ ], + "gcc-diagnostic-ignored-qualifiers": [ ], + "gcc-diagnostic-implicit": [ ], + "gcc-diagnostic-implicit-fallthrough": [ ], + "gcc-diagnostic-implicit-fallthrough=<0,5>": [ ], + "gcc-diagnostic-implicit-function-declaration": [ ], + "gcc-diagnostic-implicit-int": [ ], + "gcc-diagnostic-implicit-interface": [ ], + "gcc-diagnostic-implicit-procedure": [ ], + "gcc-diagnostic-inaccessible-base": [ ], + "gcc-diagnostic-incompatible-pointer-types": [ ], + "gcc-diagnostic-infinite-recursion": [ ], + "gcc-diagnostic-inherited-variadic-ctor": [ ], + "gcc-diagnostic-init-list-lifetime": [ ], + "gcc-diagnostic-init-self": [ ], + "gcc-diagnostic-inline": [ ], + "gcc-diagnostic-int-conversion": [ ], + "gcc-diagnostic-int-in-bool-context": [ ], + "gcc-diagnostic-int-to-pointer-cast": [ ], + "gcc-diagnostic-integer-division": [ ], + "gcc-diagnostic-interference-size": [ ], + "gcc-diagnostic-intrinsic-shadow": [ ], + "gcc-diagnostic-intrinsics-std": [ ], + "gcc-diagnostic-invalid-constexpr": [ ], + "gcc-diagnostic-invalid-imported-macros": [ ], + "gcc-diagnostic-invalid-memory-model": [ ], + "gcc-diagnostic-invalid-offsetof": [ ], + "gcc-diagnostic-invalid-pch": [ ], + "gcc-diagnostic-invalid-utf8": [ ], + "gcc-diagnostic-jump-misses-init": [ ], + "gcc-diagnostic-larger-than-": [ ], + "gcc-diagnostic-larger-than=": [ ], + "gcc-diagnostic-line-truncation": [ ], + "gcc-diagnostic-literal-suffix": [ ], + "gcc-diagnostic-logical-not-parentheses": [ ], + "gcc-diagnostic-logical-op": [ ], + "gcc-diagnostic-long-long": [ ], + "gcc-diagnostic-lto-type-mismatch": [ ], + "gcc-diagnostic-main": [ ], + "gcc-diagnostic-maybe-uninitialized": [ ], + "gcc-diagnostic-memset-elt-size": [ ], + "gcc-diagnostic-memset-transposed-args": [ ], + "gcc-diagnostic-misleading-indentation": [ ], + "gcc-diagnostic-mismatched-dealloc": [ ], + "gcc-diagnostic-mismatched-new-delete": [ ], + "gcc-diagnostic-mismatched-special-enum": [ ], + "gcc-diagnostic-mismatched-tags": [ ], + "gcc-diagnostic-missing-attributes": [ ], + "gcc-diagnostic-missing-braces": [ ], + "gcc-diagnostic-missing-declarations": [ ], + "gcc-diagnostic-missing-field-initializers": [ ], + "gcc-diagnostic-missing-format-attribute": [ ], + "gcc-diagnostic-missing-include-dirs": [ ], + "gcc-diagnostic-missing-noreturn": [ ], + "gcc-diagnostic-missing-parameter-type": [ ], + "gcc-diagnostic-missing-profile": [ ], + "gcc-diagnostic-missing-prototypes": [ ], + "gcc-diagnostic-missing-requires": [ ], + "gcc-diagnostic-missing-template-keyword": [ ], + "gcc-diagnostic-missing-variable-declarations": [ ], + "gcc-diagnostic-multichar": [ ], + "gcc-diagnostic-multiple-inheritance": [ ], + "gcc-diagnostic-multistatement-macros": [ ], + "gcc-diagnostic-namespaces": [ ], + "gcc-diagnostic-narrowing": [ ], + "gcc-diagnostic-nested-externs": [ ], + "gcc-diagnostic-no-alloc-size-larger-than": [ ], + "gcc-diagnostic-no-alloca-larger-than": [ ], + "gcc-diagnostic-no-frame-larger-than": [ ], + "gcc-diagnostic-no-larger-than": [ ], + "gcc-diagnostic-no-stack-usage": [ ], + "gcc-diagnostic-no-vla-larger-than": [ ], + "gcc-diagnostic-noexcept": [ ], + "gcc-diagnostic-noexcept-type": [ ], + "gcc-diagnostic-non-template-friend": [ ], + "gcc-diagnostic-non-virtual-dtor": [ ], + "gcc-diagnostic-nonnull": [ ], + "gcc-diagnostic-nonnull-compare": [ ], + "gcc-diagnostic-normalized": [ ], + "gcc-diagnostic-normalized=[none|id|nfc|nfkc]": [ ], + "gcc-diagnostic-nrvo": [ ], + "gcc-diagnostic-null-dereference": [ ], + "gcc-diagnostic-objc-root-class": [ ], + "gcc-diagnostic-odr": [ ], + "gcc-diagnostic-old-style-cast": [ ], + "gcc-diagnostic-old-style-declaration": [ ], + "gcc-diagnostic-old-style-definition": [ ], + "gcc-diagnostic-openacc-parallelism": [ ], + "gcc-diagnostic-openmp": [ ], + "gcc-diagnostic-openmp-simd": [ ], + "gcc-diagnostic-overflow": [ ], + "gcc-diagnostic-overlength-strings": [ ], + "gcc-diagnostic-overloaded-virtual": [ ], + "gcc-diagnostic-overloaded-virtual=<0,2>": [ ], + "gcc-diagnostic-override-init": [ ], + "gcc-diagnostic-override-init-side-effects": [ ], + "gcc-diagnostic-overwrite-recursive": [ ], + "gcc-diagnostic-packed": [ ], + "gcc-diagnostic-packed-bitfield-compat": [ ], + "gcc-diagnostic-packed-not-aligned": [ ], + "gcc-diagnostic-padded": [ ], + "gcc-diagnostic-parentheses": [ ], + "gcc-diagnostic-pedantic": [ ], + "gcc-diagnostic-pessimizing-move": [ ], + "gcc-diagnostic-placement-new": [ ], + "gcc-diagnostic-placement-new=<0,2>": [ ], + "gcc-diagnostic-pmf-conversions": [ ], + "gcc-diagnostic-pointer-arith": [ ], + "gcc-diagnostic-pointer-compare": [ ], + "gcc-diagnostic-pointer-sign": [ ], + "gcc-diagnostic-pointer-to-int-cast": [ ], + "gcc-diagnostic-pragmas": [ ], + "gcc-diagnostic-prio-ctor-dtor": [ ], + "gcc-diagnostic-property-assign-default": [ ], + "gcc-diagnostic-protocol": [ ], + "gcc-diagnostic-psabi": [ ], + "gcc-diagnostic-range-loop-construct": [ ], + "gcc-diagnostic-real-q-constant": [ ], + "gcc-diagnostic-realloc-lhs": [ ], + "gcc-diagnostic-realloc-lhs-all": [ ], + "gcc-diagnostic-redundant-decls": [ ], + "gcc-diagnostic-redundant-move": [ ], + "gcc-diagnostic-redundant-tags": [ ], + "gcc-diagnostic-register": [ ], + "gcc-diagnostic-reorder": [ ], + "gcc-diagnostic-restrict": [ ], + "gcc-diagnostic-return-local-addr": [ ], + "gcc-diagnostic-return-mismatch": [ ], + "gcc-diagnostic-return-type": [ ], + "gcc-diagnostic-scalar-storage-order": [ ], + "gcc-diagnostic-selector": [ ], + "gcc-diagnostic-self-move": [ ], + "gcc-diagnostic-sequence-point": [ ], + "gcc-diagnostic-shadow": [ ], + "gcc-diagnostic-shadow-compatible-local": [ ], + "gcc-diagnostic-shadow-ivar": [ ], + "gcc-diagnostic-shadow-local": [ ], + "gcc-diagnostic-shadow=compatible-local": [ ], + "gcc-diagnostic-shadow=global": [ ], + "gcc-diagnostic-shadow=local": [ ], + "gcc-diagnostic-shift-count-negative": [ ], + "gcc-diagnostic-shift-count-overflow": [ ], + "gcc-diagnostic-shift-negative-value": [ ], + "gcc-diagnostic-shift-overflow": [ ], + "gcc-diagnostic-shift-overflow=<0,2>": [ ], + "gcc-diagnostic-sign-compare": [ ], + "gcc-diagnostic-sign-conversion": [ ], + "gcc-diagnostic-sign-promo": [ ], + "gcc-diagnostic-sized-deallocation": [ ], + "gcc-diagnostic-sizeof-array-argument": [ ], + "gcc-diagnostic-sizeof-array-div": [ ], + "gcc-diagnostic-sizeof-pointer-div": [ ], + "gcc-diagnostic-sizeof-pointer-memaccess": [ ], + "gcc-diagnostic-stack-protector": [ ], + "gcc-diagnostic-stack-usage=": [ ], + "gcc-diagnostic-strict-aliasing": [ ], + "gcc-diagnostic-strict-aliasing=<0,3>": [ ], + "gcc-diagnostic-strict-flex-arrays": [ ], + "gcc-diagnostic-strict-null-sentinel": [ ], + "gcc-diagnostic-strict-overflow": [ ], + "gcc-diagnostic-strict-overflow=<0,5>": [ ], + "gcc-diagnostic-strict-prototypes": [ ], + "gcc-diagnostic-strict-selector-match": [ ], + "gcc-diagnostic-string-compare": [ ], + "gcc-diagnostic-stringop-overflow": [ ], + "gcc-diagnostic-stringop-overflow=<0,4>": [ ], + "gcc-diagnostic-stringop-overread": [ ], + "gcc-diagnostic-stringop-truncation": [ ], + "gcc-diagnostic-subobject-linkage": [ ], + "gcc-diagnostic-suggest-attribute=cold": [ ], + "gcc-diagnostic-suggest-attribute=const": [ ], + "gcc-diagnostic-suggest-attribute=format": [ ], + "gcc-diagnostic-suggest-attribute=malloc": [ ], + "gcc-diagnostic-suggest-attribute=noreturn": [ ], + "gcc-diagnostic-suggest-attribute=pure": [ ], + "gcc-diagnostic-suggest-attribute=returns_nonnull": [ ], + "gcc-diagnostic-suggest-final-methods": [ ], + "gcc-diagnostic-suggest-final-types": [ ], + "gcc-diagnostic-suggest-override": [ ], + "gcc-diagnostic-surprising": [ ], + "gcc-diagnostic-switch": [ ], + "gcc-diagnostic-switch-bool": [ ], + "gcc-diagnostic-switch-default": [ ], + "gcc-diagnostic-switch-enum": [ ], + "gcc-diagnostic-switch-outside-range": [ ], + "gcc-diagnostic-switch-unreachable": [ ], + "gcc-diagnostic-sync-nand": [ ], + "gcc-diagnostic-synth": [ ], + "gcc-diagnostic-system-headers": [ ], + "gcc-diagnostic-tabs": [ ], + "gcc-diagnostic-target-lifetime": [ ], + "gcc-diagnostic-tautological-compare": [ ], + "gcc-diagnostic-template-id-cdtor": [ ], + "gcc-diagnostic-templates": [ ], + "gcc-diagnostic-terminate": [ ], + "gcc-diagnostic-traditional": [ ], + "gcc-diagnostic-traditional-conversion": [ ], + "gcc-diagnostic-trampolines": [ ], + "gcc-diagnostic-trigraphs": [ ], + "gcc-diagnostic-trivial-auto-var-init": [ ], + "gcc-diagnostic-tsan": [ ], + "gcc-diagnostic-type-limits": [ ], + "gcc-diagnostic-undeclared-selector": [ ], + "gcc-diagnostic-undef": [ ], + "gcc-diagnostic-undefined-do-loop": [ ], + "gcc-diagnostic-underflow": [ ], + "gcc-diagnostic-unicode": [ ], + "gcc-diagnostic-uninitialized": [ ], + "gcc-diagnostic-unknown-pragmas": [ ], + "gcc-diagnostic-unreachable-code": [ ], + "gcc-diagnostic-unsafe-loop-optimizations": [ ], + "gcc-diagnostic-unsuffixed-float-constants": [ ], + "gcc-diagnostic-unused": [ ], + "gcc-diagnostic-unused-but-set-parameter": [ ], + "gcc-diagnostic-unused-but-set-variable": [ ], + "gcc-diagnostic-unused-const-variable": [ ], + "gcc-diagnostic-unused-const-variable=<0,2>": [ ], + "gcc-diagnostic-unused-dummy-argument": [ ], + "gcc-diagnostic-unused-function": [ ], + "gcc-diagnostic-unused-label": [ ], + "gcc-diagnostic-unused-local-typedefs": [ ], + "gcc-diagnostic-unused-macros": [ ], + "gcc-diagnostic-unused-parameter": [ ], + "gcc-diagnostic-unused-result": [ ], + "gcc-diagnostic-unused-value": [ ], + "gcc-diagnostic-unused-variable": [ ], + "gcc-diagnostic-use-after-free": [ ], + "gcc-diagnostic-use-after-free=<0,3>": [ ], + "gcc-diagnostic-use-without-only": [ ], + "gcc-diagnostic-useless-cast": [ ], + "gcc-diagnostic-varargs": [ ], + "gcc-diagnostic-variadic-macros": [ ], + "gcc-diagnostic-vector-operation-performance": [ ], + "gcc-diagnostic-vexing-parse": [ ], + "gcc-diagnostic-virtual-inheritance": [ ], + "gcc-diagnostic-virtual-move-assign": [ ], + "gcc-diagnostic-vla": [ ], + "gcc-diagnostic-vla-larger-than=": [ ], + "gcc-diagnostic-vla-parameter": [ ], + "gcc-diagnostic-volatile": [ ], + "gcc-diagnostic-volatile-register-var": [ ], + "gcc-diagnostic-write-strings": [ ], + "gcc-diagnostic-xor-used-as-pow": [ ], + "gcc-diagnostic-zero-as-null-pointer-constant": [ ], + "gcc-diagnostic-zero-length-bounds": [ ], + "gcc-diagnostic-zerotrip": [ ] } } From e5809f852ec90714ce71974fb98e8ba260284659 Mon Sep 17 00:00:00 2001 From: fdniel97 Date: Fri, 8 May 2026 23:33:21 +0200 Subject: [PATCH 2/8] [DEBUG] added warnings to gcc command, currently buggy --- .../codechecker_analyzer/analyzers/gcc/analyzer.py | 12 ++++++++++-- .../analyzers/gcc/result_handler.py | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/analyzer/codechecker_analyzer/analyzers/gcc/analyzer.py b/analyzer/codechecker_analyzer/analyzers/gcc/analyzer.py index c1b10034bd..3ae91a006e 100644 --- a/analyzer/codechecker_analyzer/analyzers/gcc/analyzer.py +++ b/analyzer/codechecker_analyzer/analyzers/gcc/analyzer.py @@ -22,7 +22,7 @@ from .config_handler import GccConfigHandler from .result_handler import GccResultHandler, \ - actual_name_to_codechecker_name, codechecker_name_to_actual_name_disabled + actual_name_to_codechecker_name, codechecker_name_to_actual_name, codechecker_name_to_actual_name_disabled LOG = get_logger('analyzer.gcc') @@ -72,11 +72,16 @@ def construct_analyzer_cmd(self, result_handler): analyzer_cmd.append('-fdiagnostics-format=sarif-stderr') for checker_name, value in config.checks().items(): + print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccxx") + print(checker_name) if value[0] == CheckerState.DISABLED: # TODO python3.9 removeprefix method would be nicer # than startswith and a hardcoded slicing analyzer_cmd.append( codechecker_name_to_actual_name_disabled(checker_name)) + else: + analyzer_cmd.append( + codechecker_name_to_actual_name(checker_name)) compile_lang = self.buildaction.lang if not has_flag('-x', analyzer_cmd): @@ -114,10 +119,13 @@ def get_analyzer_checkers(cls): # Still contains the help message we need to remove. for entry in output.decode().split('\n'): warning_name, _, description = entry.strip().partition(' ') + print('ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc') + #print(actual_name_to_codechecker_name(warning_name)) # Skip blacklisted warnings, warnings with equal signs in their name and the generic -W flag. - if '=' in warning_name or warning_name == '-W' or warning_name in blacklisted_checkers: + if (not warning_name.startswith('-W')) or ('=' in warning_name) or (warning_name == '-W') or (actual_name_to_codechecker_name(warning_name) in blacklisted_checkers): continue # GCC Static Analyzer names and warning names start with -W. + print(warning_name) if warning_name.startswith('-W'): # Rename the checkers interally (similarly to how we # support cppcheck) diff --git a/analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py b/analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py index 73f3afc611..137b56abe0 100644 --- a/analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py +++ b/analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py @@ -29,6 +29,9 @@ def actual_name_to_codechecker_name(actual_name: str): + if not actual_name.startswith('-W'): + print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") + print(actual_name) assert actual_name.startswith('-W') if actual_name.startswith('-Wanalyzer'): return actual_name.replace("-Wanalyzer", "gcc") @@ -43,6 +46,9 @@ def codechecker_name_to_actual_name(codechecker_name: str): def codechecker_name_to_actual_name_disabled(codechecker_name: str): assert codechecker_name.startswith('gcc') + print(codechecker_name) + if codechecker_name.startswith('gcc-diagnostic-'): + return codechecker_name.replace("gcc-diagnostic-", "-Wno-") return codechecker_name.replace("gcc", "-Wno-analyzer") From 09ff80b08c3d482bf90fb7b6562c7172fdd34761 Mon Sep 17 00:00:00 2001 From: fdniel97 Date: Fri, 8 May 2026 23:48:11 +0200 Subject: [PATCH 3/8] add more blacklisted checkers --- config/labels/analyzers/gcc.json | 100 +++++++++++++++---------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/config/labels/analyzers/gcc.json b/config/labels/analyzers/gcc.json index 4d8399c7f4..3ec94c6ea3 100644 --- a/config/labels/analyzers/gcc.json +++ b/config/labels/analyzers/gcc.json @@ -247,8 +247,8 @@ "severity:HIGH" ], "gcc-diagnostic-NSObject-attribute": [ ], - "gcc-diagnostic-abi": [ ], - "gcc-diagnostic-abi-tag": [ ], + "gcc-diagnostic-abi": [ "blacklist:true" ], + "gcc-diagnostic-abi-tag": [ "blacklist:true" ], "gcc-diagnostic-abi=": [ ], "gcc-diagnostic-absolute-value": [ ], "gcc-diagnostic-address": [ ], @@ -258,12 +258,12 @@ "gcc-diagnostic-aliasing": [ ], "gcc-diagnostic-align-commons": [ ], "gcc-diagnostic-aligned-new=[none|global|all]": [ ], - "gcc-diagnostic-all": [ ], - "gcc-diagnostic-alloc-size": [ ], - "gcc-diagnostic-alloc-size-larger-than=": [ ], + "gcc-diagnostic-all": [ "blacklist:true" ], + "gcc-diagnostic-alloc-size": [ ], + "gcc-diagnostic-alloc-size-larger-than": [ "blacklist:true" ], "gcc-diagnostic-alloc-zero": [ ], "gcc-diagnostic-alloca": [ ], - "gcc-diagnostic-alloca-larger-than=": [ ], + "gcc-diagnostic-alloca-larger-than=": [ "blacklist:true" ], "gcc-diagnostic-ampersand": [ ], "gcc-diagnostic-analyzer-allocation-size": [ ], "gcc-diagnostic-analyzer-deref-before-check": [ ], @@ -316,38 +316,38 @@ "gcc-diagnostic-analyzer-write-to-const": [ ], "gcc-diagnostic-analyzer-write-to-string-literal": [ ], "gcc-diagnostic-arith-conversion": [ ], - "gcc-diagnostic-array-bounds": [ ], - "gcc-diagnostic-array-bounds=<0,2>": [ ], + "gcc-diagnostic-array-bounds": [ "blacklist:true" ], + "gcc-diagnostic-array-bounds=<0,2>": [ "blacklist:true" ], "gcc-diagnostic-array-compare": [ ], - "gcc-diagnostic-array-parameter": [ ], - "gcc-diagnostic-array-parameter=<0,2>": [ ], + "gcc-diagnostic-array-parameter": [ "blacklist:true" ], + "gcc-diagnostic-array-parameter=<0,2>": [ "blacklist:true" ], "gcc-diagnostic-array-temporaries": [ ], "gcc-diagnostic-assign-intercept": [ ], - "gcc-diagnostic-attribute-alias": [ ], - "gcc-diagnostic-attribute-alias=<0,2>": [ ], + "gcc-diagnostic-attribute-alias": [ "blacklist:true" ], + "gcc-diagnostic-attribute-alias=<0,2>": [ "blacklist:true"], "gcc-diagnostic-attribute-warning": [ ], "gcc-diagnostic-attributes": [ ], "gcc-diagnostic-bad-function-cast": [ ], - "gcc-diagnostic-bidi-chars": [ ], - "gcc-diagnostic-bidi-chars=": [ ], + "gcc-diagnostic-bidi-chars": [ "blacklist:true" ], + "gcc-diagnostic-bidi-chars=": [ "blacklist:true" ], "gcc-diagnostic-bool-compare": [ ], "gcc-diagnostic-bool-operation": [ ], "gcc-diagnostic-builtin-declaration-mismatch": [ ], "gcc-diagnostic-builtin-macro-redefined": [ ], "gcc-diagnostic-c++-compat": [ ], - "gcc-diagnostic-c++0x-compat": [ ], + "gcc-diagnostic-c++0x-compat": [ "blacklist:true" ], "gcc-diagnostic-c++11-compat": [ ], "gcc-diagnostic-c++11-extensions": [ ], "gcc-diagnostic-c++14-compat": [ ], "gcc-diagnostic-c++14-extensions": [ ], "gcc-diagnostic-c++17-compat": [ ], "gcc-diagnostic-c++17-extensions": [ ], - "gcc-diagnostic-c++1z-compat": [ ], + "gcc-diagnostic-c++1z-compat": [ "blacklist:true" ], "gcc-diagnostic-c++20-compat": [ ], "gcc-diagnostic-c++20-extensions": [ ], "gcc-diagnostic-c++23-extensions": [ ], "gcc-diagnostic-c++26-extensions": [ ], - "gcc-diagnostic-c++2a-compat": [ ], + "gcc-diagnostic-c++2a-compat": [ "blacklist:true" ], "gcc-diagnostic-c-binding-type": [ ], "gcc-diagnostic-c11-c23-compat": [ ], "gcc-diagnostic-c90-c99-compat": [ ], @@ -365,13 +365,13 @@ "gcc-diagnostic-changes-meaning": [ ], "gcc-diagnostic-char-subscripts": [ ], "gcc-diagnostic-character-truncation": [ ], - "gcc-diagnostic-chkp": [ ], + "gcc-diagnostic-chkp": [ "blacklist:true" ], "gcc-diagnostic-class-conversion": [ ], "gcc-diagnostic-class-memaccess": [ ], "gcc-diagnostic-clobbered": [ ], "gcc-diagnostic-comma-subscript": [ ], "gcc-diagnostic-comment": [ ], - "gcc-diagnostic-comments": [ ], + "gcc-diagnostic-comments": [ "blacklist:true" ], "gcc-diagnostic-compare-distinct-pointer-types": [ ], "gcc-diagnostic-compare-reals": [ ], "gcc-diagnostic-complain-wrong-lang": [ ], @@ -386,8 +386,8 @@ "gcc-diagnostic-ctad-maybe-unsupported": [ ], "gcc-diagnostic-ctor-dtor-privacy": [ ], "gcc-diagnostic-dangling-else": [ ], - "gcc-diagnostic-dangling-pointer": [ ], - "gcc-diagnostic-dangling-pointer=<0,2>": [ ], + "gcc-diagnostic-dangling-pointer": [ "blacklist:true" ], + "gcc-diagnostic-dangling-pointer=<0,2>": [ "blacklist:true" ], "gcc-diagnostic-dangling-reference": [ ], "gcc-diagnostic-date-time": [ ], "gcc-diagnostic-declaration-after-statement": [ ], @@ -425,22 +425,22 @@ "gcc-diagnostic-flex-array-member-not-at-end": [ ], "gcc-diagnostic-float-conversion": [ ], "gcc-diagnostic-float-equal": [ ], - "gcc-diagnostic-format": [ ], + "gcc-diagnostic-format": [ "blacklist:true" ], "gcc-diagnostic-format-contains-nul": [ ], "gcc-diagnostic-format-diag": [ ], "gcc-diagnostic-format-extra-args": [ ], "gcc-diagnostic-format-nonliteral": [ ], - "gcc-diagnostic-format-overflow<0,2>": [ ], - "gcc-diagnostic-format-overflow=<0,2>": [ ], + "gcc-diagnostic-format-overflow<0,2>": [ "blacklist:true" ], + "gcc-diagnostic-format-overflow=<0,2>": [ "blacklist:true" ], "gcc-diagnostic-format-security": [ ], "gcc-diagnostic-format-signedness": [ ], - "gcc-diagnostic-format-truncation": [ ], - "gcc-diagnostic-format-truncation=<0,2>": [ ], + "gcc-diagnostic-format-truncation": [ "blacklist:true" ], + "gcc-diagnostic-format-truncation=<0,2>": [ "blacklist:true" ], "gcc-diagnostic-format-y2k": [ ], "gcc-diagnostic-format-zero-length": [ ], - "gcc-diagnostic-format=<0,2>": [ ], + "gcc-diagnostic-format=<0,2>": [ "blacklist:true" ], "gcc-diagnostic-frame-address": [ ], - "gcc-diagnostic-frame-larger-than=": [ ], + "gcc-diagnostic-frame-larger-than=": [ "blacklist:true" ], "gcc-diagnostic-free-nonheap-object": [ ], "gcc-diagnostic-function-elimination": [ ], "gcc-diagnostic-global-module": [ ], @@ -451,7 +451,7 @@ "gcc-diagnostic-ignored-qualifiers": [ ], "gcc-diagnostic-implicit": [ ], "gcc-diagnostic-implicit-fallthrough": [ ], - "gcc-diagnostic-implicit-fallthrough=<0,5>": [ ], + "gcc-diagnostic-implicit-fallthrough=<0,5>": [ "blacklist:true" ], "gcc-diagnostic-implicit-function-declaration": [ ], "gcc-diagnostic-implicit-int": [ ], "gcc-diagnostic-implicit-interface": [ ], @@ -477,13 +477,13 @@ "gcc-diagnostic-invalid-pch": [ ], "gcc-diagnostic-invalid-utf8": [ ], "gcc-diagnostic-jump-misses-init": [ ], - "gcc-diagnostic-larger-than-": [ ], - "gcc-diagnostic-larger-than=": [ ], + "gcc-diagnostic-larger-than-": [ "blacklist:true" ], + "gcc-diagnostic-larger-than=": [ "blacklist:true" ], "gcc-diagnostic-line-truncation": [ ], "gcc-diagnostic-literal-suffix": [ ], "gcc-diagnostic-logical-not-parentheses": [ ], "gcc-diagnostic-logical-op": [ ], - "gcc-diagnostic-long-long": [ ], + "gcc-diagnostic-long-long": [ "blacklist:true" ], "gcc-diagnostic-lto-type-mismatch": [ ], "gcc-diagnostic-main": [ ], "gcc-diagnostic-maybe-uninitialized": [ ], @@ -513,12 +513,12 @@ "gcc-diagnostic-namespaces": [ ], "gcc-diagnostic-narrowing": [ ], "gcc-diagnostic-nested-externs": [ ], - "gcc-diagnostic-no-alloc-size-larger-than": [ ], - "gcc-diagnostic-no-alloca-larger-than": [ ], - "gcc-diagnostic-no-frame-larger-than": [ ], - "gcc-diagnostic-no-larger-than": [ ], - "gcc-diagnostic-no-stack-usage": [ ], - "gcc-diagnostic-no-vla-larger-than": [ ], + "gcc-diagnostic-no-alloc-size-larger-than": [ "blacklist:true" ], + "gcc-diagnostic-no-alloca-larger-than": [ "blacklist:true" ], + "gcc-diagnostic-no-frame-larger-than": [ "blacklist:true" ], + "gcc-diagnostic-no-larger-than": [ "blacklist:true" ], + "gcc-diagnostic-no-stack-usage": [ "blacklist:true" ], + "gcc-diagnostic-no-vla-larger-than": [ "blacklist:true" ], "gcc-diagnostic-noexcept": [ ], "gcc-diagnostic-noexcept-type": [ ], "gcc-diagnostic-non-template-friend": [ ], @@ -526,7 +526,7 @@ "gcc-diagnostic-nonnull": [ ], "gcc-diagnostic-nonnull-compare": [ ], "gcc-diagnostic-normalized": [ ], - "gcc-diagnostic-normalized=[none|id|nfc|nfkc]": [ ], + "gcc-diagnostic-normalized=[none|id|nfc|nfkc]": [ "blacklist:true" ], "gcc-diagnostic-nrvo": [ ], "gcc-diagnostic-null-dereference": [ ], "gcc-diagnostic-objc-root-class": [ ], @@ -549,10 +549,10 @@ "gcc-diagnostic-packed-not-aligned": [ ], "gcc-diagnostic-padded": [ ], "gcc-diagnostic-parentheses": [ ], - "gcc-diagnostic-pedantic": [ ], + "gcc-diagnostic-pedantic": [ "blacklist:true" ], "gcc-diagnostic-pessimizing-move": [ ], "gcc-diagnostic-placement-new": [ ], - "gcc-diagnostic-placement-new=<0,2>": [ ], + "gcc-diagnostic-placement-new=<0,2>": [ "blacklist:true" ], "gcc-diagnostic-pmf-conversions": [ ], "gcc-diagnostic-pointer-arith": [ ], "gcc-diagnostic-pointer-compare": [ ], @@ -580,18 +580,18 @@ "gcc-diagnostic-selector": [ ], "gcc-diagnostic-self-move": [ ], "gcc-diagnostic-sequence-point": [ ], - "gcc-diagnostic-shadow": [ ], + "gcc-diagnostic-shadow": [ "blacklist:true" ], "gcc-diagnostic-shadow-compatible-local": [ ], "gcc-diagnostic-shadow-ivar": [ ], "gcc-diagnostic-shadow-local": [ ], - "gcc-diagnostic-shadow=compatible-local": [ ], - "gcc-diagnostic-shadow=global": [ ], + "gcc-diagnostic-shadow=compatible-local": [ "blacklist:true" ], + "gcc-diagnostic-shadow=global": [ "blacklist:true" ], "gcc-diagnostic-shadow=local": [ ], "gcc-diagnostic-shift-count-negative": [ ], "gcc-diagnostic-shift-count-overflow": [ ], "gcc-diagnostic-shift-negative-value": [ ], "gcc-diagnostic-shift-overflow": [ ], - "gcc-diagnostic-shift-overflow=<0,2>": [ ], + "gcc-diagnostic-shift-overflow=<0,2>": [ "blacklist:true" ], "gcc-diagnostic-sign-compare": [ ], "gcc-diagnostic-sign-conversion": [ ], "gcc-diagnostic-sign-promo": [ ], @@ -659,11 +659,11 @@ "gcc-diagnostic-unreachable-code": [ ], "gcc-diagnostic-unsafe-loop-optimizations": [ ], "gcc-diagnostic-unsuffixed-float-constants": [ ], - "gcc-diagnostic-unused": [ ], + "gcc-diagnostic-unused": [ "blacklist:true"], "gcc-diagnostic-unused-but-set-parameter": [ ], "gcc-diagnostic-unused-but-set-variable": [ ], "gcc-diagnostic-unused-const-variable": [ ], - "gcc-diagnostic-unused-const-variable=<0,2>": [ ], + "gcc-diagnostic-unused-const-variable=<0,2>": [ "blacklist:true" ], "gcc-diagnostic-unused-dummy-argument": [ ], "gcc-diagnostic-unused-function": [ ], "gcc-diagnostic-unused-label": [ ], @@ -683,10 +683,10 @@ "gcc-diagnostic-vexing-parse": [ ], "gcc-diagnostic-virtual-inheritance": [ ], "gcc-diagnostic-virtual-move-assign": [ ], - "gcc-diagnostic-vla": [ ], - "gcc-diagnostic-vla-larger-than=": [ ], + "gcc-diagnostic-vla": [ "blacklist:true" ], + "gcc-diagnostic-vla-larger-than=": [ "blacklist:true" ], "gcc-diagnostic-vla-parameter": [ ], - "gcc-diagnostic-volatile": [ ], + "gcc-diagnostic-volatile": [ "blacklist:true" ], "gcc-diagnostic-volatile-register-var": [ ], "gcc-diagnostic-write-strings": [ ], "gcc-diagnostic-xor-used-as-pow": [ ], From 98689354666697136c1eb619da60e3b5f3245b80 Mon Sep 17 00:00:00 2001 From: fdniel97 Date: Wed, 13 May 2026 21:44:47 +0200 Subject: [PATCH 4/8] finished implementation of adding gcc warnings --- .../analyzers/gcc/analyzer.py | 28 +++++++++---------- .../analyzers/gcc/result_handler.py | 8 +++--- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/analyzer/codechecker_analyzer/analyzers/gcc/analyzer.py b/analyzer/codechecker_analyzer/analyzers/gcc/analyzer.py index 3ae91a006e..3dad32f6e5 100644 --- a/analyzer/codechecker_analyzer/analyzers/gcc/analyzer.py +++ b/analyzer/codechecker_analyzer/analyzers/gcc/analyzer.py @@ -22,7 +22,8 @@ from .config_handler import GccConfigHandler from .result_handler import GccResultHandler, \ - actual_name_to_codechecker_name, codechecker_name_to_actual_name, codechecker_name_to_actual_name_disabled + actual_name_to_codechecker_name, \ + codechecker_name_to_actual_name, codechecker_name_to_actual_name_disabled LOG = get_logger('analyzer.gcc') @@ -72,8 +73,6 @@ def construct_analyzer_cmd(self, result_handler): analyzer_cmd.append('-fdiagnostics-format=sarif-stderr') for checker_name, value in config.checks().items(): - print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccxx") - print(checker_name) if value[0] == CheckerState.DISABLED: # TODO python3.9 removeprefix method would be nicer # than startswith and a hardcoded slicing @@ -119,20 +118,19 @@ def get_analyzer_checkers(cls): # Still contains the help message we need to remove. for entry in output.decode().split('\n'): warning_name, _, description = entry.strip().partition(' ') - print('ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc') - #print(actual_name_to_codechecker_name(warning_name)) - # Skip blacklisted warnings, warnings with equal signs in their name and the generic -W flag. - if (not warning_name.startswith('-W')) or ('=' in warning_name) or (warning_name == '-W') or (actual_name_to_codechecker_name(warning_name) in blacklisted_checkers): + # We filter out the unwanted checkers + if not warning_name.startswith('-W') or '=' in warning_name \ + or warning_name == '-W' \ + or actual_name_to_codechecker_name(warning_name) \ + in blacklisted_checkers: continue # GCC Static Analyzer names and warning names start with -W. - print(warning_name) - if warning_name.startswith('-W'): - # Rename the checkers interally (similarly to how we - # support cppcheck) - renamed_checker_name = \ - actual_name_to_codechecker_name(warning_name) - checker_list.append( - (renamed_checker_name, description.strip())) + # Rename the checkers interally + # (similarly to how we support cppcheck) + renamed_checker_name = \ + actual_name_to_codechecker_name(warning_name) + checker_list.append( + (renamed_checker_name, description.strip())) return checker_list except (subprocess.CalledProcessError) as e: LOG.error(e.stderr) diff --git a/analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py b/analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py index 137b56abe0..e4bf6c2add 100644 --- a/analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py +++ b/analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py @@ -29,9 +29,6 @@ def actual_name_to_codechecker_name(actual_name: str): - if not actual_name.startswith('-W'): - print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") - print(actual_name) assert actual_name.startswith('-W') if actual_name.startswith('-Wanalyzer'): return actual_name.replace("-Wanalyzer", "gcc") @@ -41,7 +38,10 @@ def actual_name_to_codechecker_name(actual_name: str): def codechecker_name_to_actual_name(codechecker_name: str): assert codechecker_name.startswith('gcc') - return codechecker_name.replace("gcc", "-Wanalyzer") + if codechecker_name.startswith('gcc-diagnostic-'): + return codechecker_name.replace("gcc-diagnostic-", "-W") + else: + return codechecker_name.replace("gcc", "-Wanalyzer") def codechecker_name_to_actual_name_disabled(codechecker_name: str): From a94ffa5ece9ca862c4e07cb599f285594ed980df Mon Sep 17 00:00:00 2001 From: fdniel97 Date: Wed, 13 May 2026 23:09:48 +0200 Subject: [PATCH 5/8] fixed UTs --- analyzer/tests/unit/test_checker_handling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analyzer/tests/unit/test_checker_handling.py b/analyzer/tests/unit/test_checker_handling.py index 8dbbc7d400..12a72b6a59 100644 --- a/analyzer/tests/unit/test_checker_handling.py +++ b/analyzer/tests/unit/test_checker_handling.py @@ -795,7 +795,7 @@ def create_analyzer_cppcheck(args, workspace): class MockCppcheckCheckerLabels: - def checkers_by_labels(self, labels): + def checkers_by_labels(self, labels, _=None): if labels[0] == 'profile:default': return [ 'cppcheck-argumentSize', From 04d51f6e9bb6ecff4c28ae8cd08a524f863f8214 Mon Sep 17 00:00:00 2001 From: fdniel97 Date: Sat, 16 May 2026 20:17:42 +0200 Subject: [PATCH 6/8] remove left over print --- analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py | 1 - 1 file changed, 1 deletion(-) diff --git a/analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py b/analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py index e4bf6c2add..c19da1bf4f 100644 --- a/analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py +++ b/analyzer/codechecker_analyzer/analyzers/gcc/result_handler.py @@ -46,7 +46,6 @@ def codechecker_name_to_actual_name(codechecker_name: str): def codechecker_name_to_actual_name_disabled(codechecker_name: str): assert codechecker_name.startswith('gcc') - print(codechecker_name) if codechecker_name.startswith('gcc-diagnostic-'): return codechecker_name.replace("gcc-diagnostic-", "-Wno-") return codechecker_name.replace("gcc", "-Wno-analyzer") From b2daa7efdb23558e4ddb0fb0dd01809e287a1d1c Mon Sep 17 00:00:00 2001 From: fdniel97 Date: Sun, 17 May 2026 19:53:24 +0200 Subject: [PATCH 7/8] added warning without 'Wno' to blacklist --- config/labels/analyzers/gcc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/labels/analyzers/gcc.json b/config/labels/analyzers/gcc.json index 3ec94c6ea3..ca4b74801e 100644 --- a/config/labels/analyzers/gcc.json +++ b/config/labels/analyzers/gcc.json @@ -417,7 +417,7 @@ "gcc-diagnostic-enum-compare": [ ], "gcc-diagnostic-enum-conversion": [ ], "gcc-diagnostic-enum-int-mismatch": [ ], - "gcc-diagnostic-error-implicit-function-declaration": [ ], + "gcc-diagnostic-error-implicit-function-declaration": [ "blacklist:true" ], "gcc-diagnostic-exceptions": [ ], "gcc-diagnostic-expansion-to-defined": [ ], "gcc-diagnostic-extra": [ ], From 1d8388b79fbcdbdeab4f46b714904663601a30d2 Mon Sep 17 00:00:00 2001 From: fdniel97 Date: Tue, 9 Jun 2026 14:48:40 +0200 Subject: [PATCH 8/8] added unit tests for new checkers --- .../tests/functional/analyze/test_analyze.py | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/analyzer/tests/functional/analyze/test_analyze.py b/analyzer/tests/functional/analyze/test_analyze.py index 0ca34ceb92..36e0650a7a 100644 --- a/analyzer/tests/functional/analyze/test_analyze.py +++ b/analyzer/tests/functional/analyze/test_analyze.py @@ -1286,6 +1286,105 @@ def test_disable_all_checkers(self): # Checkers of all 3 analyzers are disabled. self.assertEqual(out.count("No checkers enabled for"), 5) + def test_analyzer_gcc_warnings(self): + build_json = os.path.join(self.test_workspace, "build.json") + source_file = os.path.join(self.test_dir, "compiler_warning.c") + + build_log = [{"directory": self.test_workspace, + "command": "gcc -c " + source_file, "file": source_file}] + + with open(build_json, 'w', + encoding="utf-8", errors="ignore") as outfile: + json.dump(build_log, outfile) + + analyze_cmd = [self._codechecker_cmd, "analyze", build_json, + "--analyzers", "gcc", + "-o", self.report_dir, + "--disable-all", + "--verbose", "debug_analyzer"] + + process = subprocess.Popen( + analyze_cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=self.test_dir, + encoding="utf-8", + errors="ignore") + out, _ = process.communicate() + self.assertEqual(out.count("No checkers enabled for gcc"), 1) + + analyze_cmd = [self._codechecker_cmd, "analyze", build_json, + "--analyzers", "gcc", + "-o", self.report_dir, + "--enable", "gcc-diagnostic-div-by-zero", + "--verbose", "debug_analyzer"] + + process = subprocess.Popen( + analyze_cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=self.test_dir, + encoding="utf-8", + errors="ignore") + out, _ = process.communicate() + self.assertEqual(out.count("gcc: 1"), 1) + self.assertEqual(out.count("Wdiv-by-zero"), 2) + + analyze_cmd = [self._codechecker_cmd, "analyze", build_json, + "--analyzers", "gcc", + "-o", self.report_dir, + "--enable", "gcc-out-of-bounds", + "--verbose", "debug_analyzer"] + + process = subprocess.Popen( + analyze_cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=self.test_dir, + encoding="utf-8", + errors="ignore") + out, _ = process.communicate() + self.assertEqual(out.count("gcc: 1"), 1) + self.assertEqual(out.count("Wanalyzer-out-of-bounds"), 2) + + analyze_cmd = [self._codechecker_cmd, "analyze", build_json, + "--analyzers", "gcc", + "-o", self.report_dir, + "--enable", "gcc-diagnostic-comment", + "--verbose", "debug_analyzer"] + + process = subprocess.Popen( + analyze_cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=self.test_dir, + encoding="utf-8", + errors="ignore") + out, _ = process.communicate() + self.assertEqual(out.count("gcc: 1"), 1) + self.assertEqual(out.count("Wcomment"), 2) + + analyze_cmd = [self._codechecker_cmd, "analyze", build_json, + "--analyzers", "gcc", + "-o", self.report_dir, + "--enable-all", + "--disable", "gcc-diagnostic-div-by-zero", + "--disable", "gcc-out-of-bounds", + "--disable", "gcc-diagnostic-comment", + "--verbose", "debug_analyzer"] + + process = subprocess.Popen( + analyze_cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=self.test_dir, + encoding="utf-8", + errors="ignore") + out, _ = process.communicate() + self.assertEqual(out.count("Wno-div-by-zero"), 2) + self.assertEqual(out.count("Wno-analyzer-out-of-bounds"), 2) + self.assertEqual(out.count("Wno-comment"), 2) + def test_analyzer_and_checker_config(self): """Test analyzer configuration through command line flags.""" build_json = os.path.join(self.test_workspace, "build_success.json")