Skip to content

Commit 18d373c

Browse files
committed
fixup! adjust other parts of CodeGen to use isEmptyFieldForLayout/isEmptyRecordForLayout
1 parent 4e8a846 commit 18d373c

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"
@@ -7728,23 +7729,28 @@ class MappableExprsHandler {
77287729
for (const auto &I : RD->bases()) {
77297730
if (I.isVirtual())
77307731
continue;
7731-
const auto *Base = I.getType()->getAsCXXRecordDecl();
7732+
7733+
QualType BaseTy = I.getType();
7734+
const auto *Base = BaseTy->getAsCXXRecordDecl();
77327735
// Ignore empty bases.
7733-
if (Base->isEmpty() || CGF.getContext()
7734-
.getASTRecordLayout(Base)
7735-
.getNonVirtualSize()
7736-
.isZero())
7736+
if (isEmptyRecordForLayout(CGF.getContext(), BaseTy) ||
7737+
CGF.getContext()
7738+
.getASTRecordLayout(Base)
7739+
.getNonVirtualSize()
7740+
.isZero())
77377741
continue;
77387742

77397743
unsigned FieldIndex = RL.getNonVirtualBaseLLVMFieldNo(Base);
77407744
RecordLayout[FieldIndex] = Base;
77417745
}
77427746
// Fill in virtual bases.
77437747
for (const auto &I : RD->vbases()) {
7744-
const auto *Base = I.getType()->getAsCXXRecordDecl();
7748+
QualType BaseTy = I.getType();
77457749
// Ignore empty bases.
7746-
if (Base->isEmpty())
7750+
if (isEmptyRecordForLayout(CGF.getContext(), BaseTy))
77477751
continue;
7752+
7753+
const auto *Base = BaseTy->getAsCXXRecordDecl();
77487754
unsigned FieldIndex = RL.getVirtualBaseIndex(Base);
77497755
if (RecordLayout[FieldIndex])
77507756
continue;
@@ -7755,7 +7761,8 @@ class MappableExprsHandler {
77557761
for (const auto *Field : RD->fields()) {
77567762
// Fill in non-bitfields. (Bitfields always use a zero pattern, which we
77577763
// will fill in later.)
7758-
if (!Field->isBitField() && !Field->isZeroSize(CGF.getContext())) {
7764+
if (!Field->isBitField() &&
7765+
!isEmptyFieldForLayout(CGF.getContext(), Field)) {
77597766
unsigned FieldIndex = RL.getLLVMFieldNo(Field);
77607767
RecordLayout[FieldIndex] = Field;
77617768
}

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)