| 3823 | } |
| 3824 | |
| 3825 | bool isUnreachableOperand(const Token *tok) |
| 3826 | { |
| 3827 | for (;;) |
| 3828 | { |
| 3829 | const Token *parent = tok->astParent(); |
| 3830 | if (!parent) |
| 3831 | break; |
| 3832 | |
| 3833 | if (parent->isBinaryOp()) { |
| 3834 | const bool left = tok == parent->astOperand1(); |
| 3835 | const Token *sibling = left ? parent->astOperand2() : parent->astOperand1(); |
| 3836 | |
| 3837 | // logical and |
| 3838 | if (Token::simpleMatch(parent, "&&") && !left && sibling->hasKnownIntValue() |
| 3839 | && !sibling->getKnownIntValue()) |
| 3840 | return true; |
| 3841 | |
| 3842 | // logical or |
| 3843 | if (Token::simpleMatch(parent, "||") && !left && sibling->hasKnownIntValue() |
| 3844 | && sibling->getKnownIntValue()) |
| 3845 | return true; |
| 3846 | |
| 3847 | // ternary |
| 3848 | if (Token::simpleMatch(parent, ":") && Token::simpleMatch(parent->astParent(), "?")) { |
| 3849 | const Token *condTok = parent->astParent()->astOperand1(); |
| 3850 | if (condTok->hasKnownIntValue() && static_cast<bool>(condTok->getKnownIntValue()) != left) |
| 3851 | return true; |
| 3852 | } |
| 3853 | } |
| 3854 | |
| 3855 | tok = parent; |
| 3856 | } |
| 3857 | |
| 3858 | return false; |
| 3859 | } |
| 3860 | |
| 3861 | static bool unknownLeafValuesAreTemplateArgs(const Token *tok) |
| 3862 | { |
no test coverage detected