[cfe-commits] r68514 - in /cfe/trunk: lib/Sema/SemaExprObjC.cpp test/SemaObjC/objc-string-constant.m

Steve Naroff snaroff at apple.com
Tue Apr 7 07:18:46 PDT 2009


Author: snaroff
Date: Tue Apr  7 09:18:33 2009
New Revision: 68514

URL: http://llvm.org/viewvc/llvm-project?rev=68514&view=rev
Log:
Change the type of ObjC @ string constants (from NSConstantString->NSString).

This fixes <rdar://problem/6757102> clang type for @"xxx" is "NSConstantString *" (GCC type is "NSString *").

Added:
    cfe/trunk/test/SemaObjC/objc-string-constant.m
Modified:
    cfe/trunk/lib/Sema/SemaExprObjC.cpp

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=68514&r1=68513&r2=68514&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Tue Apr  7 09:18:33 2009
@@ -69,19 +69,21 @@
     return true;
 
   // Initialize the constant string interface lazily. This assumes
-  // the NSConstantString interface is seen in this translation unit.
+  // the NSString interface is seen in this translation unit. Note: We
+  // don't use NSConstantString, since the runtime team considers this
+  // interface private (even though it appears in the header files).
   QualType Ty = Context.getObjCConstantStringInterface();
   if (!Ty.isNull()) {
     Ty = Context.getPointerType(Ty);
   } else {
-    IdentifierInfo *NSIdent = &Context.Idents.get("NSConstantString");
+    IdentifierInfo *NSIdent = &Context.Idents.get("NSString");
     NamedDecl *IF = LookupName(TUScope, NSIdent, LookupOrdinaryName);
     if (ObjCInterfaceDecl *StrIF = dyn_cast_or_null<ObjCInterfaceDecl>(IF)) {
       Context.setObjCConstantStringInterface(StrIF);
       Ty = Context.getObjCConstantStringInterface();
       Ty = Context.getPointerType(Ty);
     } else {
-      // If there is no NSConstantString interface defined then treat constant
+      // If there is no NSString interface defined then treat constant
       // strings as untyped objects and let the runtime figure it out later.
       Ty = Context.getObjCIdType();
     }

Added: cfe/trunk/test/SemaObjC/objc-string-constant.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objc-string-constant.m?rev=68514&view=auto

==============================================================================
--- cfe/trunk/test/SemaObjC/objc-string-constant.m (added)
+++ cfe/trunk/test/SemaObjC/objc-string-constant.m Tue Apr  7 09:18:33 2009
@@ -0,0 +1,39 @@
+// RUN: clang-cc %s -verify -fsyntax-only &&
+
+#define nil 0       /* id of Nil instance */
+
+ at interface NSObject 
+ at end
+
+ at interface NSString : NSObject
+
+ at end
+
+ at interface NSMutableString : NSString
+
+ at end
+
+ at interface NSSimpleCString : NSString {
+ at protected
+    char *bytes;
+    int numBytes;
+}
+ at end
+
+ at interface NSConstantString : NSSimpleCString
+ at end
+
+
+ at interface Subclass : NSObject 
+- (NSString *)token;
+ at end
+
+ at implementation Subclass
+- (NSString *)token;
+{
+  NSMutableString *result = nil;
+
+  return (result != nil) ? result : @"";
+}
+ at end
+





More information about the cfe-commits mailing list