Index: clang/lib/AST/ASTImporter.cpp =================================================================== --- clang/lib/AST/ASTImporter.cpp +++ clang/lib/AST/ASTImporter.cpp @@ -467,18 +467,8 @@ template bool hasSameVisibilityContextAndLinkage(T *Found, T *From); - bool IsStructuralMatch(Decl *From, Decl *To, bool Complain); - bool IsStructuralMatch(RecordDecl *FromRecord, RecordDecl *ToRecord, - bool Complain = true); - bool IsStructuralMatch(VarDecl *FromVar, VarDecl *ToVar, - bool Complain = true); - bool IsStructuralMatch(EnumDecl *FromEnum, EnumDecl *ToRecord); + bool IsStructuralMatch(Decl *From, Decl *To, bool Complain = true); bool IsStructuralMatch(EnumConstantDecl *FromEC, EnumConstantDecl *ToEC); - bool IsStructuralMatch(FunctionTemplateDecl *From, - FunctionTemplateDecl *To); - bool IsStructuralMatch(FunctionDecl *From, FunctionDecl *To); - bool IsStructuralMatch(ClassTemplateDecl *From, ClassTemplateDecl *To); - bool IsStructuralMatch(VarTemplateDecl *From, VarTemplateDecl *To); ExpectedDecl VisitDecl(Decl *D); ExpectedDecl VisitImportDecl(ImportDecl *D); ExpectedDecl VisitEmptyDecl(EmptyDecl *D); @@ -2178,68 +2168,17 @@ } bool ASTNodeImporter::IsStructuralMatch(Decl *From, Decl *To, bool Complain) { - StructuralEquivalenceContext Ctx( - Importer.getFromContext(), Importer.getToContext(), - Importer.getNonEquivalentDecls(), getStructuralEquivalenceKind(Importer), - false, Complain); - return Ctx.IsEquivalent(From, To); -} - -bool ASTNodeImporter::IsStructuralMatch(RecordDecl *FromRecord, - RecordDecl *ToRecord, bool Complain) { // Eliminate a potential failure point where we attempt to re-import // something we're trying to import while completing ToRecord. - Decl *ToOrigin = Importer.GetOriginalDecl(ToRecord); + Decl *ToOrigin = Importer.GetOriginalDecl(To); if (ToOrigin) { - auto *ToOriginRecord = dyn_cast(ToOrigin); - if (ToOriginRecord) - ToRecord = ToOriginRecord; + To = ToOrigin; } - StructuralEquivalenceContext Ctx(Importer.getFromContext(), - ToRecord->getASTContext(), - Importer.getNonEquivalentDecls(), - getStructuralEquivalenceKind(Importer), - false, Complain); - return Ctx.IsEquivalent(FromRecord, ToRecord); -} - -bool ASTNodeImporter::IsStructuralMatch(VarDecl *FromVar, VarDecl *ToVar, - bool Complain) { StructuralEquivalenceContext Ctx( Importer.getFromContext(), Importer.getToContext(), Importer.getNonEquivalentDecls(), getStructuralEquivalenceKind(Importer), false, Complain); - return Ctx.IsEquivalent(FromVar, ToVar); -} - -bool ASTNodeImporter::IsStructuralMatch(EnumDecl *FromEnum, EnumDecl *ToEnum) { - // Eliminate a potential failure point where we attempt to re-import - // something we're trying to import while completing ToEnum. - if (Decl *ToOrigin = Importer.GetOriginalDecl(ToEnum)) - if (auto *ToOriginEnum = dyn_cast(ToOrigin)) - ToEnum = ToOriginEnum; - - StructuralEquivalenceContext Ctx( - Importer.getFromContext(), Importer.getToContext(), - Importer.getNonEquivalentDecls(), getStructuralEquivalenceKind(Importer)); - return Ctx.IsEquivalent(FromEnum, ToEnum); -} - -bool ASTNodeImporter::IsStructuralMatch(FunctionTemplateDecl *From, - FunctionTemplateDecl *To) { - StructuralEquivalenceContext Ctx( - Importer.getFromContext(), Importer.getToContext(), - Importer.getNonEquivalentDecls(), getStructuralEquivalenceKind(Importer), - false, false); - return Ctx.IsEquivalent(From, To); -} - -bool ASTNodeImporter::IsStructuralMatch(FunctionDecl *From, FunctionDecl *To) { - StructuralEquivalenceContext Ctx( - Importer.getFromContext(), Importer.getToContext(), - Importer.getNonEquivalentDecls(), getStructuralEquivalenceKind(Importer), - false, false); return Ctx.IsEquivalent(From, To); } @@ -2253,24 +2192,6 @@ FromVal == ToVal; } -bool ASTNodeImporter::IsStructuralMatch(ClassTemplateDecl *From, - ClassTemplateDecl *To) { - StructuralEquivalenceContext Ctx(Importer.getFromContext(), - Importer.getToContext(), - Importer.getNonEquivalentDecls(), - getStructuralEquivalenceKind(Importer)); - return Ctx.IsEquivalent(From, To); -} - -bool ASTNodeImporter::IsStructuralMatch(VarTemplateDecl *From, - VarTemplateDecl *To) { - StructuralEquivalenceContext Ctx(Importer.getFromContext(), - Importer.getToContext(), - Importer.getNonEquivalentDecls(), - getStructuralEquivalenceKind(Importer)); - return Ctx.IsEquivalent(From, To); -} - ExpectedDecl ASTNodeImporter::VisitDecl(Decl *D) { Importer.FromDiag(D->getLocation(), diag::err_unsupported_ast_node) << D->getDeclKindName();