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

Function noMemberErrorMessage

lib/checkclass.cpp:620–638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

618}
619
620static std::string noMemberErrorMessage(const Scope *scope, const char function[], bool isdefault)
621{
622 const std::string &classname = scope ? scope->className : "class";
623 const std::string type = (scope && scope->type == ScopeType::eStruct) ? "Struct" : "Class";
624 const bool isDestructor = (function[0] == 'd');
625 std::string errmsg = "$symbol:" + classname + '\n';
626
627 if (isdefault) {
628 errmsg += type + " '$symbol' has dynamic memory/resource allocation(s). The " + function + " is explicitly defaulted but the default " + function + " does not work well.";
629 if (isDestructor)
630 errmsg += " It is recommended to define the " + std::string(function) + '.';
631 else
632 errmsg += " It is recommended to define or delete the " + std::string(function) + '.';
633 } else {
634 errmsg += type + " '$symbol' does not have a " + function + " which is recommended since it has dynamic memory/resource management.";
635 }
636
637 return errmsg;
638}
639
640void CheckClassImpl::noCopyConstructorError(const Scope *scope, bool isdefault, const Token *alloc, bool inconclusive)
641{

Callers 3

noOperatorEqErrorMethod · 0.85
noDestructorErrorMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected