| 2614 | } |
| 2615 | |
| 2616 | static const Function* findConstructor(const Scope* scope, const Token* tok, const std::vector<const Token*>& args) |
| 2617 | { |
| 2618 | if (!tok) |
| 2619 | return nullptr; |
| 2620 | const Function* f = tok->function(); |
| 2621 | if (!f && tok->astOperand1()) |
| 2622 | f = tok->astOperand1()->function(); |
| 2623 | // Search for a constructor |
| 2624 | if (!f || !f->isConstructor()) { |
| 2625 | f = nullptr; |
| 2626 | std::vector<const Function*> candidates; |
| 2627 | for (const Function& function : scope->functionList) { |
| 2628 | if (function.minArgCount() > args.size()) |
| 2629 | continue; |
| 2630 | if (!function.isConstructor()) |
| 2631 | continue; |
| 2632 | candidates.push_back(&function); |
| 2633 | } |
| 2634 | // TODO: Narrow the candidates |
| 2635 | if (candidates.size() == 1) |
| 2636 | f = candidates.front(); |
| 2637 | } |
| 2638 | if (!f) |
| 2639 | return nullptr; |
| 2640 | return f; |
| 2641 | } |
| 2642 | |
| 2643 | static void valueFlowLifetimeClassConstructor(Token* tok, |
| 2644 | const Type* t, |
no test coverage detected