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

Steve Naroff snaroff at apple.com
Wed Dec 10 12:07:38 PST 2008


Author: snaroff
Date: Wed Dec 10 14:07:25 2008
New Revision: 60845

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

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

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

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Dec 10 14:07:25 2008
@@ -2126,35 +2126,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. 

Added: cfe/trunk/test/SemaObjC/method-conflict.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/method-conflict.m?rev=60845&view=auto

==============================================================================
--- cfe/trunk/test/SemaObjC/method-conflict.m (added)
+++ cfe/trunk/test/SemaObjC/method-conflict.m Wed Dec 10 14:07:25 2008
@@ -0,0 +1,53 @@
+// RUN: clang -fsyntax-only -verify %s
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+ at class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+ at protocol NSObject  - (BOOL)isEqual:(id)object;
+ at end  @protocol NSCopying  - (id)copyWithZone:(NSZone *)zone;
+ at end  @protocol NSMutableCopying  - (id)mutableCopyWithZone:(NSZone *)zone;
+ at end  @protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder;
+ at end    @interface NSObject <NSObject> {
+}
+ at end    extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+ at interface NSValue : NSObject <NSCopying, NSCoding>  - (void)getValue:(void *)value;
+ at end        @class NSString;
+typedef struct _NSRange {
+}
+  NSRange;
+ at interface NSValue (NSValueRangeExtensions)  + (NSValue *)valueWithRange:(NSRange)range;
+ at end  @interface NSAttributedString : NSObject <NSCopying, NSMutableCopying, NSCoding>  - (NSString *)string;
+ at end  @interface NSMutableAttributedString : NSAttributedString  - (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)str;
+ at end       @class NSArray, NSDictionary, NSString, NSError;
+ at interface NSScanner : NSObject <NSCopying>  - (NSString *)string;
+ at end        typedef struct {
+}
+  CSSM_FIELDGROUP, *CSSM_FIELDGROUP_PTR;
+ at protocol XDUMLClassifier;
+ at protocol XDUMLClassInterfaceCommons <XDUMLClassifier>    @end  @protocol XDUMLImplementation;
+ at protocol XDUMLElement <NSObject> - (NSArray *) ownedElements;
+ at end @protocol XDUMLDataType;
+ at protocol XDUMLNamedElement <XDUMLElement>     - (NSString *) name;
+ at end enum _XDSourceLanguage {
+XDSourceUnknown=0,     XDSourceJava,     XDSourceC,     XDSourceCPP,     XDSourceObjectiveC };
+typedef NSUInteger XDSourceLanguage;
+ at protocol XDSCClassifier <XDUMLClassInterfaceCommons> - (XDSourceLanguage)language;
+ at end  @class XDSCDocController;
+ at interface XDSCDisplaySpecification : NSObject <NSCoding>{
+}
+ at end  @class XDSCOperation;
+ at interface XDSCClassFormatter : NSObject {
+}
++ (NSUInteger) compartmentsForClassifier: (id <XDUMLClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec;
+ at end  
+ at class NSString;
+ at implementation XDSCClassFormatter       
+
++ 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 {
+}
+ at end 
\ No newline at end of file





More information about the cfe-commits mailing list