In debugger mode, make ObjC message sends to unknown selectors return
__unknown_anytype, and rewrite such message sends correctly.
I had to bite the bullet and actually add a debugger support mode for this
one, which is a bit unfortunate, but there really isn't anything else
I could imagine doing; this is clearly just debugger-specific behavior.
llvm-svn: 135051
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index fa8721c..22185ed 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -9552,9 +9552,6 @@
}
ExprResult RebuildUnknownAnyExpr::VisitObjCMessageExpr(ObjCMessageExpr *msg) {
- ObjCMethodDecl *method = msg->getMethodDecl();
- assert(method && "__unknown_anytype message without result type?");
-
// Verify that this is a legal result type of a call.
if (DestType->isArrayType() || DestType->isFunctionType()) {
S.Diag(msg->getExprLoc(), diag::err_func_returning_array_function)
@@ -9562,8 +9559,11 @@
return ExprError();
}
- assert(method->getResultType() == S.Context.UnknownAnyTy);
- method->setResultType(DestType);
+ // Rewrite the method result type if available.
+ if (ObjCMethodDecl *method = msg->getMethodDecl()) {
+ assert(method->getResultType() == S.Context.UnknownAnyTy);
+ method->setResultType(DestType);
+ }
// Change the type of the message.
msg->setType(DestType.getNonReferenceType());