summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2011-07-19 22:38:25 +0000
committerSean Callanan <scallanan@apple.com>2011-07-19 22:38:25 +0000
commit53a6bff7e1bebc1eb9e9160fa37ad13b976ef401 (patch)
tree7c4751bbea686c9f2dcaed3b7d1e222d8e1eaadb
parent2dee16e8836be894a414693321aebff6e5929e20 (diff)
downloadbcm5719-llvm-53a6bff7e1bebc1eb9e9160fa37ad13b976ef401.tar.gz
bcm5719-llvm-53a6bff7e1bebc1eb9e9160fa37ad13b976ef401.zip
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
-rw-r--r--clang/lib/AST/ASTImporter.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index f5e392f88d0..e8e4c6a1082 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -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);
}
}
OpenPOWER on IntegriCloud