@@ -2212,8 +2212,9 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
2212
2212
Diag (IVI->getLocation (), diag::err_inconsistent_ivar_count);
2213
2213
}
2214
2214
2215
- static void WarnUndefinedMethod (Sema &S, ObjCImplDecl *Impl,
2216
- ObjCMethodDecl *method, bool &IncompleteImpl,
2215
+ static void WarnUndefinedMethod (Sema &S, SourceLocation ImpLoc,
2216
+ ObjCMethodDecl *method,
2217
+ bool &IncompleteImpl,
2217
2218
unsigned DiagID,
2218
2219
NamedDecl *NeededFor = nullptr ) {
2219
2220
// No point warning no definition of method which is 'unavailable'.
@@ -2226,19 +2227,10 @@ static void WarnUndefinedMethod(Sema &S, ObjCImplDecl *Impl,
2226
2227
// separate warnings. We will give that approach a try, as that
2227
2228
// matches what we do with protocols.
2228
2229
{
2229
- const Sema::SemaDiagnosticBuilder &B = S.Diag (Impl-> getLocation () , DiagID);
2230
+ const Sema::SemaDiagnosticBuilder &B = S.Diag (ImpLoc , DiagID);
2230
2231
B << method;
2231
2232
if (NeededFor)
2232
2233
B << NeededFor;
2233
-
2234
- // Add an empty definition at the end of the @implementation.
2235
- std::string FixItStr;
2236
- llvm::raw_string_ostream Out (FixItStr);
2237
- method->print (Out, Impl->getASTContext ().getPrintingPolicy ());
2238
- Out << " {\n }\n\n " ;
2239
-
2240
- SourceLocation Loc = Impl->getAtEndRange ().getBegin ();
2241
- B << FixItHint::CreateInsertion (Loc, FixItStr);
2242
2234
}
2243
2235
2244
2236
// Issue a note to the original declaration.
@@ -2687,10 +2679,14 @@ static void findProtocolsWithExplicitImpls(const ObjCInterfaceDecl *Super,
2687
2679
2688
2680
// / CheckProtocolMethodDefs - This routine checks unimplemented methods
2689
2681
// / Declared in protocol, and those referenced by it.
2690
- static void CheckProtocolMethodDefs (
2691
- Sema &S, ObjCImplDecl *Impl, ObjCProtocolDecl *PDecl, bool &IncompleteImpl,
2692
- const Sema::SelectorSet &InsMap, const Sema::SelectorSet &ClsMap,
2693
- ObjCContainerDecl *CDecl, LazyProtocolNameSet &ProtocolsExplictImpl) {
2682
+ static void CheckProtocolMethodDefs (Sema &S,
2683
+ SourceLocation ImpLoc,
2684
+ ObjCProtocolDecl *PDecl,
2685
+ bool & IncompleteImpl,
2686
+ const Sema::SelectorSet &InsMap,
2687
+ const Sema::SelectorSet &ClsMap,
2688
+ ObjCContainerDecl *CDecl,
2689
+ LazyProtocolNameSet &ProtocolsExplictImpl) {
2694
2690
ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(CDecl);
2695
2691
ObjCInterfaceDecl *IDecl = C ? C->getClassInterface ()
2696
2692
: dyn_cast<ObjCInterfaceDecl>(CDecl);
@@ -2777,8 +2773,9 @@ static void CheckProtocolMethodDefs(
2777
2773
if (C || MethodInClass->isPropertyAccessor ())
2778
2774
continue ;
2779
2775
unsigned DIAG = diag::warn_unimplemented_protocol_method;
2780
- if (!S.Diags .isIgnored (DIAG, Impl->getLocation ())) {
2781
- WarnUndefinedMethod (S, Impl, method, IncompleteImpl, DIAG, PDecl);
2776
+ if (!S.Diags .isIgnored (DIAG, ImpLoc)) {
2777
+ WarnUndefinedMethod (S, ImpLoc, method, IncompleteImpl, DIAG,
2778
+ PDecl);
2782
2779
}
2783
2780
}
2784
2781
}
@@ -2799,15 +2796,15 @@ static void CheckProtocolMethodDefs(
2799
2796
continue ;
2800
2797
2801
2798
unsigned DIAG = diag::warn_unimplemented_protocol_method;
2802
- if (!S.Diags .isIgnored (DIAG, Impl-> getLocation () )) {
2803
- WarnUndefinedMethod (S, Impl , method, IncompleteImpl, DIAG, PDecl);
2799
+ if (!S.Diags .isIgnored (DIAG, ImpLoc )) {
2800
+ WarnUndefinedMethod (S, ImpLoc , method, IncompleteImpl, DIAG, PDecl);
2804
2801
}
2805
2802
}
2806
2803
}
2807
2804
// Check on this protocols's referenced protocols, recursively.
2808
2805
for (auto *PI : PDecl->protocols ())
2809
- CheckProtocolMethodDefs (S, Impl , PI, IncompleteImpl, InsMap, ClsMap, CDecl ,
2810
- ProtocolsExplictImpl);
2806
+ CheckProtocolMethodDefs (S, ImpLoc , PI, IncompleteImpl, InsMap, ClsMap,
2807
+ CDecl, ProtocolsExplictImpl);
2811
2808
}
2812
2809
2813
2810
// / MatchAllMethodDeclarations - Check methods declared in interface
@@ -2830,7 +2827,7 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap,
2830
2827
if (!I->isPropertyAccessor () &&
2831
2828
!InsMap.count (I->getSelector ())) {
2832
2829
if (ImmediateClass)
2833
- WarnUndefinedMethod (*this , IMPDecl, I, IncompleteImpl,
2830
+ WarnUndefinedMethod (*this , IMPDecl-> getLocation () , I, IncompleteImpl,
2834
2831
diag::warn_undef_method_impl);
2835
2832
continue ;
2836
2833
} else {
@@ -2860,7 +2857,7 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap,
2860
2857
if (!I->isPropertyAccessor () &&
2861
2858
!ClsMap.count (I->getSelector ())) {
2862
2859
if (ImmediateClass)
2863
- WarnUndefinedMethod (*this , IMPDecl, I, IncompleteImpl,
2860
+ WarnUndefinedMethod (*this , IMPDecl-> getLocation () , I, IncompleteImpl,
2864
2861
diag::warn_undef_method_impl);
2865
2862
} else {
2866
2863
ObjCMethodDecl *ImpMethodDecl =
@@ -3027,15 +3024,16 @@ void Sema::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl,
3027
3024
3028
3025
if (ObjCInterfaceDecl *I = dyn_cast<ObjCInterfaceDecl> (CDecl)) {
3029
3026
for (auto *PI : I->all_referenced_protocols ())
3030
- CheckProtocolMethodDefs (*this , IMPDecl, PI, IncompleteImpl, InsMap ,
3031
- ClsMap, I, ExplicitImplProtocols);
3027
+ CheckProtocolMethodDefs (*this , IMPDecl-> getLocation () , PI, IncompleteImpl,
3028
+ InsMap, ClsMap, I, ExplicitImplProtocols);
3032
3029
} else if (ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(CDecl)) {
3033
3030
// For extended class, unimplemented methods in its protocols will
3034
3031
// be reported in the primary class.
3035
3032
if (!C->IsClassExtension ()) {
3036
3033
for (auto *P : C->protocols ())
3037
- CheckProtocolMethodDefs (*this , IMPDecl, P, IncompleteImpl, InsMap,
3038
- ClsMap, CDecl, ExplicitImplProtocols);
3034
+ CheckProtocolMethodDefs (*this , IMPDecl->getLocation (), P,
3035
+ IncompleteImpl, InsMap, ClsMap, CDecl,
3036
+ ExplicitImplProtocols);
3039
3037
DiagnoseUnimplementedProperties (S, IMPDecl, CDecl,
3040
3038
/* SynthesizeProperties=*/ false );
3041
3039
}
0 commit comments