]> granicus.if.org Git - clang/commitdiff
Move logic to check if a class is tagged with objc_suppress_protocol_methods into...
authorTed Kremenek <kremenek@apple.com>
Sat, 23 Nov 2013 22:29:06 +0000 (22:29 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 23 Nov 2013 22:29:06 +0000 (22:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195559 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp

index 23778cb368a5c26fe14f75fb86028d96c98e9c1e..def5817793f5076f98625d2bda4db899bb91c330 100644 (file)
@@ -925,6 +925,10 @@ public:
                                               : superCls; 
   }
 
+  /// \brief Returns true if this class is marked to suppress being
+  /// used to determine if a subclass conforms to a protocol.
+  bool shouldSuppressProtocol(const ObjCProtocolDecl *P) const;
+
   /// \brief Iterator that walks over the list of categories, filtering out
   /// those that do not meet specific criteria.
   ///
index a4857b607315661ec9119986285066c5db8d258d..69de6a3c859b38ece523721f790aace30f66b33a 100644 (file)
@@ -256,6 +256,22 @@ ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
 
 void ObjCInterfaceDecl::anchor() { }
 
+bool ObjCInterfaceDecl::shouldSuppressProtocol(const ObjCProtocolDecl *P) const{
+  if (!hasAttrs())
+    return false;
+  const AttrVec &V = 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 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.
@@ -477,18 +493,8 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel,
     // 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 (P && ClassDecl->shouldSuppressProtocol(P))
+      return 0;
 
     if ((MethodDecl = ClassDecl->getMethod(Sel, isInstance)))
       return MethodDecl;