[cfe-commits] r53833 - /cfe/trunk/lib/Sema/SemaExprObjC.cpp

Chris Lattner sabre at nondot.org
Sun Jul 20 22:27:51 PDT 2008


Author: lattner
Date: Mon Jul 21 00:27:51 2008
New Revision: 53833

URL: http://llvm.org/viewvc/llvm-project?rev=53833&view=rev
Log:
merge a bunch of code that is now common between qual interfaces and interfaces.

Modified:
    cfe/trunk/lib/Sema/SemaExprObjC.cpp

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=53833&r1=53832&r2=53833&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Mon Jul 21 00:27:51 2008
@@ -277,24 +277,7 @@
         receiverType = PTy->getPointeeType();
     
     ObjCInterfaceDecl* ClassDecl = 0;
-    if (ObjCQualifiedInterfaceType *QIT = 
-        dyn_cast<ObjCQualifiedInterfaceType>(receiverType)) {
-      ClassDecl = QIT->getDecl();
-      Method = ClassDecl->lookupInstanceMethod(Sel);
-      if (!Method) {
-        // search protocols
-        for (unsigned i = 0; i < QIT->getNumProtocols(); i++) {
-          ObjCProtocolDecl *PDecl = QIT->getProtocol(i);
-          if (PDecl && (Method = PDecl->lookupInstanceMethod(Sel)))
-            break;
-        }
-      }
-      if (!Method)
-        Diag(lbrac, diag::warn_method_not_found_in_protocol, 
-             std::string("-"), Sel.getName(),
-             SourceRange(lbrac, rbrac));
-    }
-    else if (ObjCQualifiedIdType *QIT = 
+    if (ObjCQualifiedIdType *QIT = 
              dyn_cast<ObjCQualifiedIdType>(receiverType)) {
       // search protocols
       for (unsigned i = 0; i < QIT->getNumProtocols(); i++) {
@@ -306,20 +289,35 @@
         Diag(lbrac, diag::warn_method_not_found_in_protocol, 
              std::string("-"), Sel.getName(),
              SourceRange(lbrac, rbrac));
-    }
-    else {
+    } else {
       ObjCInterfaceType *OCIReceiver =dyn_cast<ObjCInterfaceType>(receiverType);
       if (OCIReceiver == 0) {
-          Diag(lbrac, diag::error_bad_receiver_type,
-               RExpr->getType().getAsString());
-          return true;
+        Diag(lbrac, diag::error_bad_receiver_type,
+             RExpr->getType().getAsString());
+        return true;
       }
+      
       ClassDecl = OCIReceiver->getDecl();
       // FIXME: consider using InstanceMethodPool, since it will be faster
       // than the following method (which can do *many* linear searches). The
-      // idea is to add class info to InstanceMethodPool...
+      // idea is to add class info to InstanceMethodPool.
       Method = ClassDecl->lookupInstanceMethod(Sel);
+      
+      if (!Method) {
+        // Search protocol qualifiers.
+        for (ObjCQualifiedIdType::qual_iterator QI = OCIReceiver->qual_begin(),
+             E = OCIReceiver->qual_end(); QI != E; ++QI) {
+          if ((Method = (*QI)->lookupInstanceMethod(Sel)))
+            break;
+        }
+      }
+      
+      if (!Method && !OCIReceiver->qual_empty())
+        Diag(lbrac, diag::warn_method_not_found_in_protocol, 
+             std::string("-"), Sel.getName(),
+             SourceRange(lbrac, rbrac));
     }
+    
     if (!Method) {
       // If we have an implementation in scope, check "private" methods.
       if (ClassDecl)





More information about the cfe-commits mailing list