| 851 | } |
| 852 | |
| 853 | static void valueFlowBitAnd(TokenList& tokenlist, const Settings& settings) |
| 854 | { |
| 855 | for (Token* tok = tokenlist.front(); tok; tok = tok->next()) { |
| 856 | if (tok->str() != "&") |
| 857 | continue; |
| 858 | |
| 859 | if (tok->hasKnownValue()) |
| 860 | continue; |
| 861 | |
| 862 | if (!tok->astOperand1() || !tok->astOperand2()) |
| 863 | continue; |
| 864 | |
| 865 | MathLib::bigint number; |
| 866 | if (MathLib::isInt(tok->astOperand1()->str())) |
| 867 | number = MathLib::toBigNumber(tok->astOperand1()); |
| 868 | else if (MathLib::isInt(tok->astOperand2()->str())) |
| 869 | number = MathLib::toBigNumber(tok->astOperand2()); |
| 870 | else |
| 871 | continue; |
| 872 | |
| 873 | int bit = 0; |
| 874 | while (bit <= (MathLib::bigint_bits - 2) && ((static_cast<MathLib::bigint>(1) << bit) < number)) |
| 875 | ++bit; |
| 876 | |
| 877 | if ((static_cast<MathLib::bigint>(1) << bit) == number) { |
| 878 | setTokenValue(tok, ValueFlow::Value(0), settings); |
| 879 | setTokenValue(tok, ValueFlow::Value(number), settings); |
| 880 | } |
| 881 | } |
| 882 | } |
| 883 | |
| 884 | static void valueFlowSameExpressions(TokenList& tokenlist, const Settings& settings) |
| 885 | { |
no test coverage detected