| 882 | } |
| 883 | |
| 884 | static void valueFlowSameExpressions(TokenList& tokenlist, const Settings& settings) |
| 885 | { |
| 886 | for (Token* tok = tokenlist.front(); tok; tok = tok->next()) { |
| 887 | if (tok->hasKnownIntValue()) |
| 888 | continue; |
| 889 | |
| 890 | if (!tok->astOperand1() || !tok->astOperand2()) |
| 891 | continue; |
| 892 | |
| 893 | if (tok->astOperand1()->isLiteral() || tok->astOperand2()->isLiteral()) |
| 894 | continue; |
| 895 | |
| 896 | if (!astIsIntegral(tok->astOperand1(), false) && !astIsIntegral(tok->astOperand2(), false)) |
| 897 | continue; |
| 898 | |
| 899 | long long val; |
| 900 | |
| 901 | if (Token::Match(tok, "==|>=|<=|/|/=")) { |
| 902 | val = 1; |
| 903 | } |
| 904 | else if (Token::Match(tok, "!=|>|<|%|%=|-|-=|^|^=")) { |
| 905 | val = 0; |
| 906 | } |
| 907 | else |
| 908 | continue; |
| 909 | |
| 910 | ValueFlow::Value value(val); |
| 911 | value.setKnown(); |
| 912 | |
| 913 | if (isSameExpression(false, tok->astOperand1(), tok->astOperand2(), settings, true, true, &value.errorPath)) { |
| 914 | setTokenValue(tok, std::move(value), settings); |
| 915 | } |
| 916 | } |
| 917 | } |
| 918 | |
| 919 | static bool getExpressionRange(const Token* expr, MathLib::bigint* minvalue, MathLib::bigint* maxvalue) |
| 920 | { |
no test coverage detected