diff options
author | Alexey Samsonov <vonosmas@gmail.com> | 2014-08-20 18:30:07 +0000 |
---|---|---|
committer | Alexey Samsonov <vonosmas@gmail.com> | 2014-08-20 18:30:07 +0000 |
commit | 314c643b4a80f71d12024b495e6c626ea5ca860b (patch) | |
tree | 766b9ae58952561b7721e0c987705f755717e6ee /llvm/lib/Support/ScaledNumber.cpp | |
parent | b0cc53cf971c3fe7f44ae7fc88167e04412c7d3a (diff) | |
download | bcm5719-llvm-314c643b4a80f71d12024b495e6c626ea5ca860b.tar.gz bcm5719-llvm-314c643b4a80f71d12024b495e6c626ea5ca860b.zip |
Fix undefined behavior (left shift by 64 bits) in ScaledNumber::toString().
This bug is reported by UBSan.
llvm-svn: 216116
Diffstat (limited to 'llvm/lib/Support/ScaledNumber.cpp')
-rw-r--r-- | llvm/lib/Support/ScaledNumber.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Support/ScaledNumber.cpp b/llvm/lib/Support/ScaledNumber.cpp index 3fe027ba331..fc6d4e7be43 100644 --- a/llvm/lib/Support/ScaledNumber.cpp +++ b/llvm/lib/Support/ScaledNumber.cpp @@ -220,6 +220,9 @@ std::string ScaledNumberBase::toString(uint64_t D, int16_t E, int Width, } else if (E > -64) { Above0 = D >> -E; Below0 = D << (64 + E); + } else if (E == -64) { + // Special case: shift by 64 bits is undefined behavior. + Below0 = D; } else if (E > -120) { Below0 = D >> (-E - 64); Extra = D << (128 + E); |