[MC] Check the upper bound in truncate assertion

The truncateToSize function already has assertion to check the
lower boundary for the number bytes, but it does not check the
upper boundary which could still lead to usage errors.

Differential Revision: http://reviews.llvm.org/D20755

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271773 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Petr Hosek 2016-06-04 04:02:18 +00:00
parent 2c2ab512e8
commit 28a52a5d69

View File

@ -314,7 +314,7 @@ void MCAsmStreamer::EmitCommentsAndEOL() {
}
static inline int64_t truncateToSize(int64_t Value, unsigned Bytes) {
assert(Bytes && "Invalid size!");
assert(Bytes > 0 && Bytes <= 8 && "Invalid size!");
return Value & ((uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
}