Fix #11483 FN unusedFunction for method with inline implementation#4692
Fix #11483 FN unusedFunction for method with inline implementation#4692chrchr-github wants to merge 11 commits into
Conversation
| return _next; | ||
| } | ||
|
|
||
| /** IntValue interprets the attribute as an integer, and returns the value. |
There was a problem hiding this comment.
Please do not change external files. Put it in the suppression file.
| } | ||
|
|
||
| /** get allocation id for function by name (deprecated, use other alloc) */ | ||
| // cppcheck-suppress unusedFunction - only used in unit tests |
There was a problem hiding this comment.
I would drop the mention of unit tests for obvious helper functions like this. Same for the other methods in this file.
I will review this in more detail later on though.
| return const_cast<Scope *>(this->findScope(tok, const_cast<const Scope *>(startScope))); | ||
| } | ||
|
|
||
| bool isVarId(nonneg int varid) const { |
There was a problem hiding this comment.
We should keep this for now.
| void isSigned(const bool sign) { | ||
| setFlag(fIsSigned, sign); | ||
| } | ||
| bool isPointerCompare() const { |
There was a problem hiding this comment.
We should keep this even if it isn't used. Same for the other methods in this file.
| if: false # TODO: fails with preprocessorErrorDirective - see #10667 | ||
| run: | | ||
| ./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib --library=qt -D__CPPCHECK__ -D__GNUC__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --enable=unusedFunction --exception-handling -rp=. --project=cmake.output/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr | ||
| ./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib --library=qt -D__CPPCHECK__ -D__GNUC__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --enable=unusedFunction --exception-handling -rp=. --project=cmake.output/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr -icmake.output.notest |
There was a problem hiding this comment.
We should not ignore the generated files.
There was a problem hiding this comment.
This will also lead to false positives since function declarations are missing.
There was a problem hiding this comment.
As long as suppressions don't work, this is dead in the water anyway. The problem seems to be related to the way included code is handled.
There was a problem hiding this comment.
Ah - this is causing the "false positives" in the GUI code. Please revert this.
|
No need to close this. The change is good. There's several issues with suppressions. Some of them also keeping me from finishing some PRs. |
|
Uhmm, I see no obvious way to fix this. The warning is produced for a location in the .cpp file, whereas the suppression is in the header file. All tokens from the included file are assigned the same line in the .cpp, so that their actual origin is lost. |
|
I added a test for this case here: firewave@2d8d48c. The location is wrong when the fix is applied. So this might be a place to start at. |
|
I want to finish up with my suppression and platform stuff first and will take a look afterwards. I have a few things to look at in simplecpp anyways and will do it along the way. |
This is not a simplecpp issue it seems. The line is actually correct just the filename isn't. The problem is there is no file context for the token and we just use the source filename from the We probably need to add all include files to the There might be a different way though as we do report other issues from headers with the proper filename. I updated the branch with that test: https://github.com/firewave/cppcheck/commits/inc-test |
There was a problem hiding this comment.
There's TokenList::file() as convenience function. Didn't know about that until yesterday,
There was a problem hiding this comment.
Yeah, me neither.
So just using the correct filename fixes the problem with the location. For some reason, I thought the index was also necessary.
|
Please add a test and look at the open conversations. We should suppress the warning for all externals. I think the GUI warnings with the overrides might be false positives maybe related to something I already reported. I will take a look later. The other one is related to commented code and should be commented instead of being removed - see #4688. |
|
Please feel free to take over. You already found the solution, and I'm kinda tired of messing with this. |
|
I just gave a few pointers so this could advance. This is probably far from a solution as during debugging I did not see more than a single file ever being stored in the TokenList and it seems the only And imagine how tired I am that I have to wait weeks/months for things to be reviewed at all...and the countless conflicts I have to resolve all the time because of that. And I already stated that I am not able to look into things beyond the one I am still working on, sorry. |
|
I think I figured out the problem - at least within the unit test. The |
|
The tests in #5281 show that the suppressions are working as expected. The failure in the unit tests is caused by the way we preprocess code for them. |
No description provided.