I work with close source project so I don't have any minimal example to show but I encountered problem with different reporting of unusedFunctionif order of translation units in compile_commands.json is different.
I test it with the same Cppcheck version - 2.9 - (built manually) on different environments: native Linux (Ubuntu) and WSL (Ubuntu). My build system - Meson - on those setups generates compile_commands.json with items in different order and that is reflected in some differences in the report at the end where Cppcheck outputs lines withs style: The function 'placeholder' is never used. [unusedFunction]. When I sort compile_commands.json by file key before analysis the resulting report is same on both setups.
I found it by analyzing the report - when let's say fileA::methodA was checked before, then it will end up in report, but fileB::methodB won't. But when in compile_commands.json, fileB would be checked before fileA, then fileB::methodB would end up in report as unusedFunction. As a additional note I guess that it is somehow connected with the fact that both methods use same 3rd party code with some Cppcheck issues - and maybe if those issues are reported in earlier file, that file will end up in the report.
Last edit: therisktaker 2022-12-20
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I work with close source project so I don't have any minimal example to show but I encountered problem with different reporting of
unusedFunction
if order of translation units in compile_commands.json is different.I test it with the same Cppcheck version - 2.9 - (built manually) on different environments: native Linux (Ubuntu) and WSL (Ubuntu). My build system - Meson - on those setups generates compile_commands.json with items in different order and that is reflected in some differences in the report at the end where Cppcheck outputs lines withs
style: The function 'placeholder' is never used. [unusedFunction]
. When I sort compile_commands.json byfile
key before analysis the resulting report is same on both setups.I found it by analyzing the report - when let's say fileA::methodA was checked before, then it will end up in report, but fileB::methodB won't. But when in compile_commands.json, fileB would be checked before fileA, then fileB::methodB would end up in report as unusedFunction. As a additional note I guess that it is somehow connected with the fact that both methods use same 3rd party code with some Cppcheck issues - and maybe if those issues are reported in earlier file, that file will end up in the report.
Last edit: therisktaker 2022-12-20