[PATCH] D32212: Create some helpers for generating bit masks
Adrian McCarthy via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 19 09:26:08 PDT 2017
amccarth added inline comments.
================
Comment at: llvm/trunk/include/llvm/Support/MathExtras.h:207
+ assert(N <= Bits && "Invalid bit index");
+ return -T(N != 0) & (T(-1) >> (Bits - N));
+}
----------------
Be aware that this can lead to compiler warnings, at least in MSVC, if T is an unsigned type:
[[ https://msdn.microsoft.com/en-us/library/4kh09110.aspx | C4146: unary minus operator applied to unsigned type, result still unsigned ]]
Depending on the specific details, this can be a level 2 or level 3 warning. I'm surprised the tests aren't triggering it. We must disable this warning somewhere.
Repository:
rL LLVM
https://reviews.llvm.org/D32212
More information about the llvm-commits
mailing list