@@ -5827,21 +5827,6 @@ findImplsGivenInterface(ClassDecl *classDecl, Identifier categoryName) {
5827
5827
impls.push_back (ext);
5828
5828
}
5829
5829
5830
- if (impls.size () > 1 ) {
5831
- llvm::sort (impls, OrderDecls ());
5832
-
5833
- auto &diags = classDecl->getASTContext ().Diags ;
5834
- for (auto extraImpl : llvm::ArrayRef<Decl *>(impls).drop_front ()) {
5835
- auto attr = extraImpl->getAttrs ().getAttribute <ObjCImplementationAttr>();
5836
- attr->setCategoryNameInvalid ();
5837
-
5838
- diags.diagnose (attr->getLocation (), diag::objc_implementation_two_impls,
5839
- categoryName, classDecl)
5840
- .fixItRemove (attr->getRangeWithAt ());
5841
- diags.diagnose (impls.front (), diag::previous_objc_implementation);
5842
- }
5843
- }
5844
-
5845
5830
return impls;
5846
5831
}
5847
5832
@@ -5872,10 +5857,26 @@ findInterfaceGivenImpl(ClassDecl *classDecl, ExtensionDecl *ext) {
5872
5857
}
5873
5858
5874
5859
static ObjCInterfaceAndImplementation
5875
- constructResult (Decl *interface, llvm::TinyPtrVector<Decl *> impls) {
5876
- if (impls.empty ())
5860
+ constructResult (Decl *interface, llvm::TinyPtrVector<Decl *> &impls,
5861
+ Decl *diagnoseOn, Identifier categoryName) {
5862
+ if (!interface || impls.empty ())
5877
5863
return ObjCInterfaceAndImplementation ();
5878
5864
5865
+ if (impls.size () > 1 ) {
5866
+ llvm::sort (impls, OrderDecls ());
5867
+
5868
+ auto &diags = interface->getASTContext ().Diags ;
5869
+ for (auto extraImpl : llvm::ArrayRef<Decl *>(impls).drop_front ()) {
5870
+ auto attr = extraImpl->getAttrs ().getAttribute <ObjCImplementationAttr>();
5871
+ attr->setCategoryNameInvalid ();
5872
+
5873
+ diags.diagnose (attr->getLocation (), diag::objc_implementation_two_impls,
5874
+ categoryName, diagnoseOn)
5875
+ .fixItRemove (attr->getRangeWithAt ());
5876
+ diags.diagnose (impls.front (), diag::previous_objc_implementation);
5877
+ }
5878
+ }
5879
+
5879
5880
return ObjCInterfaceAndImplementation (interface, impls.front ());
5880
5881
}
5881
5882
@@ -5924,7 +5925,7 @@ findContextInterfaceAndImplementation(DeclContext *dc) {
5924
5925
// look for extensions implementing it.
5925
5926
5926
5927
auto implDecls = findImplsGivenInterface (classDecl, categoryName);
5927
- return constructResult (interfaceDecl, implDecls);
5928
+ return constructResult (interfaceDecl, implDecls, classDecl, categoryName );
5928
5929
}
5929
5930
5930
5931
ObjCInterfaceAndImplementation ObjCInterfaceAndImplementationRequest::
0 commit comments