Clang has existing support for debuggers that
want to provide "po"-like functionality which
treats the result of an expression implicitly as
"id" (if it is not otherwise known) and prints
it as an Objective-C object.
This has in the past been gated by the
"DebuggerSupport" language option, but that is
too general. Debuggers also provide other commands
like "print" that do not make any assumptions
about whether the object is an Objective-C object.
This patch makes the assumption conditional on a
new language option: DebuggerCastResultToId. I
have also made corresponding modifications to the
testsuite.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149735 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaObjC/debugger-cast-result-to-id.m b/test/SemaObjC/debugger-cast-result-to-id.m
new file mode 100644
index 0000000..86f4c3a
--- /dev/null
+++ b/test/SemaObjC/debugger-cast-result-to-id.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -funknown-anytype -fsyntax-only -fdebugger-support -fdebugger-cast-result-to-id -verify %s
+
+extern __unknown_anytype test0;
+extern __unknown_anytype test1();
+
+void test_unknown_anytype_receiver() {
+ (void)(int)[[test0 unknownMethod] otherUnknownMethod];;
+ (void)(id)[[test1() unknownMethod] otherUnknownMethod];
+}
+// RUN: %clang_cc1 -funknown-anytype -fsyntax-only -fdebugger-support -fdebugger-cast-result-to-id -verify %s
+
+extern __unknown_anytype test0;
+extern __unknown_anytype test1();
+
+void test_unknown_anytype_receiver() {
+ (void)(int)[[test0 unknownMethod] otherUnknownMethod];;
+ (void)(id)[[test1() unknownMethod] otherUnknownMethod];
+}
+// RUN: %clang_cc1 -funknown-anytype -fsyntax-only -fdebugger-support -fdebugger-cast-result-to-id -verify %s
+
+extern __unknown_anytype test0;
+extern __unknown_anytype test1();
+
+void test_unknown_anytype_receiver() {
+ (void)(int)[[test0 unknownMethod] otherUnknownMethod];;
+ (void)(id)[[test1() unknownMethod] otherUnknownMethod];
+}
diff --git a/test/SemaObjC/unknown-anytype.m b/test/SemaObjC/unknown-anytype.m
index 89e45e4..38e058c 100644
--- a/test/SemaObjC/unknown-anytype.m
+++ b/test/SemaObjC/unknown-anytype.m
@@ -17,9 +17,9 @@
int *ip = [test0 getIntPtr];
float *fp = [test1() getFloatPtr];
double *dp = [test1() getSomePtr]; // okay: picks first method found
- [[test0 unknownMethod] otherUnknownMethod];
+ [[test0 unknownMethod] otherUnknownMethod]; // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}}
(void)(int)[[test0 unknownMethod] otherUnknownMethod];;
- [[test1() unknownMethod] otherUnknownMethod];
+ [[test1() unknownMethod] otherUnknownMethod]; // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}}
(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}}