[PATCH] D68942: [Alignment][NFC] Move and type functions from MathExtras to Alignment

Hans Wennborg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 17 02:02:52 PDT 2019


hans added inline comments.


================
Comment at: llvm/include/llvm/Support/Alignment.h:176
+  uintptr_t ArithAddr = reinterpret_cast<uintptr_t>(Addr);
+  assert(ArithAddr + Alignment.value() - 1 >= ArithAddr && "Overflow");
+  return alignTo(ArithAddr, Alignment);
----------------
Because Alignment.value() is a uint64_t, this won't catch overflows when addresses are 32 bits.

This breaks the AlignmentDeathTest.AlignAddr test on 32-bit Windows, for example. And also here: http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/10957


Hopefully r375090 fixes this, but maybe it would be better for Alignment::value() not to be 64-bit for example.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68942/new/

https://reviews.llvm.org/D68942





More information about the llvm-commits mailing list