| 97 | } |
| 98 | |
| 99 | MathLib::bigint truncateIntValue(MathLib::bigint value, size_t value_size, const ValueType::Sign dst_sign) |
| 100 | { |
| 101 | if (value_size == 0) |
| 102 | return value; |
| 103 | |
| 104 | const MathLib::biguint unsignedMaxValue = std::numeric_limits<MathLib::biguint>::max() >> ((sizeof(unsignedMaxValue) - value_size) * 8); |
| 105 | const MathLib::biguint signBit = 1ULL << ((value_size * 8) - 1); |
| 106 | value &= unsignedMaxValue; |
| 107 | if (dst_sign == ValueType::Sign::SIGNED && (value & signBit)) |
| 108 | value |= ~unsignedMaxValue; |
| 109 | |
| 110 | return value; |
| 111 | } |
| 112 | |
| 113 | static nonneg int getSizeOfType(const Token *typeTok, const Settings &settings) |
| 114 | { |
no outgoing calls
no test coverage detected