/// as "bitPosition".
void flipBit(unsigned bitPosition);
+ /// Negate this APInt in place.
+ void negate() {
+ flipAllBits();
+ ++(*this);
+ }
+
/// Insert the bits from a smaller APInt starting at bitPosition.
void insertBits(const APInt &SubBits, unsigned bitPosition);
}
inline APInt operator-(APInt v) {
- v.flipAllBits();
- ++v;
+ v.negate();
return v;
}
*this += digit;
}
// If its negative, put it in two's complement form
- if (isNeg) {
- --(*this);
- this->flipAllBits();
- }
+ if (isNeg)
+ this->negate();
}
void APInt::toString(SmallVectorImpl<char> &Str, unsigned Radix,
// They want to print the signed version and it is a negative value
// Flip the bits and add one to turn it into the equivalent positive
// value and put a '-' in the result.
- Tmp.flipAllBits();
- ++Tmp;
+ Tmp.negate();
Str.push_back('-');
}