diff options
author | Ted Kremenek <kremenek@apple.com> | 2013-11-23 01:01:34 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2013-11-23 01:01:34 +0000 |
commit | 28eace65c09a51e24fb5651ee035e2c6c102da69 (patch) | |
tree | ab5a24003861c9eae641764eb089cff1647059d6 /clang/lib/AST/DeclObjC.cpp | |
parent | 0078150c43f91c82cf43c8e65f6715b984e1a80f (diff) | |
download | bcm5719-llvm-28eace65c09a51e24fb5651ee035e2c6c102da69.tar.gz bcm5719-llvm-28eace65c09a51e24fb5651ee035e2c6c102da69.zip |
Add back experimental attribute objc_suppress_protocol_methods (slightly renamed).
This is still an experimental attribute, but I wanted it in tree
for review. It may still get yanked.
This attribute can only be applied to a class @interface, not
a class extension or category. It does not change the type
system rules for Objective-C, but rather the implementation checking
for Objective-C classes that explicitly conform to a protocol.
During protocol conformance checking, clang recursively searches
up the class hierarchy for the set of methods that compose
a protocol. This attribute will cause the compiler to not consider
the methods contributed by a super class, its categories, and those
from its ancestor classes. Thus this attribute is used to force
subclasses to redeclare (and hopefully re-implement) methods if
they decide to explicitly conform to a protocol where some of those
methods may be provided by a super class.
This attribute intentionally leaves out properties, which are associated
with state. This attribute only considers methods (at least right now)
that are non-property accessors. These represent methods that "do something"
as dictated by the protocol. This may be further refined, and this
should be considered a WIP until documentation gets written or this
gets removed.
llvm-svn: 195533
Diffstat (limited to 'clang/lib/AST/DeclObjC.cpp')
-rw-r--r-- | clang/lib/AST/DeclObjC.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index ca87bb8197f..a4857b60731 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -460,7 +460,8 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, bool isInstance, bool shallowCategoryLookup, bool followSuper, - const ObjCCategoryDecl *C) const + const ObjCCategoryDecl *C, + const ObjCProtocolDecl *P) const { // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) @@ -473,6 +474,22 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, LoadExternalDefinition(); while (ClassDecl) { + // If we are looking for a method that is part of protocol conformance, + // check if the superclass has been marked to suppress conformance + // of that protocol. + if (P && ClassDecl->hasAttrs()) { + const AttrVec &V = ClassDecl->getAttrs(); + const IdentifierInfo *PI = P->getIdentifier(); + for (AttrVec::const_iterator I = V.begin(), E = V.end(); I != E; ++I) { + if (const ObjCSuppressProtocolAttr *A = + dyn_cast<ObjCSuppressProtocolAttr>(*I)){ + if (A->getProtocol() == PI) { + return 0; + } + } + } + } + if ((MethodDecl = ClassDecl->getMethod(Sel, isInstance))) return MethodDecl; |