[cfe-commits] r46632 - /cfe/trunk/Sema/SemaExprObjC.cpp

Chris Lattner sabre at nondot.org
Thu Jan 31 22:43:02 PST 2008


Author: lattner
Date: Fri Feb  1 00:43:02 2008
New Revision: 46632

URL: http://llvm.org/viewvc/llvm-project?rev=46632&view=rev
Log:
Sema::ActOnInstanceMessage is generally doing bad things with typedefs, but
here I fix just one.  The loop that rips through pointers should use
getAsPointerType() not static_cast<PointerType*> to get the pointee.  This
fixes a crash on a large testcase.

Modified:
    cfe/trunk/Sema/SemaExprObjC.cpp

Modified: cfe/trunk/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExprObjC.cpp?rev=46632&r1=46631&r2=46632&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/Sema/SemaExprObjC.cpp Fri Feb  1 00:43:02 2008
@@ -201,6 +201,9 @@
   QualType returnType;
   ObjCMethodDecl *Method = 0;
   
+  // FIXME:
+  // FIXME: This code is not stripping off type qualifiers or typedefs!
+  // FIXME:
   if (receiverType == Context.getObjCIdType() ||
       receiverType == Context.getObjCClassType()) {
     Method = InstanceMethodPool[Sel].Method;
@@ -221,11 +224,9 @@
     // FIXME (snaroff): checking in this code from Patrick. Needs to be
     // revisited. how do we get the ClassDecl from the receiver expression?
     if (!receiverIsQualId)
-      while (receiverType->isPointerType()) {
-        PointerType *pointerType =
-          static_cast<PointerType*>(receiverType.getTypePtr());
-        receiverType = pointerType->getPointeeType();
-      }
+      while (const PointerType *PTy = receiverType->getAsPointerType())
+        receiverType = PTy->getPointeeType();
+    
     ObjCInterfaceDecl* ClassDecl = 0;
     if (ObjCQualifiedInterfaceType *QIT = 
         dyn_cast<ObjCQualifiedInterfaceType>(receiverType)) {
@@ -258,12 +259,12 @@
              SourceRange(lbrac, rbrac));
     }
     else {
-      if (!isa<ObjCInterfaceType>(receiverType.getTypePtr())) {
+      ObjCInterfaceType *OCIReceiver =dyn_cast<ObjCInterfaceType>(receiverType);
+      if (OCIReceiver == 0) {
         Diag(lbrac, diag::error_bad_receiver_type, receiverType.getAsString());
         return true;
       }
-      ClassDecl = static_cast<ObjCInterfaceType*>(
-                    receiverType.getTypePtr())->getDecl();
+      ClassDecl = OCIReceiver->getDecl();
       // FIXME: consider using InstanceMethodPool, since it will be faster
       // than the following method (which can do *many* linear searches). The
       // idea is to add class info to InstanceMethodPool...





More information about the cfe-commits mailing list