@@ -5682,21 +5682,6 @@ findImplsGivenInterface(ClassDecl *classDecl, Identifier categoryName) {
5682
5682
impls.push_back (ext);
5683
5683
}
5684
5684
5685
- if (impls.size () > 1 ) {
5686
- llvm::sort (impls, OrderDecls ());
5687
-
5688
- auto &diags = classDecl->getASTContext ().Diags ;
5689
- for (auto extraImpl : llvm::ArrayRef<Decl *>(impls).drop_front ()) {
5690
- auto attr = extraImpl->getAttrs ().getAttribute <ObjCImplementationAttr>();
5691
- attr->setCategoryNameInvalid ();
5692
-
5693
- diags.diagnose (attr->getLocation (), diag::objc_implementation_two_impls,
5694
- categoryName, classDecl)
5695
- .fixItRemove (attr->getRangeWithAt ());
5696
- diags.diagnose (impls.front (), diag::previous_objc_implementation);
5697
- }
5698
- }
5699
-
5700
5685
return impls;
5701
5686
}
5702
5687
@@ -5727,10 +5712,26 @@ findInterfaceGivenImpl(ClassDecl *classDecl, ExtensionDecl *ext) {
5727
5712
}
5728
5713
5729
5714
static ObjCInterfaceAndImplementation
5730
- constructResult (Decl *interface, llvm::TinyPtrVector<Decl *> impls) {
5731
- if (impls.empty ())
5715
+ constructResult (Decl *interface, llvm::TinyPtrVector<Decl *> &impls,
5716
+ Decl *diagnoseOn, Identifier categoryName) {
5717
+ if (!interface || impls.empty ())
5732
5718
return ObjCInterfaceAndImplementation ();
5733
5719
5720
+ if (impls.size () > 1 ) {
5721
+ llvm::sort (impls, OrderDecls ());
5722
+
5723
+ auto &diags = interface->getASTContext ().Diags ;
5724
+ for (auto extraImpl : llvm::ArrayRef<Decl *>(impls).drop_front ()) {
5725
+ auto attr = extraImpl->getAttrs ().getAttribute <ObjCImplementationAttr>();
5726
+ attr->setCategoryNameInvalid ();
5727
+
5728
+ diags.diagnose (attr->getLocation (), diag::objc_implementation_two_impls,
5729
+ categoryName, diagnoseOn)
5730
+ .fixItRemove (attr->getRangeWithAt ());
5731
+ diags.diagnose (impls.front (), diag::previous_objc_implementation);
5732
+ }
5733
+ }
5734
+
5734
5735
return ObjCInterfaceAndImplementation (interface, impls.front ());
5735
5736
}
5736
5737
@@ -5779,7 +5780,7 @@ findContextInterfaceAndImplementation(DeclContext *dc) {
5779
5780
// look for extensions implementing it.
5780
5781
5781
5782
auto implDecls = findImplsGivenInterface (classDecl, categoryName);
5782
- return constructResult (interfaceDecl, implDecls);
5783
+ return constructResult (interfaceDecl, implDecls, classDecl, categoryName );
5783
5784
}
5784
5785
5785
5786
ObjCInterfaceAndImplementation ObjCInterfaceAndImplementationRequest::
0 commit comments