diff options
author | Ted Kremenek <kremenek@apple.com> | 2013-12-10 19:43:48 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2013-12-10 19:43:48 +0000 |
commit | f41cf7f10f76704b7037de9a8a7adcc114db1c46 (patch) | |
tree | 0f57c1a4e0271d7ae02d7a70d51f2276d5e40283 /clang/lib | |
parent | d980da2290fda089a3156d0b23e928fcf99b270a (diff) | |
download | bcm5719-llvm-f41cf7f10f76704b7037de9a8a7adcc114db1c46.tar.gz bcm5719-llvm-f41cf7f10f76704b7037de9a8a7adcc114db1c46.zip |
Rename attribute 'objc_suppress_protocol_methods' to 'objc_protocol_requires_explicit_implementation'.
That's a mouthful, and not necessarily the final name. This also
reflects a semantic change where this attribute is now on the
protocol itself instead of a class. This attribute will require
that a protocol, when adopted by a class, is explicitly implemented
by the class itself (instead of walking the super class chain).
Note that this attribute is not "done". This should be considered
a WIP.
llvm-svn: 196955
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/DeclObjC.cpp | 21 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 13 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 8 |
3 files changed, 8 insertions, 34 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index fb4b9dbd1f4..3db1acf0039 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -256,18 +256,6 @@ ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const { void ObjCInterfaceDecl::anchor() { } -bool ObjCInterfaceDecl::shouldSuppressProtocol(const ObjCProtocolDecl *P) const{ - if (!hasAttrs()) - return false; - const IdentifierInfo *PI = P->getIdentifier(); - for (specific_attr_iterator<ObjCSuppressProtocolAttr> - I = specific_attr_begin<ObjCSuppressProtocolAttr>(), - E = specific_attr_end<ObjCSuppressProtocolAttr>(); I != E; ++I) - if ((*I)->getProtocol() == PI) - return true; - return false; -} - /// FindPropertyVisibleInPrimaryClass - Finds declaration of the property /// with name 'PropertyId' in the primary class; including those in protocols /// (direct or indirect) used by the primary class. @@ -555,8 +543,7 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, bool isInstance, bool shallowCategoryLookup, bool followSuper, - const ObjCCategoryDecl *C, - const ObjCProtocolDecl *P) const + const ObjCCategoryDecl *C) const { // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) @@ -569,12 +556,6 @@ 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->shouldSuppressProtocol(P)) - return 0; - if ((MethodDecl = ClassDecl->getMethod(Sel, isInstance))) return MethodDecl; diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 6d7bc034658..0edef9e52a4 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -1740,16 +1740,9 @@ static void handleAttrWithMessage(Sema &S, Decl *D, static void handleObjCSuppresProtocolAttr(Sema &S, Decl *D, const AttributeList &Attr) { - IdentifierLoc *Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : 0; - - if (!Parm) { - S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.getName() << 1; - return; - } - D->addAttr(::new (S.Context) - ObjCSuppressProtocolAttr(Attr.getRange(), S.Context, Parm->Ident, - Attr.getAttributeSpellingListIndex())); + ObjCExplicitProtocolImplAttr(Attr.getRange(), S.Context, + Attr.getAttributeSpellingListIndex())); } static bool checkAvailabilityAttr(Sema &S, SourceRange Range, @@ -4032,7 +4025,7 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, handleSimpleAttribute<ArcWeakrefUnavailableAttr>(S, D, Attr); break; case AttributeList::AT_ObjCRootClass: handleSimpleAttribute<ObjCRootClassAttr>(S, D, Attr); break; - case AttributeList::AT_ObjCSuppressProtocol: + case AttributeList::AT_ObjCExplicitProtocolImpl: handleObjCSuppresProtocolAttr(S, D, Attr); break; case AttributeList::AT_ObjCRequiresPropertyDefs: diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 421b797c794..babfafe656d 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1666,6 +1666,8 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc, // the method was implemented by a base class or an inherited // protocol. This lookup is slow, but occurs rarely in correct code // and otherwise would terminate in a warning. + if (PDecl->hasAttr<ObjCExplicitProtocolImplAttr>()) + Super = NULL; // check unimplemented instance methods. if (!NSIDecl) @@ -1679,8 +1681,7 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc, true /* instance */, false /* shallowCategory */, true /* followsSuper */, - NULL /* category */, - PDecl /* protocol */))) { + NULL /* category */))) { // If a method is not implemented in the category implementation but // has been declared in its primary class, superclass, // or in one of their protocols, no need to issue the warning. @@ -1717,8 +1718,7 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc, false /* class method */, false /* shallowCategoryLookup */, true /* followSuper */, - NULL /* category */, - PDecl /* protocol */))) { + NULL /* category */))) { // See above comment for instance method lookups. if (C && IDecl->lookupMethod(method->getSelector(), false /* class */, |