From d4798ef4211d13d0e6cf4f692f5a8a2b10c6ecf3 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 13 Dec 2013 06:26:10 +0000 Subject: [PATCH] Make 'CheckProtocolMethodDefs' a static function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197208 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/Sema.h | 9 --------- lib/Sema/SemaDeclObjC.cpp | 40 ++++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index b11322d7db..67f62ce702 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -2600,15 +2600,6 @@ public: typedef llvm::SmallPtrSet SelectorSet; typedef llvm::DenseMap ProtocolsMethodsMap; - /// CheckProtocolMethodDefs - This routine checks unimplemented - /// methods declared in protocol, and those referenced by it. - void CheckProtocolMethodDefs(SourceLocation ImpLoc, - ObjCProtocolDecl *PDecl, - bool& IncompleteImpl, - const SelectorSet &InsMap, - const SelectorSet &ClsMap, - ObjCContainerDecl *CDecl); - /// CheckImplementationIvars - This routine checks if the instance variables /// listed in the implelementation match those listed in the interface. void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 723fbdb6e6..1aa36ca678 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -1635,12 +1635,13 @@ void Sema::WarnExactTypedMethods(ObjCMethodDecl *ImpMethodDecl, /// CheckProtocolMethodDefs - This routine checks unimplemented methods /// Declared in protocol, and those referenced by it. -void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc, - ObjCProtocolDecl *PDecl, - bool& IncompleteImpl, - const SelectorSet &InsMap, - const SelectorSet &ClsMap, - ObjCContainerDecl *CDecl) { +static void CheckProtocolMethodDefs(Sema &S, + SourceLocation ImpLoc, + ObjCProtocolDecl *PDecl, + bool& IncompleteImpl, + const Sema::SelectorSet &InsMap, + const Sema::SelectorSet &ClsMap, + ObjCContainerDecl *CDecl) { ObjCCategoryDecl *C = dyn_cast(CDecl); ObjCInterfaceDecl *IDecl = C ? C->getClassInterface() : dyn_cast(CDecl); @@ -1648,7 +1649,7 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc, ObjCInterfaceDecl *Super = IDecl->getSuperClass(); ObjCInterfaceDecl *NSIDecl = 0; - if (getLangOpts().ObjCRuntime.isNeXTFamily()) { + if (S.getLangOpts().ObjCRuntime.isNeXTFamily()) { // check to see if class implements forwardInvocation method and objects // of this class are derived from 'NSProxy' so that to forward requests // from one object to another. @@ -1656,12 +1657,12 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc, // implemented in the class, we should not issue "Method definition not // found" warnings. // FIXME: Use a general GetUnarySelector method for this. - IdentifierInfo* II = &Context.Idents.get("forwardInvocation"); - Selector fISelector = Context.Selectors.getSelector(1, &II); + IdentifierInfo* II = &S.Context.Idents.get("forwardInvocation"); + Selector fISelector = S.Context.Selectors.getSelector(1, &II); if (InsMap.count(fISelector)) // Is IDecl derived from 'NSProxy'? If so, no instance methods // need be implemented in the implementation. - NSIDecl = IDecl->lookupInheritedClass(&Context.Idents.get("NSProxy")); + NSIDecl = IDecl->lookupInheritedClass(&S.Context.Idents.get("NSProxy")); } // If this is a forward protocol declaration, get its definition. @@ -1706,9 +1707,9 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc, if (C || MethodInClass->isPropertyAccessor()) continue; unsigned DIAG = diag::warn_unimplemented_protocol_method; - if (Diags.getDiagnosticLevel(DIAG, ImpLoc) + if (S.Diags.getDiagnosticLevel(DIAG, ImpLoc) != DiagnosticsEngine::Ignored) { - WarnUndefinedMethod(*this, ImpLoc, method, IncompleteImpl, DIAG, + WarnUndefinedMethod(S, ImpLoc, method, IncompleteImpl, DIAG, PDecl); } } @@ -1733,16 +1734,17 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc, continue; unsigned DIAG = diag::warn_unimplemented_protocol_method; - if (Diags.getDiagnosticLevel(DIAG, ImpLoc) != + if (S.Diags.getDiagnosticLevel(DIAG, ImpLoc) != DiagnosticsEngine::Ignored) { - WarnUndefinedMethod(*this, ImpLoc, method, IncompleteImpl, DIAG, PDecl); + WarnUndefinedMethod(S, ImpLoc, method, IncompleteImpl, DIAG, PDecl); } } } // Check on this protocols's referenced protocols, recursively. for (ObjCProtocolDecl::protocol_iterator PI = PDecl->protocol_begin(), E = PDecl->protocol_end(); PI != E; ++PI) - CheckProtocolMethodDefs(ImpLoc, *PI, IncompleteImpl, InsMap, ClsMap, CDecl); + CheckProtocolMethodDefs(S, ImpLoc, *PI, IncompleteImpl, InsMap, ClsMap, + CDecl); } /// MatchAllMethodDeclarations - Check methods declared in interface @@ -1959,8 +1961,8 @@ void Sema::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl, for (ObjCInterfaceDecl::all_protocol_iterator PI = I->all_referenced_protocol_begin(), E = I->all_referenced_protocol_end(); PI != E; ++PI) - CheckProtocolMethodDefs(IMPDecl->getLocation(), *PI, IncompleteImpl, - InsMap, ClsMap, I); + CheckProtocolMethodDefs(*this, IMPDecl->getLocation(), *PI, + IncompleteImpl, InsMap, ClsMap, I); // Check class extensions (unnamed categories) for (ObjCInterfaceDecl::visible_extensions_iterator Ext = I->visible_extensions_begin(), @@ -1974,8 +1976,8 @@ void Sema::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl, if (!C->IsClassExtension()) { for (ObjCCategoryDecl::protocol_iterator PI = C->protocol_begin(), E = C->protocol_end(); PI != E; ++PI) - CheckProtocolMethodDefs(IMPDecl->getLocation(), *PI, IncompleteImpl, - InsMap, ClsMap, CDecl); + CheckProtocolMethodDefs(*this, IMPDecl->getLocation(), *PI, + IncompleteImpl, InsMap, ClsMap, CDecl); DiagnoseUnimplementedProperties(S, IMPDecl, CDecl); } } else -- 2.50.0