This fix (thanks to Doug Gregor) corrects a bug

in ImportDefinition when replacing a previously
forward-declared CXXRecordDecl with its full
definition.  The forward-declared type's
DefinitionData had not been intialized for the
forward-declared type, so adding fields to the
Decl caused CXXRecordDecl::addedMember() to
crash when accessing the DefinitionData.

llvm-svn: 135530
This commit is contained in:
Sean Callanan 2011-07-19 22:38:25 +00:00
parent 2dee16e883
commit 53a6bff7e1
1 changed files with 12 additions and 3 deletions

View File

@ -86,7 +86,7 @@ namespace {
void ImportDeclarationNameLoc(const DeclarationNameInfo &From,
DeclarationNameInfo& To);
void ImportDeclContext(DeclContext *FromDC, bool ForceImport = false);
bool ImportDefinition(RecordDecl *From, RecordDecl *To);
bool ImportDefinition(RecordDecl *From, RecordDecl *To, bool ForceImport = false);
TemplateParameterList *ImportTemplateParameterList(
TemplateParameterList *Params);
TemplateArgument ImportTemplateArgument(const TemplateArgument &From);
@ -1781,7 +1781,7 @@ void ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, bool ForceImport) {
Importer.Import(*From);
}
bool ASTNodeImporter::ImportDefinition(RecordDecl *From, RecordDecl *To) {
bool ASTNodeImporter::ImportDefinition(RecordDecl *From, RecordDecl *To, bool ForceImport) {
if (To->getDefinition())
return false;
@ -1818,7 +1818,7 @@ bool ASTNodeImporter::ImportDefinition(RecordDecl *From, RecordDecl *To) {
ToCXX->setBases(Bases.data(), Bases.size());
}
ImportDeclContext(From);
ImportDeclContext(From, ForceImport);
To->completeDefinition();
return false;
}
@ -4306,6 +4306,15 @@ void ASTImporter::ImportDefinition(Decl *From) {
if (DeclContext *FromDC = cast<DeclContext>(From)) {
ASTNodeImporter Importer(*this);
if (RecordDecl *ToRecord = dyn_cast<RecordDecl>(To)) {
if (!ToRecord->getDefinition()) {
Importer.ImportDefinition(cast<RecordDecl>(FromDC), ToRecord,
/*ForceImport=*/true);
return;
}
}
Importer.ImportDeclContext(FromDC, true);
}
}