summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTWriterDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-08-28 00:28:14 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-08-28 00:28:14 +0000
commit6b8e3c02ca44fb6c3738bb0c75859c11a03e30ed (patch)
tree1f1343ce573a06b3b9a68352ac93b54bc3b270e5 /clang/lib/Serialization/ASTWriterDecl.cpp
parentbebcbfb46dc7c89d32eb11254123211f87087dca (diff)
downloadbcm5719-llvm-6b8e3c02ca44fb6c3738bb0c75859c11a03e30ed.tar.gz
bcm5719-llvm-6b8e3c02ca44fb6c3738bb0c75859c11a03e30ed.zip
[c++2a] P0683R1: Permit default member initializers for bit-fields.
This would be trivial, except that our in-memory and serialized representations for FieldDecls assumed that this can't happen. llvm-svn: 311867
Diffstat (limited to 'clang/lib/Serialization/ASTWriterDecl.cpp')
-rw-r--r--clang/lib/Serialization/ASTWriterDecl.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp
index ec21ca2276c..c13c528d23a 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -849,17 +849,16 @@ void ASTDeclWriter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) {
void ASTDeclWriter::VisitFieldDecl(FieldDecl *D) {
VisitDeclaratorDecl(D);
Record.push_back(D->isMutable());
- if (D->InitStorage.getInt() == FieldDecl::ISK_BitWidthOrNothing &&
- D->InitStorage.getPointer() == nullptr) {
- Record.push_back(0);
- } else if (D->InitStorage.getInt() == FieldDecl::ISK_CapturedVLAType) {
- Record.push_back(D->InitStorage.getInt() + 1);
- Record.AddTypeRef(
- QualType(static_cast<Type *>(D->InitStorage.getPointer()), 0));
- } else {
- Record.push_back(D->InitStorage.getInt() + 1);
- Record.AddStmt(static_cast<Expr *>(D->InitStorage.getPointer()));
- }
+
+ FieldDecl::InitStorageKind ISK = D->InitStorage.getInt();
+ Record.push_back(ISK);
+ if (ISK == FieldDecl::ISK_CapturedVLAType)
+ Record.AddTypeRef(QualType(D->getCapturedVLAType(), 0));
+ else if (ISK)
+ Record.AddStmt(D->getInClassInitializer());
+
+ Record.AddStmt(D->getBitWidth());
+
if (!D->getDeclName())
Record.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D));
@@ -873,6 +872,7 @@ void ASTDeclWriter::VisitFieldDecl(FieldDecl *D) {
!D->isModulePrivate() &&
!D->getBitWidth() &&
!D->hasInClassInitializer() &&
+ !D->hasCapturedVLAType() &&
!D->hasExtInfo() &&
!ObjCIvarDecl::classofKind(D->getKind()) &&
!ObjCAtDefsFieldDecl::classofKind(D->getKind()) &&
@@ -1741,7 +1741,7 @@ void ASTWriter::WriteDeclAbbrevs() {
Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
// FieldDecl
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
- Abv->Add(BitCodeAbbrevOp(0)); //getBitWidth
+ Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
// Type Source Info
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
@@ -1774,7 +1774,7 @@ void ASTWriter::WriteDeclAbbrevs() {
Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
// FieldDecl
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
- Abv->Add(BitCodeAbbrevOp(0)); //getBitWidth
+ Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
// ObjC Ivar
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize
OpenPOWER on IntegriCloud