Skip to content

Commit 37be748

Browse files
committed
Revert "[clang][ObjC] Add fix it for missing methods in impl"
This reverts commit dd72ae3. Notified the author of the internal failure and author suggested to revert it for now.
1 parent c948922 commit 37be748

File tree

2 files changed

+26
-43
lines changed

2 files changed

+26
-43
lines changed

clang/lib/Sema/SemaDeclObjC.cpp

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,8 +2212,9 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
22122212
Diag(IVI->getLocation(), diag::err_inconsistent_ivar_count);
22132213
}
22142214

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,
22172218
unsigned DiagID,
22182219
NamedDecl *NeededFor = nullptr) {
22192220
// No point warning no definition of method which is 'unavailable'.
@@ -2226,19 +2227,10 @@ static void WarnUndefinedMethod(Sema &S, ObjCImplDecl *Impl,
22262227
// separate warnings. We will give that approach a try, as that
22272228
// matches what we do with protocols.
22282229
{
2229-
const Sema::SemaDiagnosticBuilder &B = S.Diag(Impl->getLocation(), DiagID);
2230+
const Sema::SemaDiagnosticBuilder &B = S.Diag(ImpLoc, DiagID);
22302231
B << method;
22312232
if (NeededFor)
22322233
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);
22422234
}
22432235

22442236
// Issue a note to the original declaration.
@@ -2687,10 +2679,14 @@ static void findProtocolsWithExplicitImpls(const ObjCInterfaceDecl *Super,
26872679

26882680
/// CheckProtocolMethodDefs - This routine checks unimplemented methods
26892681
/// 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) {
26942690
ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(CDecl);
26952691
ObjCInterfaceDecl *IDecl = C ? C->getClassInterface()
26962692
: dyn_cast<ObjCInterfaceDecl>(CDecl);
@@ -2777,8 +2773,9 @@ static void CheckProtocolMethodDefs(
27772773
if (C || MethodInClass->isPropertyAccessor())
27782774
continue;
27792775
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);
27822779
}
27832780
}
27842781
}
@@ -2799,15 +2796,15 @@ static void CheckProtocolMethodDefs(
27992796
continue;
28002797

28012798
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);
28042801
}
28052802
}
28062803
}
28072804
// Check on this protocols's referenced protocols, recursively.
28082805
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);
28112808
}
28122809

28132810
/// MatchAllMethodDeclarations - Check methods declared in interface
@@ -2830,7 +2827,7 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap,
28302827
if (!I->isPropertyAccessor() &&
28312828
!InsMap.count(I->getSelector())) {
28322829
if (ImmediateClass)
2833-
WarnUndefinedMethod(*this, IMPDecl, I, IncompleteImpl,
2830+
WarnUndefinedMethod(*this, IMPDecl->getLocation(), I, IncompleteImpl,
28342831
diag::warn_undef_method_impl);
28352832
continue;
28362833
} else {
@@ -2860,7 +2857,7 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap,
28602857
if (!I->isPropertyAccessor() &&
28612858
!ClsMap.count(I->getSelector())) {
28622859
if (ImmediateClass)
2863-
WarnUndefinedMethod(*this, IMPDecl, I, IncompleteImpl,
2860+
WarnUndefinedMethod(*this, IMPDecl->getLocation(), I, IncompleteImpl,
28642861
diag::warn_undef_method_impl);
28652862
} else {
28662863
ObjCMethodDecl *ImpMethodDecl =
@@ -3027,15 +3024,16 @@ void Sema::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl,
30273024

30283025
if (ObjCInterfaceDecl *I = dyn_cast<ObjCInterfaceDecl> (CDecl)) {
30293026
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);
30323029
} else if (ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(CDecl)) {
30333030
// For extended class, unimplemented methods in its protocols will
30343031
// be reported in the primary class.
30353032
if (!C->IsClassExtension()) {
30363033
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);
30393037
DiagnoseUnimplementedProperties(S, IMPDecl, CDecl,
30403038
/*SynthesizeProperties=*/false);
30413039
}

clang/test/FixIt/fixit-objc-missing-method-impl.m

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)