Ericsson / codechecker

CodeChecker is an analyzer tooling, defect database and viewer extension for static and dynamic analyzer tools.
https://codechecker.readthedocs.io
Apache License 2.0
2.27k stars 383 forks source link

The actual error in a report message should be at the diagnostic message, not at the last bug path event #3722

Open vodorok opened 2 years ago

vodorok commented 2 years ago

The diagnostic message should be used when indicating an error, as this report element indicates an error in the code semantically. Right now the last bug path event is treated as the error because Clang static analyzer emits reports in format where diagnostic message is duplicated in the last position, this is a clangsa quirk and Codechecker should not rely on this behavior. For Cppcheck to work correctly the bug path event list is needed to be extended with the diagnostic message, which is a redundant step, as the diagnostic message also has a location.

The position of an error is critical from the point of report suppression, so the impact of this modification should be carefully examined, but a clearer error presentation would be desirable in the future.

This is a follow up to #3680 Also a follow up to #3721

whisperity commented 2 years ago

Note that the reliance on the invariant for the last element is indeed a CSA-related kludge, because Clang-Tidy has always been emitting diagnostics as [warning, note, ..., warning) ranges: every note (and remark) after a warning belongs to that warning (or error), so it is the top-level warning outputs that demarcate individual reports...