summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-12-15 00:53:32 +0000
committerDouglas Gregor <dgregor@apple.com>2011-12-15 00:53:32 +0000
commit95715f9ecf44d99516b4beb2e51907e033f7c3d2 (patch)
tree6a7505ffaeda0511e355f2b6854d578dcd1ce2bb
parent16ad2905a359832fc238b64a9335a2d242088bd7 (diff)
downloadbcm5719-llvm-95715f9ecf44d99516b4beb2e51907e033f7c3d2.tar.gz
bcm5719-llvm-95715f9ecf44d99516b4beb2e51907e033f7c3d2.zip
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 <rdar://problem/10400663>. llvm-svn: 146622
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp9
-rw-r--r--clang/test/SemaObjC/unknown-anytype.m9
-rw-r--r--clang/test/SemaObjCXX/unknown-anytype.mm3
3 files changed, 18 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 59369d603d9..e7e6b892e52 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/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<ObjCMessageExpr>(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/clang/test/SemaObjC/unknown-anytype.m b/clang/test/SemaObjC/unknown-anytype.m
index 48eb91ae237..89e45e4a131 100644
--- a/clang/test/SemaObjC/unknown-anytype.m
+++ b/clang/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/clang/test/SemaObjCXX/unknown-anytype.mm b/clang/test/SemaObjCXX/unknown-anytype.mm
index 163dddee708..40954c85ebe 100644
--- a/clang/test/SemaObjCXX/unknown-anytype.mm
+++ b/clang/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];
}
}
OpenPOWER on IntegriCloud