[cfe-commits] r68931 - in /cfe/trunk: lib/AST/ASTContext.cpp test/SemaObjC/property.m
Chris Lattner
sabre at nondot.org
Sun Apr 12 16:51:02 PDT 2009
Author: lattner
Date: Sun Apr 12 18:51:02 2009
New Revision: 68931
URL: http://llvm.org/viewvc/llvm-project?rev=68931&view=rev
Log:
fix PR3932: [ObjC]Type defined as 'id' is not recognized as a valid object type.
by making ASTContext::isObjCObjectPointerType accept typedefs of id.
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/SemaObjC/property.m
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=68931&r1=68930&r2=68931&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sun Apr 12 18:51:02 2009
@@ -2659,22 +2659,29 @@
return true;
// All other object types are pointers.
- if (!Ty->isPointerType())
+ const PointerType *PT = Ty->getAsPointerType();
+ if (PT == 0)
return false;
- // Check to see if this is 'id' or 'Class', both of which are typedefs for
- // pointer types. This looks for the typedef specifically, not for the
- // underlying type.
- if (Ty.getUnqualifiedType() == getObjCIdType() ||
- Ty.getUnqualifiedType() == getObjCClassType())
- return true;
-
// If this a pointer to an interface (e.g. NSString*), it is ok.
- if (Ty->getAsPointerType()->getPointeeType()->isObjCInterfaceType())
+ if (PT->getPointeeType()->isObjCInterfaceType() ||
+ // If is has NSObject attribute, OK as well.
+ isObjCNSObjectType(Ty))
return true;
- // If is has NSObject attribute, OK as well.
- return isObjCNSObjectType(Ty);
+ // Check to see if this is 'id' or 'Class', both of which are typedefs for
+ // pointer types. This looks for the typedef specifically, not for the
+ // underlying type. Iteratively strip off typedefs so that we can handle
+ // typedefs of typedefs.
+ while (TypedefType *TDT = dyn_cast<TypedefType>(Ty)) {
+ if (Ty.getUnqualifiedType() == getObjCIdType() ||
+ Ty.getUnqualifiedType() == getObjCClassType())
+ return true;
+
+ Ty = TDT->getDecl()->getUnderlyingType();
+ }
+
+ return false;
}
/// getObjCGCAttr - Returns one of GCNone, Weak or Strong objc's
Modified: cfe/trunk/test/SemaObjC/property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property.m?rev=68931&r1=68930&r2=68931&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property.m (original)
+++ cfe/trunk/test/SemaObjC/property.m Sun Apr 12 18:51:02 2009
@@ -39,9 +39,17 @@
@property double bar;
@end
-int main() {
+int func1() {
id foo;
double bar = [foo bar];
return 0;
}
+// PR3932
+typedef id BYObjectIdentifier;
+ at interface Foo1 {
+ void *isa;
+}
+ at property(copy) BYObjectIdentifier identifier;
+ at end
+
More information about the cfe-commits
mailing list