summaryrefslogtreecommitdiffstats
path: root/clang/Sema/SemaExprObjC.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-02-01 06:43:02 +0000
committerChris Lattner <sabre@nondot.org>2008-02-01 06:43:02 +0000
commit617bfc39ffeafa7dff1eaa47f980b8e8043efc2a (patch)
tree9081c075444627f3356a6208684b64db6b294157 /clang/Sema/SemaExprObjC.cpp
parent81f0550cdddc81c406e05821570b730b79c80624 (diff)
downloadbcm5719-llvm-617bfc39ffeafa7dff1eaa47f980b8e8043efc2a.tar.gz
bcm5719-llvm-617bfc39ffeafa7dff1eaa47f980b8e8043efc2a.zip
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. llvm-svn: 46632
Diffstat (limited to 'clang/Sema/SemaExprObjC.cpp')
-rw-r--r--clang/Sema/SemaExprObjC.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/clang/Sema/SemaExprObjC.cpp b/clang/Sema/SemaExprObjC.cpp
index f4d16d9736c..0f53bbd804c 100644
--- a/clang/Sema/SemaExprObjC.cpp
+++ b/clang/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...
OpenPOWER on IntegriCloud