| 2444 | } |
| 2445 | |
| 2446 | std::vector<const Variable*> getArgumentVars(const Token* tok, int argnr) |
| 2447 | { |
| 2448 | if (!tok) |
| 2449 | return {}; |
| 2450 | if (tok->function()) { |
| 2451 | const Variable* argvar = tok->function()->getArgumentVar(argnr); |
| 2452 | if (argvar) |
| 2453 | return {argvar}; |
| 2454 | return {}; |
| 2455 | } |
| 2456 | if (tok->variable() || Token::simpleMatch(tok, "{") || Token::Match(tok->previous(), "%type% (|{")) { |
| 2457 | const Type* type = Token::typeOf(tok); |
| 2458 | if (!type) |
| 2459 | return {}; |
| 2460 | const Scope* typeScope = type->classScope; |
| 2461 | if (!typeScope) |
| 2462 | return {}; |
| 2463 | const bool tokIsBrace = Token::simpleMatch(tok, "{"); |
| 2464 | // Aggregate constructor |
| 2465 | if (tokIsBrace && typeScope->numConstructors == 0 && argnr < typeScope->varlist.size()) { |
| 2466 | auto it = std::next(typeScope->varlist.cbegin(), argnr); |
| 2467 | return {&*it}; |
| 2468 | } |
| 2469 | std::vector<const Variable*> result; |
| 2470 | const int argCount = numberOfArguments(tok); |
| 2471 | const bool constructor = tokIsBrace || (tok->variable() && tok->variable()->nameToken() == tok); |
| 2472 | for (const Function &function : typeScope->functionList) { |
| 2473 | if (function.argCount() < argCount) |
| 2474 | continue; |
| 2475 | if (constructor && !function.isConstructor()) |
| 2476 | continue; |
| 2477 | if (!constructor && !Token::simpleMatch(function.token, "operator()")) |
| 2478 | continue; |
| 2479 | const Variable* argvar = function.getArgumentVar(argnr); |
| 2480 | if (argvar) |
| 2481 | result.push_back(argvar); |
| 2482 | } |
| 2483 | return result; |
| 2484 | } |
| 2485 | return {}; |
| 2486 | } |
| 2487 | |
| 2488 | static bool isCPPCastKeyword(const Token* tok) |
| 2489 | { |
no test coverage detected