Skip to content

Commit 363be51

Browse files
committed
fixup! adjust other parts of CodeGen to use isEmptyFieldForLayout/isEmptyRecordForLayout
1 parent 6acbcfa commit 363be51

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

clang/lib/CodeGen/CGExprConstant.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2499,7 +2499,8 @@ static llvm::Constant *EmitNullConstant(CodeGenModule &CGM,
24992499
for (const auto *Field : record->fields()) {
25002500
// Fill in non-bitfields. (Bitfields always use a zero pattern, which we
25012501
// will fill in later.)
2502-
if (!Field->isBitField() && !Field->isZeroSize(CGM.getContext())) {
2502+
if (!Field->isBitField() &&
2503+
!isEmptyFieldForLayout(CGM.getContext(), Field)) {
25032504
unsigned fieldIndex = layout.getLLVMFieldNo(Field);
25042505
elements[fieldIndex] = CGM.EmitNullConstant(Field->getType());
25052506
}

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "CGOpenMPRuntime.h"
14+
#include "ABIInfoImpl.h"
1415
#include "CGCXXABI.h"
1516
#include "CGCleanup.h"
1617
#include "CGRecordLayout.h"
@@ -7719,23 +7720,28 @@ class MappableExprsHandler {
77197720
for (const auto &I : RD->bases()) {
77207721
if (I.isVirtual())
77217722
continue;
7722-
const auto *Base = I.getType()->getAsCXXRecordDecl();
7723+
7724+
QualType BaseTy = I.getType();
7725+
const auto *Base = BaseTy->getAsCXXRecordDecl();
77237726
// Ignore empty bases.
7724-
if (Base->isEmpty() || CGF.getContext()
7725-
.getASTRecordLayout(Base)
7726-
.getNonVirtualSize()
7727-
.isZero())
7727+
if (isEmptyRecordForLayout(CGF.getContext(), BaseTy) ||
7728+
CGF.getContext()
7729+
.getASTRecordLayout(Base)
7730+
.getNonVirtualSize()
7731+
.isZero())
77287732
continue;
77297733

77307734
unsigned FieldIndex = RL.getNonVirtualBaseLLVMFieldNo(Base);
77317735
RecordLayout[FieldIndex] = Base;
77327736
}
77337737
// Fill in virtual bases.
77347738
for (const auto &I : RD->vbases()) {
7735-
const auto *Base = I.getType()->getAsCXXRecordDecl();
7739+
QualType BaseTy = I.getType();
77367740
// Ignore empty bases.
7737-
if (Base->isEmpty())
7741+
if (isEmptyRecordForLayout(CGF.getContext(), BaseTy))
77387742
continue;
7743+
7744+
const auto *Base = BaseTy->getAsCXXRecordDecl();
77397745
unsigned FieldIndex = RL.getVirtualBaseIndex(Base);
77407746
if (RecordLayout[FieldIndex])
77417747
continue;
@@ -7746,7 +7752,8 @@ class MappableExprsHandler {
77467752
for (const auto *Field : RD->fields()) {
77477753
// Fill in non-bitfields. (Bitfields always use a zero pattern, which we
77487754
// will fill in later.)
7749-
if (!Field->isBitField() && !Field->isZeroSize(CGF.getContext())) {
7755+
if (!Field->isBitField() &&
7756+
!isEmptyFieldForLayout(CGF.getContext(), Field)) {
77507757
unsigned FieldIndex = RL.getLLVMFieldNo(Field);
77517758
RecordLayout[FieldIndex] = Field;
77527759
}

clang/lib/CodeGen/CodeGenTBAA.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
#include "CodeGenTBAA.h"
18+
#include "ABIInfoImpl.h"
1819
#include "CGRecordLayout.h"
1920
#include "CodeGenTypes.h"
2021
#include "clang/AST/ASTContext.h"
@@ -309,7 +310,7 @@ CodeGenTBAA::CollectFields(uint64_t BaseOffset,
309310
unsigned idx = 0;
310311
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
311312
i != e; ++i, ++idx) {
312-
if ((*i)->isZeroSize(Context))
313+
if (isEmptyFieldForLayout(Context, *i))
313314
continue;
314315

315316
uint64_t Offset =

0 commit comments

Comments
 (0)