| 1650 | } |
| 1651 | |
| 1652 | static const Token *findInsertValue(const Token *tok, const Token *containerTok, const Token *keyTok, const Settings &settings) |
| 1653 | { |
| 1654 | const Token *startTok = skipLocalVars(tok); |
| 1655 | const Token *top = startTok->astTop(); |
| 1656 | |
| 1657 | const Token *icontainerTok = nullptr; |
| 1658 | const Token *ikeyTok = nullptr; |
| 1659 | const Token *ivalueTok = nullptr; |
| 1660 | if (Token::simpleMatch(top, "=") && Token::simpleMatch(top->astOperand1(), "[")) { |
| 1661 | icontainerTok = top->astOperand1()->astOperand1(); |
| 1662 | ikeyTok = top->astOperand1()->astOperand2(); |
| 1663 | ivalueTok = top->astOperand2(); |
| 1664 | } |
| 1665 | if (Token::simpleMatch(top, "(") && Token::Match(top->astOperand1(), ". insert|emplace (") && !astIsIterator(top->astOperand1()->tokAt(2))) { |
| 1666 | icontainerTok = top->astOperand1()->astOperand1(); |
| 1667 | const Token *itok = top->astOperand1()->tokAt(2)->astOperand2(); |
| 1668 | if (Token::simpleMatch(itok, ",")) { |
| 1669 | ikeyTok = itok->astOperand1(); |
| 1670 | ivalueTok = itok->astOperand2(); |
| 1671 | } else { |
| 1672 | ikeyTok = itok; |
| 1673 | } |
| 1674 | } |
| 1675 | if (!ikeyTok || !icontainerTok) |
| 1676 | return nullptr; |
| 1677 | if (isSameExpression(true, containerTok, icontainerTok, settings, true, false) && |
| 1678 | isSameExpression(true, keyTok, ikeyTok, settings, true, true)) { |
| 1679 | if (ivalueTok) |
| 1680 | return ivalueTok; |
| 1681 | return ikeyTok; |
| 1682 | } |
| 1683 | return nullptr; |
| 1684 | } |
| 1685 | |
| 1686 | void CheckStlImpl::checkFindInsert() |
| 1687 | { |
no test coverage detected