summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaObjC/kindof.m
Commit message (Collapse)AuthorAgeFilesLines
* [ObjC generics] Fix applying `__kindof` to the type parameter.Volodymyr Sapsai2019-02-161-0/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes the warning about incompatible pointer types on assigning to a subclass of type argument an expression of type `__kindof TypeParam`. We already have a mechanism in `ASTContext::canAssignObjCInterfaces` that handles `ObjCObjectType` with `__kindof`. But it wasn't triggered because during type substitution `__kindof TypeParam` was represented as `AttributedType` with attribute `ObjCKindOf` and equivalent type `TypeArg`. For assignment type checking we use canonical types so attributed type was desugared and the attribute was ignored. The fix is in checking transformed `AttributedType` and pushing `__kindof` down into `ObjCObjectType` when necessary. rdar://problem/38514910 Reviewers: ahatanak, erik.pilkington, doug.gregor Reviewed By: doug.gregor Subscribers: jkorous, dexonsmith, manmanren, jordan_rose, doug.gregor, cfe-commits Differential Revision: https://reviews.llvm.org/D57076 llvm-svn: 354189
* ObjectiveC Generics: Start using ObjCTypeParamType.Manman Ren2016-09-131-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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. We create ObjCTypeParamType for ObjCTypeParamDecl when we create ObjCTypeParamDecl. We also substitute ObjCTypeParamType instead of TypedefType on an ObjCTypeParamDecl. rdar://24619481 rdar://25060179 Differential Revision: http://reviews.llvm.org/D23080 llvm-svn: 281358
* ObjectiveC: canonicalize "kindof id" to "id".Manman Ren2016-05-201-1/+22
| | | | | | | | There is no need to apply kindof on an unqualified id type. rdar://24753825 llvm-svn: 270241
* ObjC kindof: set the type of a conditional expression when involving kindof.Manman Ren2016-05-061-1/+33
| | | | | | | | When either LHS or RHS is a kindof type, we return a kindof type. rdar://problem/20513780 llvm-svn: 268781
* ObjC kindof: order the methods in global pool relative to availability.Manman Ren2016-04-131-0/+13
| | | | | | | | | | | | | | r265877 tries to put methods that are deprecated or unavailable to the front of the global pool to emit diagnostics, but it breaks some of our existing codes that depend on choosing a certain method for id lookup. This commit orders the methods with the same declaration with respect to the availability, but do not order methods with different declaration. rdar://25707511 llvm-svn: 266264
* ObjC kindof: check the context when inserting methods to global pool.Manman Ren2016-04-091-0/+14
| | | | | | | | | | | | | | | | To make kindof lookup work, we need to insert methods with different context into the global pool, even though they have the same siganture. Since diagnosis of availability is performed on the best candidate, which is often the first candidate from the global pool, we prioritize the methods that are unavaible or deprecated to the head of the list. Since we now have more methods in the global pool, we need to watch out for performance impact. rdar://25635831 llvm-svn: 265877
* [ObjC kindof] Use type bound to filter out the candidate methods.Manman Ren2016-04-071-2/+14
| | | | | | rdar://21306753 llvm-svn: 265712
* [Objective-c] Fix a crash that occurs when ObjCTypeParamList::back() isAkira Hatanaka2015-12-161-0/+16
| | | | | | | | | | | | | | called on an empty list. This commit makes Parser::parseObjCTypeParamListOrProtocolRefs return nullptr if it sees an invalid type parameter (e.g., __kindof) in the type parameter list. rdar://problem/23068920 Differential Revision: http://reviews.llvm.org/D15463 llvm-svn: 255754
* s/__nonnull/_Nonnull in a test for Objective-C __kindof.Douglas Gregor2015-07-071-1/+1
| | | | llvm-svn: 241563
* Implement the Objective-C __kindof type qualifier.Douglas Gregor2015-07-071-0/+304
The __kindof type qualifier can be applied to Objective-C object (pointer) types to indicate id-like behavior, which includes implicit "downcasting" of __kindof types to subclasses and id-like message-send behavior. __kindof types provide better type bounds for substitutions into unspecified generic types, which preserves more type information. llvm-svn: 241548
OpenPOWER on IntegriCloud