[PATCH] D85191: [AST] Get field size in chars rather than bits in RecordLayoutBuilder.

Xiangling Liao via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 4 07:16:02 PDT 2020


Xiangling_L 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;
----------------
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.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85191



More information about the cfe-commits mailing list