| 2407 | } |
| 2408 | |
| 2409 | bool CheckClassImpl::isMemberFunc(const Scope *scope, const Token *tok) |
| 2410 | { |
| 2411 | if (!tok->function()) { |
| 2412 | if (Token::simpleMatch(tok->astParent(), ".") && Token::simpleMatch(tok->astParent()->astOperand1(), "this")) |
| 2413 | return true; |
| 2414 | for (const Function &func : scope->functionList) { |
| 2415 | if (func.name() == tok->str()) { |
| 2416 | const Token* tok2 = tok->tokAt(2); |
| 2417 | int argsPassed = tok2->str() == ")" ? 0 : 1; |
| 2418 | for (;;) { |
| 2419 | tok2 = tok2->nextArgument(); |
| 2420 | if (tok2) |
| 2421 | argsPassed++; |
| 2422 | else |
| 2423 | break; |
| 2424 | } |
| 2425 | if (argsPassed == func.argCount() || |
| 2426 | (func.isVariadic() && argsPassed >= (func.argCount() - 1)) || |
| 2427 | (argsPassed < func.argCount() && argsPassed >= func.minArgCount())) |
| 2428 | return true; |
| 2429 | } |
| 2430 | } |
| 2431 | } else if (tok->function()->nestedIn == scope) |
| 2432 | return !tok->function()->isStatic(); |
| 2433 | |
| 2434 | // not found in this class |
| 2435 | if (!scope->definedType->derivedFrom.empty()) { |
| 2436 | // check each base class |
| 2437 | for (const Type::BaseInfo & i : scope->definedType->derivedFrom) { |
| 2438 | // find the base class |
| 2439 | const Type *derivedFrom = i.type; |
| 2440 | |
| 2441 | // find the function in the base class |
| 2442 | if (derivedFrom && derivedFrom->classScope && derivedFrom->classScope != scope) { |
| 2443 | if (isMemberFunc(derivedFrom->classScope, tok)) |
| 2444 | return true; |
| 2445 | } |
| 2446 | } |
| 2447 | } |
| 2448 | |
| 2449 | return false; |
| 2450 | } |
| 2451 | |
| 2452 | bool CheckClassImpl::isConstMemberFunc(const Scope *scope, const Token *tok) |
| 2453 | { |
nothing calls this directly
no test coverage detected