[cfe-commits] r102223 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExprObjC.cpp

Fariborz Jahanian fjahanian at apple.com
Fri Apr 23 16:19:04 PDT 2010


Author: fjahanian
Date: Fri Apr 23 18:19:04 2010
New Revision: 102223

URL: http://llvm.org/viewvc/llvm-project?rev=102223&view=rev
Log:
With -fno-constant-cfstrrings, class NSConstantString
must be there or it is error (Next runtime).


Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaExprObjC.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=102223&r1=102222&r2=102223&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Apr 23 18:19:04 2010
@@ -238,6 +238,8 @@
   "duplicate interface definition for class %0">;
 def err_undef_superclass : Error<
   "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<
   "trying to recursively use %0 as superclass of %1">;
 def warn_previous_alias_decl : Warning<"previously declared alias is ignored">;

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=102223&r1=102222&r2=102223&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Fri Apr 23 18:19:04 2010
@@ -78,6 +78,21 @@
   QualType Ty = Context.getObjCConstantStringInterface();
   if (!Ty.isNull()) {
     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 {
     IdentifierInfo *NSIdent = &Context.Idents.get("NSString");
     NamedDecl *IF = LookupSingleName(TUScope, NSIdent, AtLocs[0],





More information about the cfe-commits mailing list