From: Douglas Gregor Date: Thu, 15 Dec 2011 00:53:32 +0000 (+0000) Subject: In debugger support mode, if we have a top-level message send X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5e3a8bea1cb3a8508a99982278934df32ccc7387;p=clang In debugger support mode, if we have a top-level message send expression with an unknown result type, assume that the result type is 'id'. Fixes . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146622 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 59369d603d..e7e6b892e5 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -4674,6 +4674,15 @@ ExprResult Sema::ActOnFinishFullExpr(Expr *FE) { if (DiagnoseUnexpandedParameterPack(FullExpr.get())) return ExprError(); + // Top-level message sends default to 'id' when we're in a debugger. + if (getLangOptions().DebuggerSupport && + FullExpr.get()->getType() == Context.UnknownAnyTy && + isa(FullExpr.get())) { + FullExpr = forceUnknownAnyToType(FullExpr.take(), Context.getObjCIdType()); + if (FullExpr.isInvalid()) + return ExprError(); + } + FullExpr = CheckPlaceholderExpr(FullExpr.take()); if (FullExpr.isInvalid()) return ExprError(); diff --git a/test/SemaObjC/unknown-anytype.m b/test/SemaObjC/unknown-anytype.m index 48eb91ae23..89e45e4a13 100644 --- a/test/SemaObjC/unknown-anytype.m +++ b/test/SemaObjC/unknown-anytype.m @@ -17,8 +17,13 @@ void test_unknown_anytype_receiver() { int *ip = [test0 getIntPtr]; float *fp = [test1() getFloatPtr]; double *dp = [test1() getSomePtr]; // okay: picks first method found - [[test0 unknownMethod] otherUnknownMethod]; // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}} + [[test0 unknownMethod] otherUnknownMethod]; (void)(int)[[test0 unknownMethod] otherUnknownMethod];; - [[test1() unknownMethod] otherUnknownMethod]; // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}} + [[test1() unknownMethod] otherUnknownMethod]; (void)(id)[[test1() unknownMethod] otherUnknownMethod]; + + if ([[test0 unknownMethod] otherUnknownMethod]) { // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}} + } + if ([[test1() unknownMethod] otherUnknownMethod]) { // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}} + } } diff --git a/test/SemaObjCXX/unknown-anytype.mm b/test/SemaObjCXX/unknown-anytype.mm index 163dddee70..40954c85eb 100644 --- a/test/SemaObjCXX/unknown-anytype.mm +++ b/test/SemaObjCXX/unknown-anytype.mm @@ -3,6 +3,7 @@ // rdar://problem/9416370 namespace test0 { void test(id x) { - [x foo]; // expected-error {{no known method '-foo'; cast the message send to the method's return type}} + if ([x foo]) {} // expected-error {{no known method '-foo'; cast the message send to the method's return type}} + [x foo]; } }