| 735 | } |
| 736 | |
| 737 | std::vector<ValueType> getParentValueTypes(const Token* tok, const Settings& settings, const Token** parent) |
| 738 | { |
| 739 | if (!tok) |
| 740 | return {}; |
| 741 | if (!tok->astParent()) |
| 742 | return {}; |
| 743 | if (isInConstructorList(tok)) { |
| 744 | if (parent) |
| 745 | *parent = tok->astParent()->astOperand1(); |
| 746 | if (tok->astParent()->astOperand1()->valueType()) |
| 747 | return {*tok->astParent()->astOperand1()->valueType()}; |
| 748 | return {}; |
| 749 | } |
| 750 | const Token* ftok = nullptr; |
| 751 | if (Token::Match(tok->astParent(), "(|{|,")) { |
| 752 | int argn = -1; |
| 753 | ftok = getTokenArgumentFunction(tok, argn); |
| 754 | const Token* typeTok = nullptr; |
| 755 | if (ftok && argn >= 0) { |
| 756 | if (ftok->function()) { |
| 757 | std::vector<ValueType> result; |
| 758 | const Token* nameTok = nullptr; |
| 759 | for (const Variable* var : getArgumentVars(ftok, argn)) { |
| 760 | if (!var) |
| 761 | continue; |
| 762 | if (!var->valueType()) |
| 763 | continue; |
| 764 | nameTok = var->nameToken(); |
| 765 | result.push_back(*var->valueType()); |
| 766 | if (var->isArray()) |
| 767 | result.back().pointer += var->dimensions().size(); |
| 768 | } |
| 769 | if (result.size() == 1 && nameTok && parent) { |
| 770 | *parent = nameTok; |
| 771 | } |
| 772 | return result; |
| 773 | } |
| 774 | if (const Type* t = Token::typeOf(ftok, &typeTok)) { |
| 775 | if (astIsPointer(typeTok)) |
| 776 | return {*typeTok->valueType()}; |
| 777 | const Scope* scope = t->classScope; |
| 778 | // Check for aggregate constructors |
| 779 | if (scope && scope->numConstructors == 0 && t->derivedFrom.empty() && |
| 780 | (t->isClassType() || t->isStructType()) && numberOfArguments(ftok) <= scope->varlist.size() && |
| 781 | !scope->varlist.empty()) { |
| 782 | if (argn < scope->varlist.size()) { |
| 783 | auto it = std::next(scope->varlist.cbegin(), argn); |
| 784 | if (it->valueType()) |
| 785 | return { *it->valueType() }; |
| 786 | } |
| 787 | } |
| 788 | } |
| 789 | } |
| 790 | } |
| 791 | if (Token::Match(tok->astParent()->tokAt(-2), ". push_back|push_front|insert|push (") && |
| 792 | astIsContainer(tok->astParent()->tokAt(-2)->astOperand1())) { |
| 793 | const Token* contTok = tok->astParent()->tokAt(-2)->astOperand1(); |
| 794 | const ValueType* vtCont = contTok->valueType(); |
no test coverage detected