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

Function constructorTakesReference

lib/checkother.cpp:3310–3323  ·  view source on GitHub ↗

check if a constructor in given class scope takes a reference */

Source from the content-addressed store, hash-verified

3308
3309/* check if a constructor in given class scope takes a reference */
3310static bool constructorTakesReference(const Scope * const classScope)
3311{
3312 return std::any_of(classScope->functionList.begin(), classScope->functionList.end(), [&](const Function& constructor) {
3313 if (constructor.isConstructor()) {
3314 for (int argnr = 0U; argnr < constructor.argCount(); argnr++) {
3315 const Variable * const argVar = constructor.getArgumentVar(argnr);
3316 if (argVar && argVar->isReference()) {
3317 return true;
3318 }
3319 }
3320 }
3321 return false;
3322 });
3323}
3324
3325static bool isLargeObject(const Variable* var, const Settings& settings)
3326{

Callers 1

checkRedundantCopyMethod · 0.85

Calls 3

getArgumentVarMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected