[cfe-commits] r146622 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/SemaObjC/unknown-anytype.m test/SemaObjCXX/unknown-anytype.mm

Douglas Gregor dgregor at apple.com
Wed Dec 14 16:53:32 PST 2011


Author: dgregor
Date: Wed Dec 14 18:53:32 2011
New Revision: 146622

URL: http://llvm.org/viewvc/llvm-project?rev=146622&view=rev
Log:
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>.

Modified:
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/test/SemaObjC/unknown-anytype.m
    cfe/trunk/test/SemaObjCXX/unknown-anytype.mm

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=146622&r1=146621&r2=146622&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Dec 14 18:53:32 2011
@@ -4674,6 +4674,15 @@
   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();

Modified: cfe/trunk/test/SemaObjC/unknown-anytype.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/unknown-anytype.m?rev=146622&r1=146621&r2=146622&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/unknown-anytype.m (original)
+++ cfe/trunk/test/SemaObjC/unknown-anytype.m Wed Dec 14 18:53:32 2011
@@ -17,8 +17,13 @@
   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}}
+  }
 }

Modified: cfe/trunk/test/SemaObjCXX/unknown-anytype.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/unknown-anytype.mm?rev=146622&r1=146621&r2=146622&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/unknown-anytype.mm (original)
+++ cfe/trunk/test/SemaObjCXX/unknown-anytype.mm Wed Dec 14 18:53:32 2011
@@ -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];
   }
 }





More information about the cfe-commits mailing list