| 3355 | } |
| 3356 | |
| 3357 | void CheckClassImpl::uselessOverrideError(const Function *funcInBase, const Function *funcInDerived, bool isSameCode) |
| 3358 | { |
| 3359 | const std::string functionName = funcInDerived ? ((funcInDerived->isDestructor() ? "~" : "") + funcInDerived->name()) : ""; |
| 3360 | const std::string funcType = (funcInDerived && funcInDerived->isDestructor()) ? "destructor" : "function"; |
| 3361 | |
| 3362 | ErrorPath errorPath; |
| 3363 | if (funcInBase && funcInDerived) { |
| 3364 | errorPath.emplace_back(funcInBase->tokenDef, "Virtual " + funcType + " in base class"); |
| 3365 | errorPath.emplace_back(funcInDerived->tokenDef, char(std::toupper(funcType[0])) + funcType.substr(1) + " in derived class"); |
| 3366 | } |
| 3367 | |
| 3368 | std::string errStr = "\nThe " + funcType + " '$symbol' overrides a " + funcType + " in a base class but "; |
| 3369 | if (isSameCode) { |
| 3370 | errStr += "is identical to the overridden function"; |
| 3371 | } |
| 3372 | else |
| 3373 | errStr += "just delegates back to the base class."; |
| 3374 | reportError(std::move(errorPath), Severity::style, "uselessOverride", |
| 3375 | "$symbol:" + functionName + |
| 3376 | errStr, |
| 3377 | CWE(0U) /* Unknown CWE! */, |
| 3378 | Certainty::normal); |
| 3379 | } |
| 3380 | |
| 3381 | static const Token* getSingleFunctionCall(const Scope* scope) { |
| 3382 | const Token* const start = scope->bodyStart->next(); |
no test coverage detected