Patch to do type-checking for objctive-c's object types.
More is yet to come.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45263 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp
index 6520fa9..531b348 100644
--- a/AST/ASTContext.cpp
+++ b/AST/ASTContext.cpp
@@ -1273,19 +1273,21 @@
   // match id<P..> with an 'id' type in all cases.
   if (const PointerType *PT = lhs->getAsPointerType()) {
     QualType PointeeTy = PT->getPointeeType();
-    if (isObjcIdType(PointeeTy))
+    if (isObjcIdType(PointeeTy) || PointeeTy->isVoidType())
       return true;
         
   }
   else if (const PointerType *PT = rhs->getAsPointerType()) {
     QualType PointeeTy = PT->getPointeeType();
-    if (isObjcIdType(PointeeTy))
+    if (isObjcIdType(PointeeTy) || PointeeTy->isVoidType())
       return true;
     
   }
   
   ObjcQualifiedInterfaceType *lhsQI = 0;
   ObjcQualifiedInterfaceType *rhsQI = 0;
+  ObjcInterfaceDecl *lhsID = 0;
+  ObjcInterfaceDecl *rhsID = 0;
   ObjcQualifiedIdType *lhsQID = dyn_cast<ObjcQualifiedIdType>(lhs);
   ObjcQualifiedIdType *rhsQID = dyn_cast<ObjcQualifiedIdType>(rhs);
   
@@ -1296,8 +1298,14 @@
       rhsQI = 
         dyn_cast<ObjcQualifiedInterfaceType>(
           rtype.getCanonicalType().getTypePtr());
+      if (!rhsQI) {
+        ObjcInterfaceType *IT = dyn_cast<ObjcInterfaceType>(
+                                  rtype.getCanonicalType().getTypePtr());
+        if (IT)
+          rhsID = IT->getDecl();
+      }
     }
-    if (!rhsQI && !rhsQID)
+    if (!rhsQI && !rhsQID && !rhsID)
       return false;
     
     for (unsigned i =0; i < lhsQID->getNumProtocols(); i++) {
@@ -1309,10 +1317,14 @@
         numRhsProtocols = rhsQI->getNumProtocols();
         rhsProtoList = rhsQI->getReferencedProtocols();
       }
-      else {
+      else if (rhsQID) {
         numRhsProtocols = rhsQID->getNumProtocols();
         rhsProtoList = rhsQID->getReferencedProtocols();
       }
+      else {
+        numRhsProtocols = rhsID->getNumIntfRefProtocols();
+        rhsProtoList = rhsID->getReferencedProtocols();
+      }
       for (unsigned j = 0; j < numRhsProtocols; j++) {
         ObjcProtocolDecl *rhsProto = rhsProtoList[j];
         if (lhsProto == rhsProto) {
@@ -1331,19 +1343,31 @@
       lhsQI = 
       dyn_cast<ObjcQualifiedInterfaceType>(
         ltype.getCanonicalType().getTypePtr());
+      if (!lhsQI) {
+        ObjcInterfaceType *IT = dyn_cast<ObjcInterfaceType>(
+                                  ltype.getCanonicalType().getTypePtr());
+        if (IT)
+          lhsID = IT->getDecl();
+      }
     }
-    if (!lhsQI && !lhsQID)
+    if (!lhsQI && !lhsQID && !lhsID)
       return false;
+    
     unsigned numLhsProtocols;
     ObjcProtocolDecl **lhsProtoList;
     if (lhsQI) {
       numLhsProtocols = lhsQI->getNumProtocols();
       lhsProtoList = lhsQI->getReferencedProtocols();
     }
-    else {
+    else if (lhsQID) {
       numLhsProtocols = lhsQID->getNumProtocols();
       lhsProtoList = lhsQID->getReferencedProtocols();
     }
+    else {
+      numLhsProtocols = lhsID->getNumIntfRefProtocols();
+      lhsProtoList = lhsID->getReferencedProtocols();
+    }
+    
     for (unsigned i =0; i < numLhsProtocols; i++) {
       bool match = false;
       ObjcProtocolDecl *lhsProto = lhsProtoList[i];