Support: Remove undefined behavior from &raw_ostream::operator<<

Don't negate signed integer types in &raw_ostream::operator<<(const
FormattedNumber &FN).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218496 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer 2014-09-26 02:48:14 +00:00
parent abf5bf221f
commit 346056ffc0

View File

@ -433,7 +433,7 @@ raw_ostream &raw_ostream::operator<<(const FormattedNumber &FN) {
char *EndPtr = NumberBuffer+sizeof(NumberBuffer);
char *CurPtr = EndPtr;
bool Neg = (FN.DecValue < 0);
uint64_t N = Neg ? -FN.DecValue : FN.DecValue;
uint64_t N = Neg ? -static_cast<uint64_t>(FN.DecValue) : FN.DecValue;
while (N) {
*--CurPtr = '0' + char(N % 10);
N /= 10;