summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprObjC.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-06-21 21:44:18 +0000
committerChris Lattner <sabre@nondot.org>2008-06-21 21:44:18 +0000
commit091f698d29ff1262fcd2c39eafec70e3ba2711a5 (patch)
tree1f94845500c0ba42733478ad99c053b33fdf323d /clang/lib/Sema/SemaExprObjC.cpp
parent0f2b47173088cb17b793fd0f6b427e69dbe067a9 (diff)
downloadbcm5719-llvm-091f698d29ff1262fcd2c39eafec70e3ba2711a5.tar.gz
bcm5719-llvm-091f698d29ff1262fcd2c39eafec70e3ba2711a5.zip
"this patch adds code generation hooks for Objective-C constant strings. It also modifies Sema so that Objective-C constant strings are treated as untyped objects if the interface for the constant string class can not be found. This is consistent with Apple GCC. I thought it was consistent with GNU GCC, since this was causing failures when trying to compile GNUstep with (GNU) GCC, but it appears that this is not the case when attempting to produce a simple test case to demonstrate it. Possibly there is a way of making the error go away, but I haven't found out what it is yet."
Patch by David Chisnall! llvm-svn: 52599
Diffstat (limited to 'clang/lib/Sema/SemaExprObjC.cpp')
-rw-r--r--clang/lib/Sema/SemaExprObjC.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index 920457e00c6..1aed69ec2c5 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -54,13 +54,17 @@ Sema::ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs,
IdentifierInfo *NSIdent = &Context.Idents.get("NSConstantString");
Decl *IFace = LookupDecl(NSIdent, Decl::IDNS_Ordinary, TUScope);
ObjCInterfaceDecl *strIFace = dyn_cast_or_null<ObjCInterfaceDecl>(IFace);
- if (!strIFace)
- return Diag(S->getLocStart(), diag::err_undef_interface,
- NSIdent->getName());
- Context.setObjCConstantStringInterface(strIFace);
+ if (strIFace)
+ Context.setObjCConstantStringInterface(strIFace);
}
QualType t = Context.getObjCConstantStringInterface();
- t = Context.getPointerType(t);
+ // If there is no NSConstantString interface defined then treat constant
+ // strings as untyped objects and let the runtime figure it out later.
+ if (t == QualType()) {
+ t = Context.getObjCIdType();
+ } else {
+ t = Context.getPointerType(t);
+ }
return new ObjCStringLiteral(S, t, AtLoc);
}
@@ -298,9 +302,9 @@ Sema::ExprResult Sema::ActOnInstanceMessage(
else {
ObjCInterfaceType *OCIReceiver =dyn_cast<ObjCInterfaceType>(receiverType);
if (OCIReceiver == 0) {
- Diag(lbrac, diag::error_bad_receiver_type,
- RExpr->getType().getAsString());
- return true;
+ Diag(lbrac, diag::error_bad_receiver_type,
+ RExpr->getType().getAsString());
+ return true;
}
ClassDecl = OCIReceiver->getDecl();
// FIXME: consider using InstanceMethodPool, since it will be faster
OpenPOWER on IntegriCloud