From fb8cc1dfd87a1cbbaa17d64ec753d3fe8a9e9c38 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 1 Feb 2008 06:43:02 +0000 Subject: [PATCH] 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 to get the pointee. This fixes a crash on a large testcase. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46632 91177308-0d34-0410-b5e6-96231b3b80d8 --- Sema/SemaExprObjC.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Sema/SemaExprObjC.cpp b/Sema/SemaExprObjC.cpp index f4d16d9736..0f53bbd804 100644 --- a/Sema/SemaExprObjC.cpp +++ b/Sema/SemaExprObjC.cpp @@ -201,6 +201,9 @@ Sema::ExprResult Sema::ActOnInstanceMessage( 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 @@ Sema::ExprResult Sema::ActOnInstanceMessage( // 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(receiverType.getTypePtr()); - receiverType = pointerType->getPointeeType(); - } + while (const PointerType *PTy = receiverType->getAsPointerType()) + receiverType = PTy->getPointeeType(); + ObjCInterfaceDecl* ClassDecl = 0; if (ObjCQualifiedInterfaceType *QIT = dyn_cast(receiverType)) { @@ -258,12 +259,12 @@ Sema::ExprResult Sema::ActOnInstanceMessage( SourceRange(lbrac, rbrac)); } else { - if (!isa(receiverType.getTypePtr())) { + ObjCInterfaceType *OCIReceiver =dyn_cast(receiverType); + if (OCIReceiver == 0) { Diag(lbrac, diag::error_bad_receiver_type, receiverType.getAsString()); return true; } - ClassDecl = static_cast( - 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... -- 2.40.0