[cfe-commits] r46936 - in /cfe/trunk/Sema: Sema.h SemaDeclObjC.cpp
Steve Naroff
snaroff at apple.com
Sun Feb 10 13:39:00 PST 2008
Author: snaroff
Date: Sun Feb 10 15:38:56 2008
New Revision: 46936
URL: http://llvm.org/viewvc/llvm-project?rev=46936&view=rev
Log:
Add a diagnostics helper to remove some redundant code.
Modified:
cfe/trunk/Sema/Sema.h
cfe/trunk/Sema/SemaDeclObjC.cpp
Modified: cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.h?rev=46936&r1=46935&r2=46936&view=diff
==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Sun Feb 10 15:38:56 2008
@@ -268,6 +268,9 @@
void HandleAlignedAttribute(Decl *d, AttributeList *rawAttr);
+ void WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method,
+ bool &IncompleteImpl);
+
/// CheckProtocolMethodDefs - This routine checks unimpletented methods
/// Declared in protocol, and those referenced by it.
void CheckProtocolMethodDefs(SourceLocation ImpLoc,
@@ -280,7 +283,7 @@
/// listed in the implelementation match those listed in the interface.
void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
ObjCIvarDecl **Fields, unsigned nIvars,
- SourceLocation Loc);
+ SourceLocation Loc);
/// ImplMethodsVsClassMethods - This is main routine to warn if any method
/// remains unimplemented in the @implementation class.
Modified: cfe/trunk/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDeclObjC.cpp?rev=46936&r1=46935&r2=46936&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/Sema/SemaDeclObjC.cpp Sun Feb 10 15:38:56 2008
@@ -457,6 +457,15 @@
Diag((*IVI)->getLocation(), diag::err_inconsistant_ivar_count);
}
+void Sema::WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method,
+ bool &IncompleteImpl) {
+ if (!IncompleteImpl) {
+ Diag(ImpLoc, diag::warn_incomplete_impl);
+ IncompleteImpl = true;
+ }
+ Diag(ImpLoc, diag::warn_undef_method_impl, method->getSelector().getName());
+}
+
/// CheckProtocolMethodDefs - This routine checks unimplemented methods
/// Declared in protocol, and those referenced by it.
void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc,
@@ -469,28 +478,16 @@
E = PDecl->instmeth_end(); I != E; ++I) {
ObjCMethodDecl *method = *I;
if (!InsMap.count(method->getSelector()) &&
- method->getImplementationControl() != ObjCMethodDecl::Optional) {
- if (!IncompleteImpl) {
- Diag(ImpLoc, diag::warn_incomplete_impl);
- IncompleteImpl = true;
- }
- Diag(ImpLoc, diag::warn_undef_method_impl,
- method->getSelector().getName());
- }
+ method->getImplementationControl() != ObjCMethodDecl::Optional)
+ WarnUndefinedMethod(ImpLoc, method, IncompleteImpl);
}
// check unimplemented class methods
for (ObjCProtocolDecl::classmeth_iterator I = PDecl->classmeth_begin(),
E = PDecl->classmeth_end(); I != E; ++I) {
ObjCMethodDecl *method = *I;
if (!ClsMap.count(method->getSelector()) &&
- method->getImplementationControl() != ObjCMethodDecl::Optional) {
- if (!IncompleteImpl) {
- Diag(ImpLoc, diag::warn_incomplete_impl);
- IncompleteImpl = true;
- }
- Diag(ImpLoc, diag::warn_undef_method_impl,
- method->getSelector().getName());
- }
+ method->getImplementationControl() != ObjCMethodDecl::Optional)
+ WarnUndefinedMethod(ImpLoc, method, IncompleteImpl);
}
// Check on this protocols's referenced protocols, recursively
ObjCProtocolDecl** RefPDecl = PDecl->getReferencedProtocols();
@@ -510,14 +507,8 @@
bool IncompleteImpl = false;
for (ObjCInterfaceDecl::instmeth_iterator I = IDecl->instmeth_begin(),
E = IDecl->instmeth_end(); I != E; ++I)
- if (!InsMap.count((*I)->getSelector())) {
- if (!IncompleteImpl) {
- Diag(IMPDecl->getLocation(), diag::warn_incomplete_impl);
- IncompleteImpl = true;
- }
- Diag(IMPDecl->getLocation(), diag::warn_undef_method_impl,
- (*I)->getSelector().getName());
- }
+ if (!InsMap.count((*I)->getSelector()))
+ WarnUndefinedMethod(IMPDecl->getLocation(), *I, IncompleteImpl);
llvm::DenseSet<Selector> ClsMap;
// Check and see if class methods in class interface have been
@@ -528,14 +519,8 @@
for (ObjCInterfaceDecl::classmeth_iterator I = IDecl->classmeth_begin(),
E = IDecl->classmeth_end(); I != E; ++I)
- if (!ClsMap.count((*I)->getSelector())) {
- if (!IncompleteImpl) {
- Diag(IMPDecl->getLocation(), diag::warn_incomplete_impl);
- IncompleteImpl = true;
- }
- Diag(IMPDecl->getLocation(), diag::warn_undef_method_impl,
- (*I)->getSelector().getName());
- }
+ if (!ClsMap.count((*I)->getSelector()))
+ WarnUndefinedMethod(IMPDecl->getLocation(), *I, IncompleteImpl);
// Check the protocol list for unimplemented methods in the @implementation
// class.
@@ -559,14 +544,9 @@
bool IncompleteImpl = false;
for (ObjCCategoryDecl::instmeth_iterator I = CatClassDecl->instmeth_begin(),
E = CatClassDecl->instmeth_end(); I != E; ++I)
- if (!InsMap.count((*I)->getSelector())) {
- if (!IncompleteImpl) {
- Diag(CatImplDecl->getLocation(), diag::warn_incomplete_impl);
- IncompleteImpl = true;
- }
- Diag(CatImplDecl->getLocation(), diag::warn_undef_method_impl,
- (*I)->getSelector().getName());
- }
+ if (!InsMap.count((*I)->getSelector()))
+ WarnUndefinedMethod(CatImplDecl->getLocation(), *I, IncompleteImpl);
+
llvm::DenseSet<Selector> ClsMap;
// Check and see if class methods in category interface have been
// implemented in its implementation class.
@@ -577,14 +557,8 @@
for (ObjCCategoryDecl::classmeth_iterator I = CatClassDecl->classmeth_begin(),
E = CatClassDecl->classmeth_end(); I != E; ++I)
- if (!ClsMap.count((*I)->getSelector())) {
- if (!IncompleteImpl) {
- Diag(CatImplDecl->getLocation(), diag::warn_incomplete_impl);
- IncompleteImpl = true;
- }
- Diag(CatImplDecl->getLocation(), diag::warn_undef_method_impl,
- (*I)->getSelector().getName());
- }
+ if (!ClsMap.count((*I)->getSelector()))
+ WarnUndefinedMethod(CatImplDecl->getLocation(), *I, IncompleteImpl);
// Check the protocol list for unimplemented methods in the @implementation
// class.
More information about the cfe-commits
mailing list