Author: lattner
Date: Sun Jul 20 23:09:54 2008
New Revision: 53819
URL: http://llvm.org/viewvc/llvm-project?rev=53819&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/Sema.cpp
Modified: cfe/trunk/lib/Sema/Sema.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=53819&r1=53818&r2=53819&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Sun Jul 20 23:09:54 2008
@@ -35,13 +35,14 @@
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();
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits