summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclObjC.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix Clang-tidy modernize-use-nullptr warnings in source directories; other ↵Hans Wennborg2015-10-061-12/+9
| | | | | | | | | | minor cleanups Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13406 llvm-svn: 249484
* Forbid qualifiers on ObjC generic parameters and arguments, butJohn McCall2015-09-231-13/+37
| | | | | | | | | | | | | | silently ignore them on arguments when they're provided indirectly (.e.g behind a template argument or typedef). This is mostly just good language design --- specifying that a generic argument is __weak doesn't actually do anything --- but it also prevents assertions when trying to apply a different ownership qualifier. rdar://21612439 llvm-svn: 248436
* Move class into an anonymous namespace. NFC.Benjamin Kramer2015-07-131-0/+2
| | | | llvm-svn: 242064
* SemaDeclObjC.cpp: Escape \@ in comment lines. [-Wdocumentation]NAKAMURA Takumi2015-07-081-2/+2
| | | | llvm-svn: 241664
* Implement variance for Objective-C type parameters.Douglas Gregor2015-07-071-3/+68
| | | | | | | | | | | | | | | Introduce co- and contra-variance for Objective-C type parameters, which allows us to express that (for example) an NSArray is covariant in its type parameter. This means that NSArray<NSMutableString *> * is a subtype of NSArray<NSString *> *, which is expected of the immutable Foundation collections. Type parameters can be annotated with __covariant or __contravariant to make them co- or contra-variant, respectively. This feature can be detected by __has_feature(objc_generics_variance). Implements rdar://problem/20217490. llvm-svn: 241549
* Warn when an intended Objective-C specialization was actually a useless ↵Douglas Gregor2015-07-071-0/+63
| | | | | | | | | | | | | | | | | | | | | | protocol qualification. Warn in cases where one has provided redundant protocol qualification that might be a typo for a specialization, e.g., NSArray<NSObject>, which is pointless (NSArray declares that it conforms to NSObject) and is likely to be a typo for NSArray<NSObject *>, i.e., an array of NSObject pointers. This warning is very narrow, only applying when the base type being qualified is parameterized, has the same number of parameters as their are protocols listed, all of the names can also refer to types (including Objective-C class types, of course), and at least one of those types is an Objective-C class (making this a typo for a missing '*'). The limitations are partly for performance reasons (we don't want to do redundant name lookup unless we really need to), and because we want the warning to apply in very limited cases to limit false positives. Part of rdar://problem/6294649. llvm-svn: 241547
* C++ support for Objective-C lightweight generics.Douglas Gregor2015-07-071-36/+36
| | | | | | | | | | | | | | | | | | | Teach C++'s tentative parsing to handle specializations of Objective-C class types (e.g., NSArray<NSString *>) as well as Objective-C protocol qualifiers (id<NSCopying>) by extending type-annotation tokens to handle this case. As part of this, remove Objective-C protocol qualifiers from the declaration specifiers, which never really made sense: instead, provide Sema entry points to make them part of the type annotation token. Among other things, this properly diagnoses bogus types such as "<NSCopying> id" which should have been written as "id <NSCopying>". Implements template instantiation support for, e.g., NSArray<T>* in C++. Note that parameterized classes are not templates in the C++ sense, so that cannot (for example) be used as a template argument for a template template parameter. Part of rdar://problem/6294649. llvm-svn: 241545
* Substitute type arguments into uses of Objective-C interface members.Douglas Gregor2015-07-071-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When messaging a method that was defined in an Objective-C class (or category or extension thereof) that has type parameters, substitute the type arguments for those type parameters. Similarly, substitute into property accesses, instance variables, and other references. This includes general infrastructure for substituting the type arguments associated with an ObjCObject(Pointer)Type into a type referenced within a particular context, handling all of the substitutions required to deal with (e.g.) inheritance involving parameterized classes. In cases where no type arguments are available (e.g., because we're messaging via some unspecialized type, id, etc.), we substitute in the type bounds for the type parameters instead. Example: @interface NSSet<T : id<NSCopying>> : NSObject <NSCopying> - (T)firstObject; @end void f(NSSet<NSString *> *stringSet, NSSet *anySet) { [stringSet firstObject]; // produces NSString* [anySet firstObject]; // produces id<NSCopying> (the bound) } When substituting for the type parameters given an unspecialized context (i.e., no specific type arguments were given), substituting the type bounds unconditionally produces type signatures that are too strong compared to the pre-generics signatures. Instead, use the following rule: - In covariant positions, such as method return types, replace type parameters with “id” or “Class” (the latter only when the type parameter bound is “Class” or qualified class, e.g, “Class<NSCopying>”) - In other positions (e.g., parameter types), replace type parameters with their type bounds. - When a specialized Objective-C object or object pointer type contains a type parameter in its type arguments (e.g., NSArray<T>*, but not NSArray<NSString *> *), replace the entire object/object pointer type with its unspecialized version (e.g., NSArray *). llvm-svn: 241543
* Handle Objective-C type arguments.Douglas Gregor2015-07-071-81/+468
| | | | | | | | | | | | | | | | | | | | | Objective-C type arguments can be provided in angle brackets following an Objective-C interface type. Syntactically, this is the same position as one would provide protocol qualifiers (e.g., id<NSCopying>), so parse both together and let Sema sort out the ambiguous cases. This applies both when parsing types and when parsing the superclass of an Objective-C class, which can now be a specialized type (e.g., NSMutableArray<T> inherits from NSArray<T>). Check Objective-C type arguments against the type parameters of the corresponding class. Verify the length of the type argument list and that each type argument satisfies the corresponding bound. Specializations of parameterized Objective-C classes are represented in the type system as distinct types. Both specialized types (e.g., NSArray<NSString *> *) and unspecialized types (NSArray *) are represented, separately. llvm-svn: 241542
* Parsing, semantic analysis, and AST for Objective-C type parameters.Douglas Gregor2015-07-071-7/+301
| | | | | | | | | | | | | | | | | | | | Produce type parameter declarations for Objective-C type parameters, and attach lists of type parameters to Objective-C classes, categories, forward declarations, and extensions as appropriate. Perform semantic analysis of type bounds for type parameters, both in isolation and across classes/categories/extensions to ensure consistency. Also handle (de-)serialization of Objective-C type parameter lists, along with sundry other things one must do to add a new declaration to Clang. Note that Objective-C type parameters are typedef name declarations, like typedefs and C++11 type aliases, in support of type erasure. Part of rdar://problem/6294649. llvm-svn: 241541
* Replace __double_underscored type nullability qualifiers with ↵Douglas Gregor2015-06-241-17/+23
| | | | | | | | | | | | | | | | _Uppercase_underscored Addresses a conflict with glibc's __nonnull macro by renaming the type nullability qualifiers as follows: __nonnull -> _Nonnull __nullable -> _Nullable __null_unspecified -> _Null_unspecified This is the major part of rdar://problem/21530726, but does not yet provide the Darwin-specific behavior for the old names. llvm-svn: 240596
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-3/+3
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-3/+3
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* SemaDeclObjC.cpp: Escape '@' in the comment. [-Wdocumentation]NAKAMURA Takumi2015-06-201-1/+1
| | | | llvm-svn: 240209
* Implement the 'null_resettable' attribute for Objective-C properties.Douglas Gregor2015-06-191-0/+3
| | | | | | | | 'null_resettable' properties are those whose getters return nonnull but whose setters take nil, to "reset" the property to some default. Implements rdar://problem/19051334. llvm-svn: 240155
* Extend type nullability qualifiers for Objective-C.Douglas Gregor2015-06-191-23/+142
| | | | | | | | | | | | | | | Introduce context-sensitive, non-underscored nullability specifiers (nonnull, nullable, null_unspecified) for Objective-C method return types, method parameter types, and properties. Introduce Objective-C-specific semantics, including computation of the nullability of the result of a message send, merging of nullability information from the @interface of a class into its @implementation, etc . This is the Objective-C part of rdar://problem/18868820. llvm-svn: 240154
* Fix PR22047: ObjC: Method unavailability attribute doesn't work with ↵Jonathan Roelofs2015-04-281-6/+6
| | | | | | | | overloaded methods http://reviews.llvm.org/D9261 llvm-svn: 236006
* [Sema] Check availability of ObjC super class and protocols of a containerArgyrios Kyrtzidis2015-04-191-4/+29
| | | | | | | | | | | in the context of the container itself. Otherwise we will emit 'unavailable' errors when referencing an unavailable super class even though the subclass is also marked 'unavailable'. rdar://20598702 llvm-svn: 235276
* [Objective-C Sema] patch to introduce IndependentClassFariborz Jahanian2015-04-161-2/+3
| | | | | | | | | attribute to be placed on Objective-C pointer typedef to make them strong enough so on their "new" method family no attempt is made to override these types. rdar://20255473 llvm-svn: 235128
* [Objective-C Sema]This patch fixes the warning when clang issuesFariborz Jahanian2015-04-151-28/+33
| | | | | | | | | | "multiple methods named '<selector>' found" warning by noting the method that is actualy used. It also cleans up and refactors code in this area and selects a method that matches actual arguments in case of receiver being a forward class object. rdar://19265430 llvm-svn: 235023
* Reduce dyn_cast<> to isa<> or cast<> where possible. Clang edition.Benjamin Kramer2015-04-101-3/+2
| | | | | | No functional change intended. llvm-svn: 234587
* [Objective-C Sema] Patch to not issue unavailbility/deprecatedFariborz Jahanian2015-04-071-1/+7
| | | | | | | | warning when multiple method declarations are found in global pool with differing types and some are available. rdar://20408445 llvm-svn: 234328
* [Modules] Make Sema's map of referenced selectors have a deterministicChandler Carruth2015-03-271-5/+4
| | | | | | | | | | | order based on order of insertion. This should cause both our warnings about these and the modules serialization to be deterministic as a consequence. Found by inspection. llvm-svn: 233343
* revert r231700 (designated initializer patch) which brokeFariborz Jahanian2015-03-111-3/+2
| | | | | | several projects. rdar://20120666. llvm-svn: 231939
* [PATCH Sema Objective-C]. Patch to warn on missing designated initializerFariborz Jahanian2015-03-091-2/+3
| | | | | | | override where at least a declaration of a designated initializer is in a super class and not necessarily in the current class. rdar://19653785. llvm-svn: 231700
* [Objective-C Sema]. Don't warn about use of Fariborz Jahanian2015-02-191-2/+6
| | | | | | | property accessors in @selector not implemented because they will be auto-synthesized. rdar://16607480 llvm-svn: 229919
* Prefer SmallVector::append/insert over push_back loops. Clang edition.Benjamin Kramer2015-02-171-2/+1
| | | | | | Same functionality, but hoists the vector growth out of the loop. llvm-svn: 229508
* Objective-C: Tweak unavailability warning.Nico Weber2014-12-271-1/+1
| | | | | | | Don't warn when a selector has an unavailable and an available variant, and the first also has an implementation. llvm-svn: 224881
* Address review feedback on r221933.Nico Weber2014-12-271-56/+62
| | | | | | | | | | | Remove ObjCMethodList::Count, instead store a "has more than one decl" bit in the low bit of the ObjCMethodDecl pointer, using a PointerIntPair. Most of this patch is replacing ".Method" with ".getMethod()". No intended behavior change. llvm-svn: 224876
* Update for LLVM API change to make Small(Ptr)Set::insert return ↵David Blaikie2014-11-191-2/+2
| | | | | | pair<iterator, bool> as per the C++ standard's associative container concept. llvm-svn: 222335
* Objective-C. Fixes a regression caused by implementationFariborz Jahanian2014-11-131-2/+15
| | | | | | | | of new warning for deprecated method call for receiver of type 'id'. This addresses rdar://18960378 where unintended warnings being issued. llvm-svn: 221933
* Pass around CorrectionCandidateCallbacks as unique_ptrs soKaelyn Takata2014-10-271-11/+10
| | | | | | TypoCorrectionConsumer can keep the callback around as long as needed. llvm-svn: 220693
* Objective-C. Warn if user has made explicit callFariborz Jahanian2014-08-221-0/+4
| | | | | | | to +initilize as this results in an extra call to this method. rdar://16628028 llvm-svn: 216271
* Objective-C. This patch is to resolve the method used in methodFariborz Jahanian2014-08-131-0/+17
| | | | | | | expression to the best method found in global method pools. This is wip. // rdar://16808765 llvm-svn: 215577
* Replacing some more complex logic with a helper function call to ↵Aaron Ballman2014-08-011-12/+6
| | | | | | ObjCMethod::getReturnTypeSourceRange. No functional changes intended. llvm-svn: 214511
* MS ABI: Consider alignment attributes on typedefs for layoutDavid Majnemer2014-07-301-2/+13
| | | | | | | | | | | | | | | | | | | The MS ABI has a notion of 'required alignment' for fields; this alignment supercedes pragma pack directives. MSVC takes into account alignment attributes on typedefs when determining whether or not a field has a certain required alignment. Do the same in clang by tracking whether or not we saw such an attribute when calculating the type's bitwidth and alignment. This fixes PR20418. Reviewers: rnk Differential Revision: http://reviews.llvm.org/D4714 llvm-svn: 214274
* Hide the concept of diagnostic levels from lex, parse and semaAlp Toker2014-06-151-9/+5
| | | | | | | | | | | | | | | | The compilation pipeline doesn't actually need to know about the high-level concept of diagnostic mappings, and hiding the final computed level presents several simplifications and other potential benefits. The only exceptions are opportunistic checks to see whether expensive code paths can be avoided for diagnostics that are guaranteed to be ignored at a certain SourceLocation. This commit formalizes that invariant by introducing and using DiagnosticsEngine::isIgnored() in place of individual level checks throughout lex, parse and sema. llvm-svn: 211005
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-51/+53
| | | | llvm-svn: 209613
* Fix a bunch of mislayered clang/Lex includes from SemaAlp Toker2014-05-031-2/+1
| | | | llvm-svn: 207896
* Initial implementation of -modules-earch-all option, for searching for ↵John Thompson2014-04-231-3/+4
| | | | | | symbols in non-imported modules. llvm-svn: 206977
* Objective-C. Fixes a bogus warning on unimplementedFariborz Jahanian2014-03-261-5/+9
| | | | | | | | selectors because we were not going through entire elements in list of all implemented selectors. // rdar://16428638 llvm-svn: 204852
* Objective-C. Better fix for my previous patch Fariborz Jahanian2014-03-181-12/+7
| | | | | | | | | "No need to issue deprecated warning if deprecated method in class extension is being implemented in primary class implementation (no overriding is involved). // rdar://16249335". No functionality change. llvm-svn: 204159
* Objective-C. No need to issue deprecated warning if deprecated method Fariborz Jahanian2014-03-181-2/+12
| | | | | | | | in class extension is being implemented in primary class implementation (no overriding is involved). // rdar://16249335 llvm-svn: 204093
* Objective-C. Do not warn when an instance method andFariborz Jahanian2014-03-171-1/+3
| | | | | | | | class method with the same selctor but different argument types having one of them in class extension. // rdar://16312105 llvm-svn: 204065
* [C++11] Replacing ObjCObjectType iterators qual_begin() and qual_end() with ↵Aaron Ballman2014-03-171-3/+2
| | | | | | iterator_range quals(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 204047
* Objective-C. Redo turning off designated initialization warnings onFariborz Jahanian2014-03-141-5/+2
| | | | | | | | 'init' methods which are unavailable. Subclasses of NSObject have to implement such methods as a common pattern to prevent user's own implementation. // rdar://16305460 llvm-svn: 203984
* Objective-C. Turn off designated initialization warnings onFariborz Jahanian2014-03-141-2/+5
| | | | | | | | 'init' methods which are unavailable. Subclasses of NSObject have to implement such methods as a common pattern to prevent user's own implementation. // rdar://16305460 llvm-svn: 203966
* [C++11] Replacing ObjCCategoryDecl iterators protocol_begin() and ↵Aaron Ballman2014-03-141-3/+2
| | | | | | protocol_end() with iterator_range protocols(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203922
* [C++11] Replacing ObjCProtocolDecl iterators protocol_begin() and ↵Aaron Ballman2014-03-131-13/+9
| | | | | | protocol_end() with iterator_range protocols(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203863
* [C++11] Replacing ObjCInterfaceDecl iterators visible_extensions_begin() and ↵Aaron Ballman2014-03-131-27/+8
| | | | | | visible_extensions_end() with iterator_range visible_extensions(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203855
OpenPOWER on IntegriCloud