diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-10-23 23:06:22 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-10-23 23:06:22 +0000 |
commit | 6a6bb2810cc8478730002c950f9261f6cb5f6143 (patch) | |
tree | 3dec2fcaad10d9b69d992850221596a8244f6648 /lib/Sema/SemaDeclObjC.cpp | |
parent | 99eb4a7920667d23a89df8fcc6429d12b36e4d57 (diff) |
Objective-C: check that when a category method is being implemented,
method type in cateogry matches the implementation.
// rdar://12519216
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166518 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclObjC.cpp')
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index a4fec7aebf..c4e91e8501 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -1709,14 +1709,26 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap, } if (ObjCInterfaceDecl *I = dyn_cast<ObjCInterfaceDecl> (CDecl)) { - // Also methods in class extensions need be looked at next. - for (const ObjCCategoryDecl *ClsExtDecl = I->getFirstClassExtension(); - ClsExtDecl; ClsExtDecl = ClsExtDecl->getNextClassExtension()) - MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen, - IMPDecl, - const_cast<ObjCCategoryDecl *>(ClsExtDecl), - IncompleteImpl, false, - WarnCategoryMethodImpl); + // when checking that methods in implementation match their declaration, + // i.e. when WarnCategoryMethodImpl is false, check declarations in class + // extension; as well as those in categories. + if (!WarnCategoryMethodImpl) + for (const ObjCCategoryDecl *CDeclChain = I->getCategoryList(); + CDeclChain; CDeclChain = CDeclChain->getNextClassCategory()) + MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen, + IMPDecl, + const_cast<ObjCCategoryDecl *>(CDeclChain), + IncompleteImpl, false, + WarnCategoryMethodImpl); + else + // Also methods in class extensions need be looked at next. + for (const ObjCCategoryDecl *ClsExtDecl = I->getFirstClassExtension(); + ClsExtDecl; ClsExtDecl = ClsExtDecl->getNextClassExtension()) + MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen, + IMPDecl, + const_cast<ObjCCategoryDecl *>(ClsExtDecl), + IncompleteImpl, false, + WarnCategoryMethodImpl); // Check for any implementation of a methods declared in protocol. for (ObjCInterfaceDecl::all_protocol_iterator |