summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-12 23:51:02 +0000
committerChris Lattner <sabre@nondot.org>2009-04-12 23:51:02 +0000
commitbc670459ad6f6c1e7c4491b4c937d8de22470d00 (patch)
tree99a9a8d3f20694de28fd36e338cdda65b9108ea2 /clang/lib
parent1e2f763c4c6274b1b77aefb3b5c0dd79519dff81 (diff)
downloadbcm5719-llvm-bc670459ad6f6c1e7c4491b4c937d8de22470d00.tar.gz
bcm5719-llvm-bc670459ad6f6c1e7c4491b4c937d8de22470d00.zip
fix PR3932: [ObjC]Type defined as 'id' is not recognized as a valid object type.
by making ASTContext::isObjCObjectPointerType accept typedefs of id. llvm-svn: 68931
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/ASTContext.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index ac69a38c3dc..f319c3f392e 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -2659,22 +2659,29 @@ bool ASTContext::isObjCObjectPointerType(QualType Ty) const {
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
OpenPOWER on IntegriCloud