[PATCH] D23078: ObjC: Use a new type for ObjC type parameter (Patch 1 out of 3)

Manman Ren via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 2 12:44:16 PDT 2016


manmanren created this revision.
manmanren added reviewers: dexonsmith, doug.gregor.
manmanren added a subscriber: cfe-commits.

For ObjC type parameter, we used to have TypedefType that is canonicalized to
id or the bound type. We can't represent "T <protocol>" and thus will lose
the type information in the following example:
@interface MyMutableDictionary<KeyType, ObjectType> : NSObject
- (void)setObject:(ObjectType)obj forKeyedSubscript:(KeyType <NSCopying>)key;
@end
MyMutableDictionary<NSString *, NSString *> *stringsByString;
NSNumber *n1, *n2;
stringsByString[n1] = n2;
--> no warning on type mismatch of the key.

To fix the problem, we introduce a new type ObjCTypeParamType that supports
a list of protocol qualifiers.

This is the first patch:
[NFC] Add a class ObjCProtocolQualifiers to wrap APIs for ObjC protocol list.
This will be shared between ObjCObjectType and ObjCTypeParamType.

https://reviews.llvm.org/D23078

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23078.66526.patch
Type: text/x-patch
Size: 6460 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160802/a92e572a/attachment.bin>


More information about the cfe-commits mailing list