With -fno-constant-cfstrrings, class NSConstantString

must be there or it is error (Next runtime).

llvm-svn: 102223
This commit is contained in:
Fariborz Jahanian 2010-04-23 23:19:04 +00:00
parent e11ee11068
commit 0731763efc
2 changed files with 17 additions and 0 deletions

View File

@ -238,6 +238,8 @@ def err_duplicate_class_def : Error<
"duplicate interface definition for class %0">; "duplicate interface definition for class %0">;
def err_undef_superclass : Error< def err_undef_superclass : Error<
"cannot find interface declaration for %0, superclass of %1">; "cannot find interface declaration for %0, superclass of %1">;
def err_no_nsconstant_string_class : Error<
"cannot find interface declaration for %0">;
def err_recursive_superclass : Error< def err_recursive_superclass : Error<
"trying to recursively use %0 as superclass of %1">; "trying to recursively use %0 as superclass of %1">;
def warn_previous_alias_decl : Warning<"previously declared alias is ignored">; def warn_previous_alias_decl : Warning<"previously declared alias is ignored">;

View File

@ -78,6 +78,21 @@ Sema::ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs,
QualType Ty = Context.getObjCConstantStringInterface(); QualType Ty = Context.getObjCConstantStringInterface();
if (!Ty.isNull()) { if (!Ty.isNull()) {
Ty = Context.getObjCObjectPointerType(Ty); Ty = Context.getObjCObjectPointerType(Ty);
} else if (getLangOptions().NoConstantCFStrings) {
IdentifierInfo *NSIdent = &Context.Idents.get("NSConstantString");
NamedDecl *IF = LookupSingleName(TUScope, NSIdent, AtLocs[0],
LookupOrdinaryName);
if (ObjCInterfaceDecl *StrIF = dyn_cast_or_null<ObjCInterfaceDecl>(IF)) {
Context.setObjCConstantStringInterface(StrIF);
Ty = Context.getObjCConstantStringInterface();
Ty = Context.getObjCObjectPointerType(Ty);
} else {
// If there is no NSConstantString interface defined then treat this
// as error and recover from it.
Diag(S->getLocStart(), diag::err_no_nsconstant_string_class) << NSIdent
<< S->getSourceRange();
Ty = Context.getObjCIdType();
}
} else { } else {
IdentifierInfo *NSIdent = &Context.Idents.get("NSString"); IdentifierInfo *NSIdent = &Context.Idents.get("NSString");
NamedDecl *IF = LookupSingleName(TUScope, NSIdent, AtLocs[0], NamedDecl *IF = LookupSingleName(TUScope, NSIdent, AtLocs[0],