diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-08-08 18:03:17 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-08-08 18:03:17 +0000 |
commit | 2112190efa85f50af84a3c4efe03c5bf69247ba2 (patch) | |
tree | 7bbe32f806be3093495453ef919f722f6607b826 /include | |
parent | adc7a739301d123914b7124e749b7ec74fa91397 (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 patch fixes the previous patch where warnings were coming out in
non-deterministic order. This is 2nd part of // rdar://6191214.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137055 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/Basic/IdentifierTable.h | 5 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 46 |
2 files changed, 50 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 d13edfa998..90d0195cff 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -493,6 +493,39 @@ 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; + + class IDENTICAL_SELECTOR_METHODS { + public: + SourceLocation Loc; + ObjCMethodDecl *Method; + IDENTICAL_SELECTOR_METHODS(SourceLocation L, ObjCMethodDecl *M) + : Loc(L), Method(M) {} + // Allow sorting based on selector's source location. + bool operator<(const IDENTICAL_SELECTOR_METHODS &i) const { + return !(Loc < i.Loc); + } + }; + + /// \brief Methods with identical selectors to be type-matched against + /// one another. + typedef SmallVector<IDENTICAL_SELECTOR_METHODS, 8> IdenticalSelectorMethods; /// \brief A set of diagnostics that may be emitted. typedef SmallVector<std::pair<SourceLocation, PartialDiagnostic>, 10> @@ -1780,7 +1813,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 +1942,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 |