1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

[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

llvm-svn: 271773
This commit is contained in:
Petr Hosek 2016-06-04 04:02:18 +00:00
parent 798fe72f38
commit d42b0273f8

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));
}