diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index cca43eed3e62..11d31156b8ef 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -2857,9 +2857,13 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) { ToParams[I]->setOwningFunction(ToMethod); ToMethod->addDeclInternal(ToParams[I]); } + SmallVector SelLocs; D->getSelectorLocs(SelLocs); - ToMethod->setMethodParams(Importer.getToContext(), ToParams, SelLocs); + for (SourceLocation &Loc : SelLocs) + Loc = Importer.Import(Loc); + + ToMethod->setMethodParams(Importer.getToContext(), ToParams, SelLocs); ToMethod->setLexicalDeclContext(LexicalDC); Importer.Imported(D, ToMethod); diff --git a/clang/test/ASTMerge/interface/Inputs/interface1.m b/clang/test/ASTMerge/interface/Inputs/interface1.m index 5865c0eff070..6192150089fe 100644 --- a/clang/test/ASTMerge/interface/Inputs/interface1.m +++ b/clang/test/ASTMerge/interface/Inputs/interface1.m @@ -100,4 +100,6 @@ @implementation I15 : I12 @end - +@interface ImportSelectorSLoc { } +-(int)addInt:(int)a toInt:(int)b moduloInt:(int)c; // don't crash here +@end