diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-08-04 21:28:44 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-08-04 21:28:44 +0000 |
commit | 6a3bec320e5617922f1f15657dcdaeb22610ca23 (patch) | |
tree | 16406de7348211182f71a195d1e890b119478024 /include/clang | |
parent | fc54016ead40df345b95d68b1f2d5e05a4a45f26 (diff) |
objective-c: diagnose protocol inconsistencies in following
situation. When a class explicitly or implicitly (through inheritance)
"conformsTo" two protocols which conflict (have methods which conflict).
This is 2nd part of // rdar://6191214.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136927 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/Basic/IdentifierTable.h | 5 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 30 |
2 files changed, 34 insertions, 1 deletions
diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index 017af5caee..c9fa74ce42 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -557,6 +557,11 @@ public: bool operator!=(Selector RHS) const { return InfoPtr != RHS.InfoPtr; } + + bool operator < (Selector RHS) const { + return InfoPtr < RHS.InfoPtr; + } + void *getAsOpaquePtr() const { return reinterpret_cast<void*>(InfoPtr); } diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index d9b320d51d..cccff294e5 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -493,6 +493,23 @@ public: /// a potentially evaluated expression. typedef SmallVector<std::pair<SourceLocation, Decl *>, 10> PotentiallyReferencedDecls; + + // FIXME. Improve on accessibility. + class PROTOCOL_METHODS { + public: + Selector Sel; + ObjCMethodDecl *Method; + PROTOCOL_METHODS(Selector S, ObjCMethodDecl *M) + : Sel(S), Method(M) {} + // Allow sorting based on selector's opaque pointer. + bool operator<(const PROTOCOL_METHODS &b) const { + return Sel < b.Sel; + } + }; + + /// \brief The set of protocols declared in protocols qualifying a + /// class. + typedef SmallVector<PROTOCOL_METHODS, 16> MethodsInProtocols; /// \brief A set of diagnostics that may be emitted. typedef SmallVector<std::pair<SourceLocation, PartialDiagnostic>, 10> @@ -1780,7 +1797,12 @@ public: void WarnExactTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl); - + + /// WarnOnMismatchedProtocolMethods - Issues warning on type mismatched + /// protocols methods and then returns true(matched), or false(mismatched). + bool WarnOnMismatchedProtocolMethods(ObjCMethodDecl *Method, + ObjCMethodDecl *MethodDecl); + bool isPropertyReadonly(ObjCPropertyDecl *PropertyDecl, ObjCInterfaceDecl *IDecl); @@ -1904,10 +1926,16 @@ public: bool ImmediateClass, bool WarnExactMatch=false); + /// MatchIdenticalSelectorsInProtocols - Check that mathods with + /// identical selectors in all protocols of this class type match. + /// Issue warning if they don't. + void MatchIdenticalSelectorsInProtocols(const ObjCInterfaceDecl *CDecl); + /// MatchMethodsInClassAndItsProtocol - Check that any redeclaration of /// method in protocol in its qualified class match in their type and /// issue warnings otherwise. void MatchMethodsInClassAndItsProtocol(const ObjCInterfaceDecl *CDecl); + /// CheckCategoryVsClassMethodMatches - Checks that methods implemented in /// category matches with those implemented in its primary class and |