Taking care of operation overloading functions#1108
Conversation
| return true; | ||
| } | ||
|
|
||
| const std::vector<std::string> additionalOperators = { |
There was a problem hiding this comment.
MSVC 10 doesn't like this, see https://ci.appveyor.com/project/danmar/cppcheck/build/1.73.5252/job/9n9j7jw7tlyhag4l#L63
Maybe use make_container (https://github.com/danmar/cppcheck/blob/master/lib/utils.h#L31)?
fdf70d1 to
e90706a
Compare
|
Thanks for pointing it out. I've corrected it and the check does now pasd |
| return false; | ||
| } | ||
|
|
||
| const char firstOperatorChar = funcName[operatorPrefix.length()]; |
There was a problem hiding this comment.
It seems to me there is access out of bounds if funcName is "operator".
| << "delete[]"; | ||
| const std::string opName = funcName.substr(operatorPrefix.length()); | ||
|
|
||
| for (std::vector<std::string>::const_iterator curOp = additionalOperators.begin(); curOp != additionalOperators.end(); ++curOp) { |
There was a problem hiding this comment.
Using std::find(), you only need 1 line of code to return true if vector has item.
| filename = func.filename; | ||
| unusedFunctionError(errorLogger, filename, func.lineNumber, it->first); | ||
| errors = true; | ||
| if (!isOperatorFunction(it->first)) { |
There was a problem hiding this comment.
does it work with an conditional continue here instead?
if (isOperatorFunction(it->first))
continue;
I prefer early return/continue/etc.
| if (calls.find(functionName) == calls.end()) { | ||
| const Location &loc = decl->second; | ||
| unusedFunctionError(errorLogger, loc.fileName, loc.lineNumber, functionName); | ||
| if (!isOperatorFunction(functionName)) { |
There was a problem hiding this comment.
This code is so short, so no early continue is needed.. keep this code as it is.
e90706a to
2030801
Compare
|
Thanks for the comments, I've change the parts accordingly. Hope it fits now |
This is a reworked version of the original pull request: #958
Somehow I am not allowed, to reopen the original pull request.
Sorry for the huge delay, but was a bit out of time.
I hope that this time it fits to the needs