ebevhan added inline comments.

================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1841
   auto setDeclInfo = [&](bool IsIncompleteArrayType) {
-    TypeInfo TI = Context.getTypeInfo(D->getType());
-    FieldAlign = Context.toCharUnitsFromBits(TI.Align);
+    auto TI = Context.getTypeInfoInChars(D->getType());
+    FieldAlign = TI.second;
----------------
ebevhan wrote:
> Xiangling_L wrote:
> > In most cases, `getTypeInfoInChars` invokes `getTypeInfo` underneath. So to 
> > make people be careful about this, I would suggest to leave a comment 
> > explaining/claiming we have to call `getTypeInfoInChars` here. And also 
> > maybe adding a testcase to guard the scenario you were talking about would 
> > be helpful to prevent someone to use `getTypeInfo` here in the future.
> I can do that.
> 
> I honestly don't think it would be a bad idea to add an assertion to 
> toCharUnitsFromBits that checks for non-bytesize-multiple amounts. I wonder 
> how much would fail if I did that, though.
Oh, I guess I only really replied to the first part about adding a comment 
here... I'm not sure I can make a test case for this, since I don't think 
there's anything that triggers this upstream.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85191

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

Reply via email to