[cfe-commits] r65583 - in /cfe/trunk: lib/AST/Type.cpp test/SemaObjC/weak-attr-ivar.m

Fariborz Jahanian fjahanian at apple.com
Thu Feb 26 15:05:51 PST 2009


Author: fjahanian
Date: Thu Feb 26 17:05:51 2009
New Revision: 65583

URL: http://llvm.org/viewvc/llvm-project?rev=65583&view=rev
Log:
Do not issue bogus error on __weak/__strong ivar access.

Added:
    cfe/trunk/test/SemaObjC/weak-attr-ivar.m
Modified:
    cfe/trunk/lib/AST/Type.cpp

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

==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Thu Feb 26 17:05:51 2009
@@ -476,20 +476,20 @@
   // There is no sugar for ObjCInterfaceType's, just return the canonical
   // type pointer if it is the right class.  There is no typedef information to
   // return and these cannot be Address-space qualified.
-  return dyn_cast<ObjCInterfaceType>(CanonicalType);
+  return dyn_cast<ObjCInterfaceType>(CanonicalType.getUnqualifiedType());
 }
 
 const ObjCQualifiedInterfaceType *
 Type::getAsObjCQualifiedInterfaceType() const {
   // There is no sugar for ObjCQualifiedInterfaceType's, just return the
   // canonical type pointer if it is the right class.
-  return dyn_cast<ObjCQualifiedInterfaceType>(CanonicalType);
+  return dyn_cast<ObjCQualifiedInterfaceType>(CanonicalType.getUnqualifiedType());
 }
 
 const ObjCQualifiedIdType *Type::getAsObjCQualifiedIdType() const {
   // There is no sugar for ObjCQualifiedIdType's, just return the canonical
   // type pointer if it is the right class.
-  return dyn_cast<ObjCQualifiedIdType>(CanonicalType);
+  return dyn_cast<ObjCQualifiedIdType>(CanonicalType.getUnqualifiedType());
 }
 
 const TemplateTypeParmType *Type::getAsTemplateTypeParmType() const {

Added: cfe/trunk/test/SemaObjC/weak-attr-ivar.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/weak-attr-ivar.m?rev=65583&view=auto

==============================================================================
--- cfe/trunk/test/SemaObjC/weak-attr-ivar.m (added)
+++ cfe/trunk/test/SemaObjC/weak-attr-ivar.m Thu Feb 26 17:05:51 2009
@@ -0,0 +1,73 @@
+// 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
+ at protocol NSCopying  - (id)copyWithZone:(NSZone *)zone;
+ at end
+ at protocol NSMutableCopying  - (id)mutableCopyWithZone:(NSZone *)zone;
+ at end
+ at protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder;
+ at end
+ at interface NSObject <NSObject> {}
+ at end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+typedef struct {
+  id *itemsPtr;
+  unsigned long *mutationsPtr;
+} NSFastEnumerationState;
+ at protocol NSFastEnumeration
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+ at end
+ at class NSString;
+ at interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>  - (NSUInteger)count;
+ at end
+ at interface NSMutableArray : NSArray  - (void)addObject:(id)anObject;
+ at end
+extern NSString * const NSUndoManagerCheckpointNotification;
+ at interface NSValueTransformer : NSObject {} @end
+ at class FooModel;
+ at interface FooObject : NSObject <NSCopying> {}
+ at end
+ at interface FooNode : FooObject {}
+- (NSArray *) children;
+ at end
+typedef enum { Foo_HUH_NONE } FooHUHCode;
+ at interface FooPlaypenEntry : FooNode {
+  NSMutableArray *_interestingChildren;
+  FooHUHCode _HUH;
+  __attribute__((objc_gc(weak))) FooPlaypenEntry *_mostInterestingChild;
+  id _author;
+}
+ at property(copy) NSString *author;
+- (BOOL) isInteresting;
+ at end  NSString *FooHUHCodeToString(FooHUHCode HUH) {
+}
+ at interface FooHUHCodeToStringTransformer: NSValueTransformer {
+}
+ at end  @implementation FooPlaypenEntry  @synthesize author = _author;
+- (BOOL) isInteresting { return 1; }
+- (NSArray *) interestingChildren {
+  if (!_interestingChildren) {
+    for (FooPlaypenEntry *child in [self children]) {
+      if ([child isInteresting]) {
+        if (!_mostInterestingChild)
+          _mostInterestingChild = child;
+        else if (child->_HUH > _mostInterestingChild->_HUH) 
+          _mostInterestingChild = child;
+      }
+    }
+  }
+}
+- (FooHUHCode) HUH {
+  if (_HUH == Foo_HUH_NONE) {
+    if (_mostInterestingChild)
+      return [_mostInterestingChild HUH];
+  }
+}
+ at end
+





More information about the cfe-commits mailing list