From 47dbaf6c8e7108631a6c296c6915cd9fca12eacd Mon Sep 17 00:00:00 2001 From: Aleksei Sidorin Date: Tue, 9 Jan 2018 14:25:05 +0000 Subject: [PATCH] [ASTImporter] Fix missing SourceLoc import for ObjCMethodDecl selectors Patch by Nico Rieck, test case by Sean Callanan! Differential Revision: https://reviews.llvm.org/D6550 llvm-svn: 322079 --- clang/lib/AST/ASTImporter.cpp | 6 +++++- clang/test/ASTMerge/interface/Inputs/interface1.m | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) 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