Author: Bevin Hansson Date: 2020-08-20T10:29:29+02:00 New Revision: 1e7ec4842c1a8b0c686e5674e215012867938a8d
URL: https://github.com/llvm/llvm-project/commit/1e7ec4842c1a8b0c686e5674e215012867938a8d DIFF: https://github.com/llvm/llvm-project/commit/1e7ec4842c1a8b0c686e5674e215012867938a8d.diff LOG: [AST] Get field size in chars rather than bits in RecordLayoutBuilder. In D79719, LayoutField was refactored to fetch the size of field types in bits and then convert to chars, rather than fetching them in chars directly. This is not ideal, since it makes the calculations char size dependent, and breaks for sizes that are not a multiple of the char size. This patch changes it to use getTypeInfoInChars instead of getTypeInfo. Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D85191 Added: Modified: clang/lib/AST/RecordLayoutBuilder.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index 0afe91b446ee..715b629e290d 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -1838,14 +1838,13 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D, CharUnits EffectiveFieldSize; auto setDeclInfo = [&](bool IsIncompleteArrayType) { - TypeInfo TI = Context.getTypeInfo(D->getType()); - FieldAlign = Context.toCharUnitsFromBits(TI.Align); + auto TI = Context.getTypeInfoInChars(D->getType()); + FieldAlign = TI.second; // Flexible array members don't have any size, but they have to be // aligned appropriately for their element type. EffectiveFieldSize = FieldSize = - IsIncompleteArrayType ? CharUnits::Zero() - : Context.toCharUnitsFromBits(TI.Width); - AlignIsRequired = TI.AlignIsRequired; + IsIncompleteArrayType ? CharUnits::Zero() : TI.first; + AlignIsRequired = Context.getTypeInfo(D->getType()).AlignIsRequired; }; if (D->getType()->isIncompleteArrayType()) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits