ASTContext::mergeTypes(): Loosen up the type checking for 'Class' (treating it like 'id').

This fixes <rdar://problem/6782722> XCDataTipsManager.m registers, observes notifications in class methods.

The radar above is the result of clang typing 'self' in a class method as 'Class', which results in some spurious warnings (GCC types 'self' in a class method as 'id').

I considered changing the type of 'self' to 'id' (to conform to GCC), however this resulted in *many* test cases breaking. In addition, I really prefer a more strongly typed 'self'.

All in all, this is the least obtrusive fix I could find for removing the spurious warnings (though we do loose some valid warnings).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69041 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 7b35731..f0c2d2b 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -2964,17 +2964,17 @@
     const ObjCInterfaceType* LHSIface = LHS->getAsObjCInterfaceType();
     const ObjCInterfaceType* RHSIface = RHS->getAsObjCInterfaceType();
 
-    // ID acts sort of like void* for ObjC interfaces
-    if (LHSIface && isObjCIdStructType(RHS))
+    // 'id' and 'Class' act sort of like void* for ObjC interfaces
+    if (LHSIface && (isObjCIdStructType(RHS) || isObjCClassStructType(RHS)))
       return LHS;
-    if (RHSIface && isObjCIdStructType(LHS))
+    if (RHSIface && (isObjCIdStructType(LHS) || isObjCClassStructType(LHS)))
       return RHS;
     
     // ID is compatible with all qualified id types.
     if (LHS->isObjCQualifiedIdType()) {
       if (const PointerType *PT = RHS->getAsPointerType()) {
         QualType pType = PT->getPointeeType();
-        if (isObjCIdStructType(pType))
+        if (isObjCIdStructType(pType) || isObjCClassStructType(pType))
           return LHS;
         // FIXME: need to use ObjCQualifiedIdTypesAreCompatible(LHS, RHS, true).
         // Unfortunately, this API is part of Sema (which we don't have access
@@ -2987,7 +2987,7 @@
     if (RHS->isObjCQualifiedIdType()) {
       if (const PointerType *PT = LHS->getAsPointerType()) {
         QualType pType = PT->getPointeeType();
-        if (isObjCIdStructType(pType))
+        if (isObjCIdStructType(pType) || isObjCClassStructType(pType))
           return RHS;
         // FIXME: need to use ObjCQualifiedIdTypesAreCompatible(LHS, RHS, true).
         // Unfortunately, this API is part of Sema (which we don't have access