Skip to content

Commit

Permalink
[AST][Serialization][Reflection] (De)serialize/import CXXRecordDecl::…
Browse files Browse the repository at this point in the history
…Metaclass
  • Loading branch information
Jenny-fa committed Apr 19, 2017
1 parent a9940d5 commit 2275d88
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/AST/ASTImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3087,6 +3087,13 @@ Decl *ASTNodeImporter::VisitRecordDecl(RecordDecl *D) {
if (!D2) {
CXXRecordDecl *D2CXX = nullptr;
if (CXXRecordDecl *DCXX = llvm::dyn_cast<CXXRecordDecl>(D)) {
MetaclassDecl *FromMetaclass = DCXX->getMetaclass();
MetaclassDecl *ToMetaclass =
cast_or_null<MetaclassDecl>(Importer.Import(FromMetaclass));
if (!ToMetaclass && FromMetaclass)
return nullptr;
D2CXX->setMetaclass(ToMetaclass);

if (DCXX->isLambda()) {
TypeSourceInfo *TInfo = Importer.Import(DCXX->getLambdaTypeInfo());
D2CXX = CXXRecordDecl::CreateLambda(Importer.getToContext(),
Expand Down
2 changes: 2 additions & 0 deletions lib/Serialization/ASTReaderDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,8 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CXXRecordDecl *D) {
}
}

D->Metaclass = ReadDeclAs<MetaclassDecl>();

bool WasDefinition = Record.readInt();
if (WasDefinition)
ReadCXXRecordDefinition(D, /*Update*/false);
Expand Down
2 changes: 2 additions & 0 deletions lib/Serialization/ASTWriterDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,8 @@ void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
Record.push_back(CXXRecNotTemplate);
}

Record.AddDeclRef(D->getMetaclass());

Record.push_back(D->isThisDeclarationADefinition());
if (D->isThisDeclarationADefinition())
Record.AddCXXDefinitionData(D);
Expand Down

0 comments on commit 2275d88

Please sign in to comment.