chrish_ericsson_atx marked 2 inline comments as done.
chrish_ericsson_atx added inline comments.


================
Comment at: clang/lib/Sema/SemaChecking.cpp:13989
+      MaxElems <<= AddrBits;
+      MaxElems /= ElemBytes;
+
----------------
ebevhan wrote:
> The size calculations here could probably be simplified by doing something 
> like this:
> 
> * If getActiveBits of the index is greater than AddrBits, it's indexing 
> outside
> * Construct an AddrBits-wide APInt containing the index value
> * Use umul_ovf with getTypeSizeInChars(ElementType); if that overflows, it's 
> indexing outside
> 
Refactored as suggested.  I agree -- it's cleaner this way (eliminates the 
loop), and avoids a divide when no diag is required.  But it's still hard to 
read because of all the APInt bitwidth hijinks necessary to do the math without 
tripping asserts. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86796

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to