Fix #13944 FN constParameterPointer in method in derived class#8240
Fix #13944 FN constParameterPointer in method in derived class#8240ceJce wants to merge 4 commits intodanmar:mainfrom
Conversation
|
IMHO we should follow the approach used for https://trac.cppcheck.net/ticket/13282 |
Can you clarify what you object of? The inconclusion part or the warning? Before it was no warning at all, now there is but inconclusive is added since the check failed to find the base class. The inconclusion part was suggested by Daniel M. |
| if (foundAllBaseClasses) //If we've seen all the base classes and none of the above were true then it must not be virtual | ||
| return false; | ||
| return defaultVal; //If we can't see all the bases classes then we can't say conclusively | ||
| //If we can't see all the bases classes then we can't say conclusively, set inconclusive (if possible) and return default value |
There was a problem hiding this comment.
Isn't inconclusive redundant since there is pFoundAllBaseClasses already?
The warning should have the "either ... or" format, and be inconclusive. |
|
I agree the warning message can be clarified and it would be good to be somewhat consistent.. |
a5a7044 to
04b4e37
Compare
04b4e37 to
81ef7f1
Compare
Add inconclusive and default=false (instead of true) in checkConstPointer.
Changed so that error message is in format "either ... or can be const" format. Added testcase with override, i.e. no warning.
f245c18 to
9433a25
Compare
|
| void invalidPointerCastError(const Token* tok, const std::string& from, const std::string& to, bool inconclusive, bool toIsInt); | ||
| void passedByValueError(const Variable* var, bool inconclusive, bool isRangeBasedFor = false); | ||
| void constVariableError(const Variable *var, const Function *function); | ||
| void constVariableError(const Variable *var, const Function *function, const bool *inconclusive = nullptr); |
There was a problem hiding this comment.
inconclusive doesn't need to be a pointer.
it seems to me that we can achieve the same behavior with a bool inconclusive = false here.



class C : public QObject
{
public:
void func01(QPoint* pt) { // <- pt can be const
if (nullptr == pt) {}
}
};
The fix adds inconclusive warning for this case, including tests.