Serialize the NonTrivialToPrimitive* flags I added in r326307.

rdar://problem/38421774

llvm-svn: 327434
This commit is contained in:
Akira Hatanaka 2018-03-13 18:58:25 +00:00
parent aee0af3e23
commit 34fb26456b
5 changed files with 36 additions and 10 deletions

View File

@ -3616,24 +3616,24 @@ public:
return NonTrivialToPrimitiveDefaultInitialize;
}
void setNonTrivialToPrimitiveDefaultInitialize() {
NonTrivialToPrimitiveDefaultInitialize = true;
void setNonTrivialToPrimitiveDefaultInitialize(bool V) {
NonTrivialToPrimitiveDefaultInitialize = V;
}
bool isNonTrivialToPrimitiveCopy() const {
return NonTrivialToPrimitiveCopy;
}
void setNonTrivialToPrimitiveCopy() {
NonTrivialToPrimitiveCopy = true;
void setNonTrivialToPrimitiveCopy(bool V) {
NonTrivialToPrimitiveCopy = V;
}
bool isNonTrivialToPrimitiveDestroy() const {
return NonTrivialToPrimitiveDestroy;
}
void setNonTrivialToPrimitiveDestroy() {
NonTrivialToPrimitiveDestroy = true;
void setNonTrivialToPrimitiveDestroy(bool V) {
NonTrivialToPrimitiveDestroy = V;
}
/// \brief Determines whether this declaration represents the

View File

@ -15445,12 +15445,12 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl,
if (Record && !getLangOpts().CPlusPlus) {
QualType FT = FD->getType();
if (FT.isNonTrivialToPrimitiveDefaultInitialize())
Record->setNonTrivialToPrimitiveDefaultInitialize();
Record->setNonTrivialToPrimitiveDefaultInitialize(true);
QualType::PrimitiveCopyKind PCK = FT.isNonTrivialToPrimitiveCopy();
if (PCK != QualType::PCK_Trivial && PCK != QualType::PCK_VolatileTrivial)
Record->setNonTrivialToPrimitiveCopy();
Record->setNonTrivialToPrimitiveCopy(true);
if (FT.isDestructedType())
Record->setNonTrivialToPrimitiveDestroy();
Record->setNonTrivialToPrimitiveDestroy(true);
}
if (Record && FD->getType().isVolatileQualified())

View File

@ -739,6 +739,9 @@ ASTDeclReader::VisitRecordDeclImpl(RecordDecl *RD) {
RD->setAnonymousStructOrUnion(Record.readInt());
RD->setHasObjectMember(Record.readInt());
RD->setHasVolatileMember(Record.readInt());
RD->setNonTrivialToPrimitiveDefaultInitialize(Record.readInt());
RD->setNonTrivialToPrimitiveCopy(Record.readInt());
RD->setNonTrivialToPrimitiveDestroy(Record.readInt());
return Redecl;
}

View File

@ -465,6 +465,9 @@ void ASTDeclWriter::VisitRecordDecl(RecordDecl *D) {
Record.push_back(D->isAnonymousStructOrUnion());
Record.push_back(D->hasObjectMember());
Record.push_back(D->hasVolatileMember());
Record.push_back(D->isNonTrivialToPrimitiveDefaultInitialize());
Record.push_back(D->isNonTrivialToPrimitiveCopy());
Record.push_back(D->isNonTrivialToPrimitiveDestroy());
if (D->getDeclContext() == D->getLexicalDeclContext() &&
!D->hasAttrs() &&
@ -1899,6 +1902,14 @@ void ASTWriter::WriteDeclAbbrevs() {
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // AnonymousStructUnion
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasObjectMember
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasVolatileMember
// isNonTrivialToPrimitiveDefaultInitialize
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
// isNonTrivialToPrimitiveCopy
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
// isNonTrivialToPrimitiveDestroy
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
// DC
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset

View File

@ -1,4 +1,10 @@
// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -emit-llvm -o - -DUSESTRUCT %s | FileCheck %s
// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -emit-pch -o %t %s
// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -include-pch %t -emit-llvm -o - -DUSESTRUCT %s | FileCheck %s
#ifndef HEADER
#define HEADER
typedef void (^BlockTy)(void);
@ -63,6 +69,10 @@ typedef struct {
volatile char i6;
} Bitfield1;
#endif
#ifdef USESTRUCT
StrongSmall getStrongSmall(void);
StrongOuter getStrongOuter(void);
void calleeStrongSmall(StrongSmall);
@ -520,3 +530,5 @@ void test_copy_constructor_Bitfield0(Bitfield0 *a) {
void test_copy_constructor_Bitfield1(Bitfield1 *a) {
Bitfield1 t = *a;
}
#endif /* USESTRUCT */