[cfe-commits] r152420 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaObjC/debugger-cast-result-to-id.m test/SemaObjCXX/debugger-cast-result-to-id.mm
Fariborz Jahanian
fjahanian at apple.com
Fri Mar 9 10:47:16 PST 2012
Author: fjahanian
Date: Fri Mar 9 12:47:16 2012
New Revision: 152420
URL: http://llvm.org/viewvc/llvm-project?rev=152420&view=rev
Log:
lldb support: under debugger support flag, when sending message
to forward class, and assigning to an 'id' type var, message
sends default to 'id'. // rdar"//10988847
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaObjC/debugger-cast-result-to-id.m
cfe/trunk/test/SemaObjCXX/debugger-cast-result-to-id.mm
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=152420&r1=152419&r2=152420&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Mar 9 12:47:16 2012
@@ -6209,6 +6209,18 @@
// Get the decls type and save a reference for later, since
// CheckInitializerTypes may change it.
QualType DclT = VDecl->getType(), SavT = DclT;
+
+ // Top-level message sends default to 'id' when we're in a debugger
+ // and we are assigning it to a variable of 'id' type.
+ if (getLangOptions().DebuggerCastResultToId && DclT->isObjCIdType())
+ if (Init->getType() == Context.UnknownAnyTy && isa<ObjCMessageExpr>(Init)) {
+ ExprResult Result = forceUnknownAnyToType(Init, Context.getObjCIdType());
+ if (Result.isInvalid()) {
+ VDecl->setInvalidDecl();
+ return;
+ }
+ Init = Result.take();
+ }
// Perform the initialization.
if (!VDecl->isInvalidDecl()) {
Modified: cfe/trunk/test/SemaObjC/debugger-cast-result-to-id.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/debugger-cast-result-to-id.m?rev=152420&r1=152419&r2=152420&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/debugger-cast-result-to-id.m (original)
+++ cfe/trunk/test/SemaObjC/debugger-cast-result-to-id.m Fri Mar 9 12:47:16 2012
@@ -7,3 +7,10 @@
(void)(int)[[test0 unknownMethod] otherUnknownMethod];;
(void)(id)[[test1() unknownMethod] otherUnknownMethod];
}
+
+// rdar://10988847
+ at class NSString; // expected-note {{forward declaration of class here}}
+
+void rdar10988847() {
+ id s = [NSString stringWithUTF8String:"foo"]; // expected-warning {{receiver 'NSString' is a forward class and corresponding @interface may not exist}}
+}
Modified: cfe/trunk/test/SemaObjCXX/debugger-cast-result-to-id.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/debugger-cast-result-to-id.mm?rev=152420&r1=152419&r2=152420&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/debugger-cast-result-to-id.mm (original)
+++ cfe/trunk/test/SemaObjCXX/debugger-cast-result-to-id.mm Fri Mar 9 12:47:16 2012
@@ -7,3 +7,11 @@
[x foo];
}
}
+
+// rdar://10988847
+ at class NSString; // expected-note {{forward declaration of class here}}
+namespace test1 {
+ void rdar10988847() {
+ id s = [NSString stringWithUTF8String:"foo"]; // expected-warning {{receiver 'NSString' is a forward class and corresponding @interface may not exist}}
+ }
+}
More information about the cfe-commits
mailing list