Skip to content

Commit

Permalink
Revert "[clang][ObjC] Add fix it for missing methods in impl"
Browse files Browse the repository at this point in the history
This reverts commit dd72ae3.

Notified the author of the internal failure and author suggested to revert it for
now.
  • Loading branch information
rdhindsa14 committed Jan 5, 2022
1 parent c948922 commit 37be748
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 43 deletions.
54 changes: 26 additions & 28 deletions clang/lib/Sema/SemaDeclObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2212,8 +2212,9 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
Diag(IVI->getLocation(), diag::err_inconsistent_ivar_count);
}

static void WarnUndefinedMethod(Sema &S, ObjCImplDecl *Impl,
ObjCMethodDecl *method, bool &IncompleteImpl,
static void WarnUndefinedMethod(Sema &S, SourceLocation ImpLoc,
ObjCMethodDecl *method,
bool &IncompleteImpl,
unsigned DiagID,
NamedDecl *NeededFor = nullptr) {
// No point warning no definition of method which is 'unavailable'.
Expand All @@ -2226,19 +2227,10 @@ static void WarnUndefinedMethod(Sema &S, ObjCImplDecl *Impl,
// separate warnings. We will give that approach a try, as that
// matches what we do with protocols.
{
const Sema::SemaDiagnosticBuilder &B = S.Diag(Impl->getLocation(), DiagID);
const Sema::SemaDiagnosticBuilder &B = S.Diag(ImpLoc, DiagID);
B << method;
if (NeededFor)
B << NeededFor;

// Add an empty definition at the end of the @implementation.
std::string FixItStr;
llvm::raw_string_ostream Out(FixItStr);
method->print(Out, Impl->getASTContext().getPrintingPolicy());
Out << " {\n}\n\n";

SourceLocation Loc = Impl->getAtEndRange().getBegin();
B << FixItHint::CreateInsertion(Loc, FixItStr);
}

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

/// CheckProtocolMethodDefs - This routine checks unimplemented methods
/// Declared in protocol, and those referenced by it.
static void CheckProtocolMethodDefs(
Sema &S, ObjCImplDecl *Impl, ObjCProtocolDecl *PDecl, bool &IncompleteImpl,
const Sema::SelectorSet &InsMap, const Sema::SelectorSet &ClsMap,
ObjCContainerDecl *CDecl, LazyProtocolNameSet &ProtocolsExplictImpl) {
static void CheckProtocolMethodDefs(Sema &S,
SourceLocation ImpLoc,
ObjCProtocolDecl *PDecl,
bool& IncompleteImpl,
const Sema::SelectorSet &InsMap,
const Sema::SelectorSet &ClsMap,
ObjCContainerDecl *CDecl,
LazyProtocolNameSet &ProtocolsExplictImpl) {
ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(CDecl);
ObjCInterfaceDecl *IDecl = C ? C->getClassInterface()
: dyn_cast<ObjCInterfaceDecl>(CDecl);
Expand Down Expand Up @@ -2777,8 +2773,9 @@ static void CheckProtocolMethodDefs(
if (C || MethodInClass->isPropertyAccessor())
continue;
unsigned DIAG = diag::warn_unimplemented_protocol_method;
if (!S.Diags.isIgnored(DIAG, Impl->getLocation())) {
WarnUndefinedMethod(S, Impl, method, IncompleteImpl, DIAG, PDecl);
if (!S.Diags.isIgnored(DIAG, ImpLoc)) {
WarnUndefinedMethod(S, ImpLoc, method, IncompleteImpl, DIAG,
PDecl);
}
}
}
Expand All @@ -2799,15 +2796,15 @@ static void CheckProtocolMethodDefs(
continue;

unsigned DIAG = diag::warn_unimplemented_protocol_method;
if (!S.Diags.isIgnored(DIAG, Impl->getLocation())) {
WarnUndefinedMethod(S, Impl, method, IncompleteImpl, DIAG, PDecl);
if (!S.Diags.isIgnored(DIAG, ImpLoc)) {
WarnUndefinedMethod(S, ImpLoc, method, IncompleteImpl, DIAG, PDecl);
}
}
}
// Check on this protocols's referenced protocols, recursively.
for (auto *PI : PDecl->protocols())
CheckProtocolMethodDefs(S, Impl, PI, IncompleteImpl, InsMap, ClsMap, CDecl,
ProtocolsExplictImpl);
CheckProtocolMethodDefs(S, ImpLoc, PI, IncompleteImpl, InsMap, ClsMap,
CDecl, ProtocolsExplictImpl);
}

/// MatchAllMethodDeclarations - Check methods declared in interface
Expand All @@ -2830,7 +2827,7 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap,
if (!I->isPropertyAccessor() &&
!InsMap.count(I->getSelector())) {
if (ImmediateClass)
WarnUndefinedMethod(*this, IMPDecl, I, IncompleteImpl,
WarnUndefinedMethod(*this, IMPDecl->getLocation(), I, IncompleteImpl,
diag::warn_undef_method_impl);
continue;
} else {
Expand Down Expand Up @@ -2860,7 +2857,7 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap,
if (!I->isPropertyAccessor() &&
!ClsMap.count(I->getSelector())) {
if (ImmediateClass)
WarnUndefinedMethod(*this, IMPDecl, I, IncompleteImpl,
WarnUndefinedMethod(*this, IMPDecl->getLocation(), I, IncompleteImpl,
diag::warn_undef_method_impl);
} else {
ObjCMethodDecl *ImpMethodDecl =
Expand Down Expand Up @@ -3027,15 +3024,16 @@ void Sema::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl,

if (ObjCInterfaceDecl *I = dyn_cast<ObjCInterfaceDecl> (CDecl)) {
for (auto *PI : I->all_referenced_protocols())
CheckProtocolMethodDefs(*this, IMPDecl, PI, IncompleteImpl, InsMap,
ClsMap, I, ExplicitImplProtocols);
CheckProtocolMethodDefs(*this, IMPDecl->getLocation(), PI, IncompleteImpl,
InsMap, ClsMap, I, ExplicitImplProtocols);
} else if (ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(CDecl)) {
// For extended class, unimplemented methods in its protocols will
// be reported in the primary class.
if (!C->IsClassExtension()) {
for (auto *P : C->protocols())
CheckProtocolMethodDefs(*this, IMPDecl, P, IncompleteImpl, InsMap,
ClsMap, CDecl, ExplicitImplProtocols);
CheckProtocolMethodDefs(*this, IMPDecl->getLocation(), P,
IncompleteImpl, InsMap, ClsMap, CDecl,
ExplicitImplProtocols);
DiagnoseUnimplementedProperties(S, IMPDecl, CDecl,
/*SynthesizeProperties=*/false);
}
Expand Down
15 changes: 0 additions & 15 deletions clang/test/FixIt/fixit-objc-missing-method-impl.m

This file was deleted.

0 comments on commit 37be748

Please sign in to comment.