Fix isShiftedInt and isShiftedUint for widths > 32.
authorJustin Lebar <jlebar@google.com>
Sun, 17 Jul 2016 18:19:21 +0000 (18:19 +0000)
committerJustin Lebar <jlebar@google.com>
Sun, 17 Jul 2016 18:19:21 +0000 (18:19 +0000)
commitcbba3c4aefe92e5d2f6aa2b7fe8062e47fc28b57
treee7457b63c44def2021bc55022996fa0646556367
parentf2d0066af751cf097a17e970e825475cb06be5bf
Fix isShiftedInt and isShiftedUint for widths > 32.

Summary:
Previously we were doing 1 << S.  "1" is an int, so this doesn't work
when S >= 32.

This patch also adds some static_asserts to these functions to ensure
that we don't hit UB by shifting left too much.

Reviewers: rnk

Subscribers: llvm-commits, dylanmckay

Differential Revision: https://reviews.llvm.org/D22441

llvm-svn: 275719
llvm/include/llvm/Support/MathExtras.h
llvm/unittests/Support/MathExtrasTest.cpp