summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseObjc.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Objective-C properties: merge attributes when redeclaring 'readonly' as ↵Douglas Gregor2015-12-101-5/+1
| | | | | | | | | | | | | | 'readwrite' in an extension. r251874 stopped back-patching the AST when an Objective-C 'readonly' property is redeclared in a class extension as 'readwrite'. However, it did not properly handle merging of Objective-C property attributes (e.g., getter name, ownership, atomicity) to the redeclaration, leading to bad metadata. Merge (and check!) those property attributes so we get the right metadata and reasonable ASTs. Fixes rdar://problem/23823989. llvm-svn: 255309
* Minor formatting fixes. NFCCraig Topper2015-11-141-2/+1
| | | | llvm-svn: 253135
* Add support for GCC's '__auto_type' extension, per the GCC manual:Richard Smith2015-11-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | https://gcc.gnu.org/onlinedocs/gcc/Typeof.html Differences from the GCC extension: * __auto_type is also permitted in C++ (but only in places where it could appear in C), allowing its use in headers that might be shared across C and C++, or used from C++98 * __auto_type can be combined with a declarator, as with C++ auto (for instance, "__auto_type *p") * multiple variables can be declared in a single __auto_type declaration, with the C++ semantics (the deduced type must be the same in each case) This patch also adds a missing restriction on applying typeof to a bit-field, which GCC has historically rejected in C (due to lack of clarity as to whether the operand should be promoted). The same restriction also applies to __auto_type in C (in both GCC and Clang). This also fixes PR25449. Patch by Nicholas Allegra! llvm-svn: 252690
* Switch to using an explicit scope object to ensure we don't forget to pop ObjCRichard Smith2015-11-031-24/+39
| | | | | | type parameters off the scope, and fix the cases where we failed to do so. llvm-svn: 251875
* Convert ActOnForwardProtocolDeclaration to take an ArrayRef and use a ↵Craig Topper2015-10-221-4/+2
| | | | | | range-based for loop. NFC llvm-svn: 250990
* Change FindProtocolDeclaration to take an ArrayRef and use a range-based for ↵Craig Topper2015-10-221-4/+2
| | | | | | loop. NFC llvm-svn: 250988
* [modules] When we see a definition of a function for which we already have aRichard Smith2015-08-211-0/+1
| | | | | | | non-visible definition, skip the new definition to avoid ending up with a function with multiple definitions. llvm-svn: 245664
* [libclang] Implement proper code-completion in an ObjC type parameter position.Douglas Gregor2015-07-071-2/+7
| | | | | | rdar://19670303 llvm-svn: 241561
* Implement variance for Objective-C type parameters.Douglas Gregor2015-07-071-7/+35
| | | | | | | | | | | | | | | 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-3/+8
| | | | | | | | | | | | | | | | | | | | | | 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-91/+198
| | | | | | | | | | | | | | | | | | | 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-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-17/+129
| | | | | | | | | | | | | | | | | | | | | 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-14/+254
| | | | | | | | | | | | | | | | | | | | 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-3/+3
| | | | | | | | | | | | | | | | _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
* Handle 'instancetype' in ParseDeclarationSpecifiers.Douglas Gregor2015-06-191-34/+5
| | | | | | | | | | ...instead of as a special case in ParseObjCTypeName with lots of duplicated logic. Besides being a nice refactoring, this also allows "- (instancetype __nonnull)self" in addition to "- (nonnull instancetype)self". rdar://problem/19924646 llvm-svn: 240188
* Check for consistent use of nullability type specifiers in a header.Douglas Gregor2015-06-191-8/+6
| | | | | | | | | | | | | | | | | Adds a new warning (under -Wnullability-completeness) that complains about pointer, block pointer, or member pointer declarations that have not been annotated with nullability information (directly or inferred) within a header that contains some nullability annotations. This is intended to be used to help maintain the completeness of nullability information within a header that has already been audited. Note that, for performance reasons, this warning will underrepresent the number of non-annotated pointers in the case where more than one pointer is seen before the first nullability type specifier, because we're only tracking one piece of information per header. Part of rdar://problem/18868820. llvm-svn: 240158
* Introduced pragmas for audited nullability regions.Douglas Gregor2015-06-191-38/+17
| | | | | | | | | | | | | | | | | Introduce the clang pragmas "assume_nonnull begin" and "assume_nonnull end" in which we make default assumptions about the nullability of many unannotated pointers: - Single-level pointers are inferred to __nonnull - NSError** in a (function or method) parameter list is inferred to NSError * __nullable * __nullable. - CFErrorRef * in a (function or method) parameter list is inferred to CFErrorRef __nullable * __nullable. - Other multi-level pointers are never inferred to anything. Implements rdar://problem/19191042. llvm-svn: 240156
* Implement the 'null_resettable' attribute for Objective-C properties.Douglas Gregor2015-06-191-0/+11
| | | | | | | | '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-3/+174
| | | | | | | | | | | | | | | 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
* [clang] Refactoring of conditions so they use isOneOf() instead of multiple ↵Daniel Marjamaki2015-06-181-8/+7
| | | | | | is(). llvm-svn: 240008
* [Sema] Check availability of ObjC super class and protocols of a containerArgyrios Kyrtzidis2015-04-191-5/+6
| | | | | | | | | | | 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
* Modified the Objective-C lexer and parser (only Sean Callanan2014-12-091-2/+8
| | | | | | | | | | | | | | | | in debugger mode) to accept @import declarations and pass them to the debugger. In the preprocessor, accept import declarations if the debugger is enabled, but don't actually load the module, just pass the import path on to the preprocessor callbacks. In the Objective-C parser, if it sees an import declaration in statement context (usual for LLDB), ignore it and return a NullStmt. llvm-svn: 223855
* Enable ActOnIdExpression to use delayed typo correction for non-C++ codeKaelyn Takata2014-11-211-1/+3
| | | | | | when calling DiagnoseEmptyLookup. llvm-svn: 222551
* Wire up delayed typo correction to DiagnoseEmptyLookup and set upKaelyn Takata2014-11-201-1/+4
| | | | | | | | | Sema::ActOnIdExpression to use the new functionality. Among other things, this allows recovery in several cases where it wasn't possible before (e.g. correcting a mistyped static_cast<>). llvm-svn: 222464
* Remove the last couple uses of the ExprArg(just Expr*) typedef in Parser.Craig Topper2014-10-301-1/+1
| | | | llvm-svn: 220897
* Parse: Replace polymorphic functor objects with lambdas and llvm::function_ref.Benjamin Kramer2014-09-031-95/+48
| | | | | | No change in functionality. llvm-svn: 217025
* Objective-C. When we use @selector(save:), etc. there may be more Fariborz Jahanian2014-06-241-3/+10
| | | | | | | | | | | | | than one method with mismatched type of same selector name. clang issues a warning to point this out since it may cause undefined behavior. There are cases though that some APIs don't care about user methods and such warnings are perceived as noise. This patch allows users to add paren delimiters around selector name to turn off such warnings. So, @selector((save:)) will turn off the warning. It also provides 'fixit' so user knows what to do. // rdar://16458579 llvm-svn: 211611
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-24/+24
| | | | | | takeAs to getAs. llvm-svn: 209800
* [C++11] Use 'nullptr'. Parser edition.Craig Topper2014-05-211-67/+69
| | | | llvm-svn: 209275
* Objective-C. Improve diagnostic error for '@import' Fariborz Jahanian2014-03-261-3/+3
| | | | | | when modules are disabled. // rdar://15505492 llvm-svn: 204862
* Cleanup dead assignments reported by scan-buildArnaud A. de Grandmaison2014-03-231-2/+2
| | | | llvm-svn: 204569
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-121-2/+2
| | | | | | class. llvm-svn: 203641
* ExpectAndConsume: Diagnose errors automaticallyAlp Toker2014-01-011-44/+28
| | | | | | | | | | | | | | 1) Teach ExpectAndConsume() to emit expected and expected-after diagnostics using the generic diagnostic descriptions added in r197972, eliminating another set of trivial err_expected_* variations while maintaining existing behaviour. 2) Lift SkipUntil() recovery out of ExpectAndConsume(). The Expect/Consume family of functions are primitive parser operations that now have the well-defined property of operating on single tokens. Factoring out recovery exposes opportunities for more consistent and tailored error recover at the call sites instead of just relying on a bottled SkipUntil formula. llvm-svn: 198270
* Switch over more of the parser to err_expectedAlp Toker2013-12-301-7/+5
| | | | | | | Includes a fix for a missing highlight range caused by a ',' typo in the PP diagnostics. llvm-svn: 198252
* Support and use token kinds as diagnostic argumentsAlp Toker2013-12-241-34/+41
| | | | | | | | | | | | | | | | | | | Introduce proper facilities to render token spellings using the diagnostic formatter. Replaces most of the hard-coded diagnostic messages related to expected tokens, which all shared the same semantics but had to be multiply defined due to variations in token order or quote marks. The associated parser changes are largely mechanical but they expose commonality in whole chunks of the parser that can now be factored away. This commit uses C++11 typed enums along with a speculative legacy fallback until the transition is complete. Requires corresponding changes in LLVM r197895. llvm-svn: 197972
* Fix a tranche of comment, test and doc typosAlp Toker2013-12-051-1/+1
| | | | llvm-svn: 196510
* Generate a marker token when entering or leaving a submodule when building aRichard Smith2013-11-231-4/+4
| | | | | | | | | module. Use the marker to diagnose cases where we try to transition between submodules when not at the top level (most likely because a closing brace was missing at the end of a header file, but is also possible if submodule headers attempt to do something fundamentally non-modular, like our .def files). llvm-svn: 195543
* Replaced bool parameters in SkipUntil function with single bit-based parameter.Alexey Bataev2013-11-181-25/+25
| | | | llvm-svn: 194994
* ObjectiveC: Handle the case of qualifying protocolsFariborz Jahanian2013-09-251-0/+3
| | | | | | | | | declared in a typedef declaraton used as super class of an ObjC class. Curretnly, these protocols are dropped from the class hierarchy. Test shows that it is now included. // rdar://15051465 llvm-svn: 191395
* This patch removes unused parameter allProperties and converts remainingFariborz Jahanian2013-07-161-4/+1
| | | | | | | parameters in ArrayRef'ize Sema::ActOnAtEnd to ArrayRef. Patch by Robert Wilhelm. llvm-svn: 186421
* ArrayRef'ize Sema::CodeComplete*Dmitri Gribenko2013-06-161-25/+13
| | | | | | Patch by Robert Wilhelm. llvm-svn: 184052
* address some comments on r183474:Adrian Prantl2013-06-071-3/+4
| | | | | | | | | | - factor the name construction part out from constructSetterName - rename constructSetterName to the more appropriate constructSetterSelector no functionality change intended. rdar://problem/14035789 llvm-svn: 183582
* Objective-C parsing. Error recovery when category implementationFariborz Jahanian2013-05-171-0/+6
| | | | | | declaration is illegally protocol qualified. // rdar://13920026 llvm-svn: 182136
* Fix a typo in a parse assert.Fariborz Jahanian2013-04-291-1/+1
| | | | | | Patch by Alex Denisov. llvm-svn: 180712
* Objective-C parsing [qoi]: Recover gracefully with good diagnosticFariborz Jahanian2013-04-241-0/+7
| | | | | | | when class implementation declaration adds protocol qualifier list. // rdar://12233858 llvm-svn: 180228
* Objective-C++: Enable passing of modern C++11 style Fariborz Jahanian2013-04-181-1/+8
| | | | | | | initialized temporaries to objc++ methods. // rdar://12788429 llvm-svn: 179818
* Objective-C parsing [qoi]: Provide good recovery whenFariborz Jahanian2013-04-181-1/+3
| | | | | | | Objective-C dictionary literals has bad syntax for the separator. // rdar://10679157 llvm-svn: 179784
* Make the ObjC attributes diagnostics a bit more informative.Nico Weber2013-04-041-6/+10
| | | | llvm-svn: 178720
* Emit a nicer diagnostic for misplaced attributes on ObjC directives.Nico Weber2013-04-031-0/+15
| | | | llvm-svn: 178670
OpenPOWER on IntegriCloud