Index: lib/AST/ASTImporter.cpp =================================================================== --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -8382,45 +8382,48 @@ } Error ASTImporter::ImportDefinition_New(Decl *From) { - Decl *To = Import(From); - if (!To) - return llvm::make_error(); + Decl *To; + if (Error Err = importInto(To, From)) + return Err; - auto *FromDC = cast(From); - ASTNodeImporter Importer(*this); + if (auto *FromDC = cast(From)) { + ASTNodeImporter Importer(*this); - if (auto *ToRecord = dyn_cast(To)) { - if (!ToRecord->getDefinition()) { - return Importer.ImportDefinition( - cast(FromDC), ToRecord, - ASTNodeImporter::IDK_Everything); + if (auto *ToRecord = dyn_cast(To)) { + if (!ToRecord->getDefinition()) { + return Importer.ImportDefinition( + cast(FromDC), ToRecord, + ASTNodeImporter::IDK_Everything); + } } - } - if (auto *ToEnum = dyn_cast(To)) { - if (!ToEnum->getDefinition()) { - return Importer.ImportDefinition( - cast(FromDC), ToEnum, ASTNodeImporter::IDK_Everything); + if (auto *ToEnum = dyn_cast(To)) { + if (!ToEnum->getDefinition()) { + return Importer.ImportDefinition( + cast(FromDC), ToEnum, ASTNodeImporter::IDK_Everything); + } } - } - if (auto *ToIFace = dyn_cast(To)) { - if (!ToIFace->getDefinition()) { - return Importer.ImportDefinition( - cast(FromDC), ToIFace, - ASTNodeImporter::IDK_Everything); + if (auto *ToIFace = dyn_cast(To)) { + if (!ToIFace->getDefinition()) { + return Importer.ImportDefinition( + cast(FromDC), ToIFace, + ASTNodeImporter::IDK_Everything); + } } - } - if (auto *ToProto = dyn_cast(To)) { - if (!ToProto->getDefinition()) { - return Importer.ImportDefinition( - cast(FromDC), ToProto, - ASTNodeImporter::IDK_Everything); + if (auto *ToProto = dyn_cast(To)) { + if (!ToProto->getDefinition()) { + return Importer.ImportDefinition( + cast(FromDC), ToProto, + ASTNodeImporter::IDK_Everything); + } } + + return Importer.ImportDeclContext(FromDC, true); } - return Importer.ImportDeclContext(FromDC, true); + return Error::success(); } void ASTImporter::ImportDefinition(Decl *From) {