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

Function getDuplInheritedMembersRecursive

lib/checkclass.cpp:3146–3169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3144}
3145
3146static std::vector<DuplMemberInfo> getDuplInheritedMembersRecursive(const Type* typeCurrent, const Type* typeBase, bool skipPrivate = true)
3147{
3148 std::vector<DuplMemberInfo> results;
3149 for (const Type::BaseInfo &parentClassIt : typeBase->derivedFrom) {
3150 // Check if there is info about the 'Base' class
3151 if (!parentClassIt.type || !parentClassIt.type->classScope)
3152 continue;
3153 // Don't crash on recursive templates
3154 if (parentClassIt.type == typeBase)
3155 continue;
3156 // Check if they have a member variable in common
3157 for (const Variable &classVarIt : typeCurrent->classScope->varlist) {
3158 for (const Variable &parentClassVarIt : parentClassIt.type->classScope->varlist) {
3159 if (classVarIt.name() == parentClassVarIt.name() && (!parentClassVarIt.isPrivate() || !skipPrivate)) // Check if the class and its parent have a common variable
3160 results.emplace_back(&classVarIt, &parentClassVarIt, &parentClassIt);
3161 }
3162 }
3163 if (typeCurrent != parentClassIt.type) {
3164 const auto recursive = getDuplInheritedMembersRecursive(typeCurrent, parentClassIt.type, skipPrivate);
3165 results.insert(results.end(), recursive.begin(), recursive.end());
3166 }
3167 }
3168 return results;
3169}
3170
3171static std::vector<DuplMemberFuncInfo> getDuplInheritedMemberFunctionsRecursive(const Type* typeCurrent, const Type* typeBase, bool skipPrivate = true)
3172{

Callers 2

checkUselessOverrideMethod · 0.85

Calls 3

nameMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected