martong added a comment. @a_sidorin
The below diff on top of your patch successfully handles the failure with the `TestCModules.py` LLDB testcase: diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 05fec7f943..e6fb590025 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -1695,15 +1695,22 @@ ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, bool ForceImport) { // LoadFieldsFromExternalStorage(). auto ImportedDC = import(cast<Decl>(FromDC)); assert(ImportedDC); - auto *ToRD = cast<RecordDecl>(*ImportedDC); + RecordDecl *ToRD = nullptr; for (auto *D : FromRD->decls()) { if (isa<FieldDecl>(D) || isa<FriendDecl>(D)) { Decl *ToD = Importer.GetAlreadyImportedOrNull(D); - assert(ToRD == ToD->getDeclContext() && ToRD->containsDecl(ToD)); - ToRD->removeDecl(ToD); + if (!ToRD) + ToRD = cast<RecordDecl>(ToD->getDeclContext()); + else + assert(ToRD == ToD->getDeclContext()); + if(ToRD->containsDecl(ToD)) + ToRD->removeDecl(ToD); } } + if (!ToRD) + return Error::success(); + if (!ToRD->hasExternalLexicalStorage()) assert(ToRD->field_empty()); Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D44100/new/ https://reviews.llvm.org/D44100 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits