MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / overrideError

Method overrideError

lib/checkclass.cpp:3339–3355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3337}
3338
3339void CheckClassImpl::overrideError(const Function *funcInBase, const Function *funcInDerived)
3340{
3341 const std::string functionName = funcInDerived ? ((funcInDerived->isDestructor() ? "~" : "") + funcInDerived->name()) : "";
3342 const std::string funcType = (funcInDerived && funcInDerived->isDestructor()) ? "destructor" : "function";
3343
3344 ErrorPath errorPath;
3345 if (funcInBase && funcInDerived) {
3346 errorPath.emplace_back(funcInBase->tokenDef, "Virtual " + funcType + " in base class");
3347 errorPath.emplace_back(funcInDerived->tokenDef, char(std::toupper(funcType[0])) + funcType.substr(1) + " in derived class");
3348 }
3349
3350 reportError(std::move(errorPath), Severity::style, "missingOverride",
3351 "$symbol:" + functionName + "\n"
3352 "The " + funcType + " '$symbol' overrides a " + funcType + " in a base class but is not marked with a 'override' specifier.",
3353 CWE(0U) /* Unknown CWE! */,
3354 Certainty::normal);
3355}
3356
3357void CheckClassImpl::uselessOverrideError(const Function *funcInBase, const Function *funcInDerived, bool isSameCode)
3358{

Callers 1

getErrorMessagesMethod · 0.80

Calls 3

reportErrorFunction · 0.70
CWEClass · 0.70
nameMethod · 0.45

Tested by

no test coverage detected