diff options
author | Chris Lattner <sabre@nondot.org> | 2008-02-01 06:43:02 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-02-01 06:43:02 +0000 |
commit | fb8cc1dfd87a1cbbaa17d64ec753d3fe8a9e9c38 (patch) | |
tree | cdf9323da86976c2197357e880b0cbbfeeebab2d | |
parent | 77250c8034e4febf7ac48b95ebc4551eadcaee83 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46632 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Sema/SemaExprObjC.cpp | 17 |
1 files 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<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 @@ Sema::ExprResult Sema::ActOnInstanceMessage( 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... |