MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / truncateIntValue

Function truncateIntValue

lib/vf_common.cpp:99–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 3

setTokenValueFunction · 0.85
truncateValuesFunction · 0.85
writeValueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected