[PATCH] D16843: [Sema] Fix bug in TypeLocBuilder::pushImpl

Manman Ren via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 18 09:52:42 PST 2016


manmanren added a comment.



> If Capacity is not a multiple of 8, (LocalSize + NumBytesAtAlign4) % 8 doesn't tell you whether the new element will be 8-byte aligned. For example, if Capacity==36, NumBytesAtAlign4==4, and LocalSize==8, (LocalSize + NumBytesAtAlign4) equals 12 but padding is not needed as the new element can start at Index=24.


I was reading the numbers wrong.

> Note that it's possible to have a Capacity that isn't a multiple of 8 by calling TypeLocBuilder::reserve. I think padding is needed if the new index (Index - LocalSize) is not a multiple of 8.


You are right, I missed the case where Capacity may not be 8-byte aligned.


http://reviews.llvm.org/D16843





More information about the cfe-commits mailing list