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
diff --git a/Sema/SemaExprObjC.cpp b/Sema/SemaExprObjC.cpp
index f4d16d9..0f53bbd 100644
--- a/Sema/SemaExprObjC.cpp
+++ b/Sema/SemaExprObjC.cpp
@@ -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...