diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-02-23 22:51:36 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-02-23 22:51:36 +0000 |
commit | f64bc202a2bcdf7b10f418ad52aaa7366c8ffef9 (patch) | |
tree | c62e51d37baf9aaa9b50ed0961de1bb111f4438d /lib | |
parent | 9428772f16e379bcad35254251f96e3d1077c730 (diff) |
objective-c++: Type of an objc string literal is NSString, not 'id'.
// rdar://10907410
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151296 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaExprObjC.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index e0420c1faf..ec5329c4d4 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -113,9 +113,21 @@ ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs, Ty = Context.getObjCConstantStringInterface(); Ty = Context.getObjCObjectPointerType(Ty); } else { - // 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(); + // If there is no NSString interface defined, implicitly declare + // a @class NSString; and use that instead. This is to make sure + // type of an NSString literal is represented correctly, instead of + // being an 'id' type. + Ty = Context.getObjCNSStringType(); + if (Ty.isNull()) { + ObjCInterfaceDecl *NSStringIDecl = + ObjCInterfaceDecl::Create (Context, + Context.getTranslationUnitDecl(), + SourceLocation(), NSIdent, + 0, SourceLocation()); + Ty = Context.getObjCInterfaceType(NSStringIDecl); + Context.setObjCNSStringType(Ty); + } + Ty = Context.getObjCObjectPointerType(Ty); } } |