| 1598 | } |
| 1599 | |
| 1600 | bool CheckIOImpl::ArgumentInfo::isStdVectorOrString() |
| 1601 | { |
| 1602 | if (!isCPP) |
| 1603 | return false; |
| 1604 | if (variableInfo->isStlType(stl_vector)) { |
| 1605 | typeToken = variableInfo->typeStartToken()->tokAt(4); |
| 1606 | _template = true; |
| 1607 | return true; |
| 1608 | } |
| 1609 | if (variableInfo->isStlType(stl_string)) { |
| 1610 | tempToken = new Token(variableInfo->typeStartToken()); |
| 1611 | if (variableInfo->typeStartToken()->strAt(2) == "string") |
| 1612 | tempToken->str("char"); |
| 1613 | else |
| 1614 | tempToken->str("wchar_t"); |
| 1615 | typeToken = tempToken; |
| 1616 | return true; |
| 1617 | } |
| 1618 | if (variableInfo->type() && !variableInfo->type()->derivedFrom.empty()) { |
| 1619 | const std::vector<Type::BaseInfo>& derivedFrom = variableInfo->type()->derivedFrom; |
| 1620 | for (const Type::BaseInfo & i : derivedFrom) { |
| 1621 | const Token* nameTok = i.nameTok; |
| 1622 | if (Token::Match(nameTok, "std :: vector|array <")) { |
| 1623 | typeToken = nameTok->tokAt(4); |
| 1624 | _template = true; |
| 1625 | return true; |
| 1626 | } |
| 1627 | if (Token::Match(nameTok, "std :: string|wstring")) { |
| 1628 | tempToken = new Token(variableInfo->typeStartToken()); |
| 1629 | if (nameTok->strAt(2) == "string") |
| 1630 | tempToken->str("char"); |
| 1631 | else |
| 1632 | tempToken->str("wchar_t"); |
| 1633 | typeToken = tempToken; |
| 1634 | return true; |
| 1635 | } |
| 1636 | } |
| 1637 | } else if (variableInfo->type()) { |
| 1638 | const Scope * classScope = variableInfo->type()->classScope; |
| 1639 | if (classScope) { |
| 1640 | for (const Function &func : classScope->functionList) { |
| 1641 | if (func.name() == "operator[]") { |
| 1642 | if (Token::Match(func.retDef, "%type% &")) { |
| 1643 | typeToken = func.retDef; |
| 1644 | return true; |
| 1645 | } |
| 1646 | } |
| 1647 | } |
| 1648 | } |
| 1649 | } |
| 1650 | |
| 1651 | return false; |
| 1652 | } |
| 1653 | |
| 1654 | static const std::set<std::string> stl_container = { |
| 1655 | "array", "bitset", "deque", "forward_list", |