[llvm] Fixed Windows build warnings (PR #68978)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 16 08:00:50 PDT 2023


================
@@ -382,7 +382,10 @@ inline uint64_t alignTo(uint64_t Value, uint64_t Align) {
 inline uint64_t alignToPowerOf2(uint64_t Value, uint64_t Align) {
   assert(Align != 0 && (Align & (Align - 1)) == 0 &&
          "Align must be a power of 2");
-  return (Value + Align - 1) & -Align;
+  // Replace unary minus to avoid compilation error on Windows:
+  // "unary minus operator applied to unsigned type, result still unsigned"
----------------
dwblaikie wrote:

Could/should we turn the warning off instead - if clang provides sufficient warnings in this case? (this warning seems like it'd have a fairly high false positive rate - so the sort of thing we wouldn't warn about in clang & wouldn't probably want enabled in LLVM)

https://github.com/llvm/llvm-project/pull/68978


More information about the llvm-commits mailing list