EnumMaskIterator: ASSERT when the mask is too big.

This will catch errors when someone updates an enum used with
EnumMaskIterator without updating EnumBitmaskSize. Previously it would
just ignore the extra bits, which produced super confusing bugs.

Bug: dawn:635
Change-Id: Ib0bf3f252db317a1bfdeb687b2426801a79b524d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/38260
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2021-01-21 10:11:54 +00:00 committed by Commit Bot service account
parent 762814bd92
commit 738aa17493
1 changed files with 2 additions and 0 deletions

View File

@ -29,6 +29,8 @@ namespace dawn_native {
public:
EnumMaskIterator(const T& mask) : mBitSetIterator(std::bitset<N>(static_cast<U>(mask))) {
// If you hit this ASSERT it means that you forgot to update EnumBitmaskSize<T>::value;
ASSERT(U(mask) == 0 || Log2(uint64_t(U(mask))) < N);
}
class Iterator final {