Fix a crash that can happen when you have typedefs for pointers to

interfaces.  Just because they x->isPointerType() doesn't mean it is
valid to just cast to a pointertype.  We have to handle typedefs etc
as well.

llvm-svn: 53819
This commit is contained in:
Chris Lattner 2008-07-21 04:09:54 +00:00
parent 15727f69fa
commit c47d930448
1 changed files with 5 additions and 4 deletions

View File

@ -35,13 +35,14 @@ bool Sema::isObjCObjectPointerType(QualType type) const {
if (!type->isPointerType())
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 (type == Context.getObjCIdType() || type == Context.getObjCClassType())
return true;
if (type->isPointerType()) {
PointerType *pointerType = static_cast<PointerType*>(type.getTypePtr());
type = pointerType->getPointeeType();
}
const PointerType *pointerType = type->getAsPointerType();
type = pointerType->getPointeeType();
return type->isObjCInterfaceType() || type->isObjCQualifiedIdType();
}