Fix #11842 FN constParameterPointer with library function#5257
Fix #11842 FN constParameterPointer with library function#5257chrchr-github merged 40 commits intocppcheck-opensource:mainfrom
Conversation
|
I'm not sure if all of the new warnings should be suppressed, or if it's better to change the tests. Changing the tests would reveal any false positives, and not distract from the original warnings the test was written for. |
| } | ||
| } else if (!parent->isCast()) { | ||
| const auto dir = mSettings->library.getArgDirection(ftok, argn + 1); | ||
| if (dir == Library::ArgumentChecks::Direction::DIR_IN) |
There was a problem hiding this comment.
It seems like this logic should be in isVariableChangedByFunctionCall, but I wonder why we skip it when the parent is a cast.
There was a problem hiding this comment.
For this test:
void f(int, const int*);
void f(int i, int* p) {
f(i, const_cast<const int*>(p));
}
Seems not ideal though.
There was a problem hiding this comment.
isVariableChangedByFunctionCall() already has handling for library functions, but it is not quite aligned with getTokenArgumentFunction() (constructors, init lists).
There was a problem hiding this comment.
isVariableChangedByFunctionCall() already has handling for library functions, but it is not quite aligned with getTokenArgumentFunction() (constructors, init lists).
We should probably have an issue to track that.
There was a problem hiding this comment.
If we only rely on isVariableChangedByFunctionCall(), there would be FPs for those:
struct A {
int* x;
A(int* y) : x(y) {}
};
void f(int* q) {
int* a[1] = { q };
}
I'm not convinced that isVariableChangedByFunctionCall() should return true here.
Commit 7325154 ("Fix #11842 FN constParameterPointer with library function (cppcheck-opensource#5257)") most likely introduced a regression for (C) function pointers passed to functions provided by the standard library that cppcheck has knowledge about.
Commit 7325154 ("Fix #11842 FN constParameterPointer with library function (cppcheck-opensource#5257)") most a regression for (C) function pointers passed to functions provided by the standard library that cppcheck has knowledge about.
No description provided.