]> granicus.if.org Git - clang/commitdiff
Fix a crash that can happen when you have typedefs for pointers to
authorChris Lattner <sabre@nondot.org>
Mon, 21 Jul 2008 04:09:54 +0000 (04:09 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 21 Jul 2008 04:09:54 +0000 (04:09 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53819 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/Sema.cpp

index 52858cb893e97fde4dff8253f4baf50c0ce240fa..4d1a0537798ff4ebbb90f28f3a255dd3b2709e1e 100644 (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();
 }