[cfe-commits] r60852 - in /cfe/trunk: lib/AST/ASTContext.cpp test/SemaObjC/method-conflict.m

Steve Naroff snaroff at apple.com
Wed Dec 10 14:14:40 PST 2008


Author: snaroff
Date: Wed Dec 10 16:14:21 2008
New Revision: 60852

URL: http://llvm.org/viewvc/llvm-project?rev=60852&view=rev
Log:
The "real" fix for <rdar://problem/6424347> clang on xcode: Assertion failed: (0 && "unexpected type"), function mergeTypes,

Commit r60845 was premature.


Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/test/SemaObjC/method-conflict.m

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=60852&r1=60851&r2=60852&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Dec 10 16:14:21 2008
@@ -2122,36 +2122,35 @@
   if (LHSClass == Type::ObjCQualifiedInterface) LHSClass = Type::ObjCInterface;
   if (RHSClass == Type::ObjCQualifiedInterface) RHSClass = Type::ObjCInterface;
 
-  // ID is compatible with all qualified id types.
-  if (LHS->isObjCQualifiedIdType()) {
-    if (const PointerType *PT = RHS->getAsPointerType()) {
-      QualType pType = PT->getPointeeType();
-      if (isObjCIdType(pType))
-        return LHS;
-      // FIXME: need to use ObjCQualifiedIdTypesAreCompatible(LHS, RHS, true).
-      // Unfortunately, this API is part of Sema (which we don't have access
-      // to. Need to refactor. The following check is insufficient, since we 
-      // need to make sure the class implements the protocol.
-      if (pType->isObjCInterfaceType())
-        return LHS;
-    }
-  }
-  if (RHS->isObjCQualifiedIdType()) {
-    if (const PointerType *PT = LHS->getAsPointerType()) {
-      QualType pType = PT->getPointeeType();
-      if (isObjCIdType(pType))
-        return RHS;
-      // FIXME: need to use ObjCQualifiedIdTypesAreCompatible(LHS, RHS, true).
-      // Unfortunately, this API is part of Sema (which we don't have access
-      // to. Need to refactor. The following check is insufficient, since we 
-      // need to make sure the class implements the protocol.
-      if (pType->isObjCInterfaceType())
-        return RHS;
-    }
-  }
   // If the canonical type classes don't match.
   if (LHSClass != RHSClass) {
-
+    // ID is compatible with all qualified id types.
+    if (LHS->isObjCQualifiedIdType()) {
+      if (const PointerType *PT = RHS->getAsPointerType()) {
+        QualType pType = PT->getPointeeType();
+        if (isObjCIdType(pType))
+          return LHS;
+        // FIXME: need to use ObjCQualifiedIdTypesAreCompatible(LHS, RHS, true).
+        // Unfortunately, this API is part of Sema (which we don't have access
+        // to. Need to refactor. The following check is insufficient, since we 
+        // need to make sure the class implements the protocol.
+        if (pType->isObjCInterfaceType())
+          return LHS;
+      }
+    }
+    if (RHS->isObjCQualifiedIdType()) {
+      if (const PointerType *PT = LHS->getAsPointerType()) {
+        QualType pType = PT->getPointeeType();
+        if (isObjCIdType(pType))
+          return RHS;
+        // FIXME: need to use ObjCQualifiedIdTypesAreCompatible(LHS, RHS, true).
+        // Unfortunately, this API is part of Sema (which we don't have access
+        // to. Need to refactor. The following check is insufficient, since we 
+        // need to make sure the class implements the protocol.
+        if (pType->isObjCInterfaceType())
+          return RHS;
+      }
+    }
     // C99 6.7.2.2p4: Each enumerated type shall be compatible with char,
     // a signed integer type, or an unsigned integer type. 
     if (const EnumType* ETy = LHS->getAsEnumType()) {
@@ -2253,6 +2252,9 @@
     // Distinct ObjC interfaces are not compatible; see canAssignObjCInterfaces
     // for checking assignment/comparison safety
     return QualType();
+  case Type::ObjCQualifiedId:
+    // Distinct qualified id's are not compatible.
+    return QualType();
   default:
     assert(0 && "unexpected type");
     return QualType();

Modified: cfe/trunk/test/SemaObjC/method-conflict.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/method-conflict.m?rev=60852&r1=60851&r2=60852&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/method-conflict.m (original)
+++ cfe/trunk/test/SemaObjC/method-conflict.m Wed Dec 10 16:14:21 2008
@@ -25,7 +25,8 @@
 }
   CSSM_FIELDGROUP, *CSSM_FIELDGROUP_PTR;
 @protocol XDUMLClassifier;
- at protocol XDUMLClassInterfaceCommons <XDUMLClassifier>    @end  @protocol XDUMLImplementation;
+ at protocol XDUMLClassInterfaceCommons <XDUMLClassifier>  // expected-warning {{cannot find protocol definition for 'XDUMLClassifier'}}
+ at end  @protocol XDUMLImplementation;
 @protocol XDUMLElement <NSObject> - (NSArray *) ownedElements;
 @end @protocol XDUMLDataType;
 @protocol XDUMLNamedElement <XDUMLElement>     - (NSString *) name;
@@ -39,7 +40,7 @@
 @end  @class XDSCOperation;
 @interface XDSCClassFormatter : NSObject {
 }
-+ (NSUInteger) compartmentsForClassifier: (id <XDUMLClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec;
++ (NSUInteger) compartmentsForClassifier: (id <XDUMLClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec; // expected-note {{previous definition is here}}
 @end  
 @class NSString;
 @implementation XDSCClassFormatter       
@@ -47,7 +48,7 @@
 + appendVisibility: (id <XDUMLNamedElement>) element withSpecification: (XDSCDisplaySpecification *) displaySpec to: (NSMutableAttributedString *) attributedString
 {
 }
-// FIXME: should we warn? (since the protocols are different). FWIW...GCC doesn't currently.
-+ (NSUInteger) compartmentsForClassifier: (id <XDSCClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec {
+// GCC doesn't currently warn about this.
++ (NSUInteger) compartmentsForClassifier: (id <XDSCClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec { // expected-warning {{conflicting types for 'compartmentsForClassifier:withSpecification:'}}
 }
 @end 
\ No newline at end of file





More information about the cfe-commits mailing list