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

Method pureVirtualFunctionCallInConstructorError

lib/checkclass.cpp:3092–3110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3090}
3091
3092void CheckClassImpl::pureVirtualFunctionCallInConstructorError(
3093 const Function * scopeFunction,
3094 const std::list<const Token *> & tokStack,
3095 const std::string &purefuncname)
3096{
3097 const char * scopeFunctionTypeName = scopeFunction ? getFunctionTypeName(scopeFunction->type) : "constructor";
3098
3099 ErrorPath errorPath;
3100 std::transform(tokStack.cbegin(), tokStack.cend(), std::back_inserter(errorPath), [](const Token* tok) {
3101 return ErrorPathItem(tok, "Calling " + tok->str());
3102 });
3103 if (!errorPath.empty())
3104 errorPath.back().second = purefuncname + " is a pure virtual function without body";
3105
3106 reportError(std::move(errorPath), Severity::warning, "pureVirtualCall",
3107 "$symbol:" + purefuncname +"\n"
3108 "Call of pure virtual function '$symbol' in " + scopeFunctionTypeName + ".\n"
3109 "Call of pure virtual function '$symbol' in " + scopeFunctionTypeName + ". The call will fail during runtime.", CWE(0U), Certainty::normal);
3110}
3111
3112
3113//---------------------------------------------------------------------------

Callers 1

getErrorMessagesMethod · 0.80

Calls 5

getFunctionTypeNameFunction · 0.85
reportErrorFunction · 0.70
CWEClass · 0.70
strMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected