summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaObjCXX
Commit message (Collapse)AuthorAgeFilesLines
...
* [Sema] Emit a better diagnostic when variable redeclarations disagreeDavid Majnemer2015-07-141-8/+8
| | | | | | | | | | | We referred to all declaration in definitions in our diagnostic messages which is can be inaccurate. Instead, classify the declaration and emit an appropriate diagnostic for the new declaration and an appropriate note pointing to the old one. This fixes PR24116. llvm-svn: 242190
* Implement variance for Objective-C type parameters.Douglas Gregor2015-07-071-0/+33
| | | | | | | | | | | | | | | 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
* Implement the Objective-C __kindof type qualifier.Douglas Gregor2015-07-071-1/+1
| | | | | | | | | | 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
* C++ support for Objective-C lightweight generics.Douglas Gregor2015-07-071-0/+407
| | | | | | | | | | | | | | | | | | | 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-072-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+26
| | | | | | | | | | | | | | | | | | | | | 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
* Make __has_extension(assume_nonnull) always true.Douglas Gregor2015-06-291-0/+4
| | | | llvm-svn: 240969
* Replace __double_underscored type nullability qualifiers with ↵Douglas Gregor2015-06-2410-40/+40
| | | | | | | | | | | | | | | | _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
* Make -Wnullability-completeness work with -Wsystem-headers.Douglas Gregor2015-06-192-1/+11
| | | | | | rdar://problem/21134250 llvm-svn: 240187
* CF_RETURNS_[NOT_]RETAINED on a param makes the inner pointer __nullable.Douglas Gregor2015-06-191-0/+16
| | | | | | | | | | | | | | That is, void cf2(CFTypeRef * __nullable p CF_RETURNS_NOT_RETAINED); is equivalent to void cf2(CFTypeRef __nullable * __nullable p CF_RETURNS_NOT_RETAINED); More rdar://problem/18742441 llvm-svn: 240186
* Check for consistent use of nullability type specifiers in a header.Douglas Gregor2015-06-1910-13/+138
| | | | | | | | | | | | | | | | | 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-194-0/+151
| | | | | | | | | | | | | | | | | 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
* [Objective-C Sema] Fixes a typo which did not allow Fariborz Jahanian2015-04-103-5/+7
| | | | | | | bridge casting to super class of object's bridge type. rdar://18311183 llvm-svn: 234652
* Recognize objc_bridge(id) on bridged casts to CF types.John McCall2015-03-101-0/+18
| | | | | | Fixes <rdar://20107345>. llvm-svn: 231814
* Update error message text.Serge Pavlov2015-01-181-2/+2
| | | | | | | | | Previously if an enumeration was used in a nested name specifier in pre-C++11 language dialect, error message was 'XXX is not a class, namespace, or scoped enumeration'. This patch removes the word 'scoped' as in C++11 any enumeration may be used in this context. llvm-svn: 226410
* Adding a -Wunused-value warning for expressions with side effects used in an ↵Aaron Ballman2014-12-171-1/+1
| | | | | | unevaluated expression context, such as sizeof(), or decltype(). Also adds a similar warning when the expression passed to typeid() *is* evaluated, since it is equally likely that the user would expect the expression operand to be unevaluated in that case. llvm-svn: 224465
* Allow @synchronized to contextually convert a C++ object to an ObjC object ↵Jordan Rose2014-08-121-0/+20
| | | | | | | | pointer. Patch by Grant Paul! llvm-svn: 215453
* Fix crash when accessing a property of an invalid interfaceOlivier Goffart2014-08-041-1/+5
| | | | llvm-svn: 214735
* Fix crash when assiging to a property with an invalid typeOlivier Goffart2014-08-041-0/+19
| | | | | | | | | | This is a regression from clang 3.4 Set the result to ExprError and returns true, rather than simply returns false because errors have been reported already and returning false show a confusing error llvm-svn: 214734
* Fix assertion hit or bogus compiler error in cases when instantiating ObjC ↵Argyrios Kyrtzidis2014-06-191-0/+35
| | | | | | | | property accesses used with overloaded binary operators. rdar://17153478 llvm-svn: 211270
* Objective-C ARC. Add support for toll-free bridge Fariborz Jahanian2014-05-101-0/+135
| | | | | | | type ,and bridge attribute, checking with static_cast. // rdar://16756639 llvm-svn: 208474
* Objective-C. Improve diagnosis of bridging types.Fariborz Jahanian2014-04-292-106/+259
| | | | | | // rdar://16737117 llvm-svn: 207542
* Objective-C ARC. Under ARC, addition of 'bridge' attributeFariborz Jahanian2014-04-221-3/+3
| | | | | | | | on CF type is not sufficient and bridge casting is still required for proper ownership semantics. // rdar://16650445 llvm-svn: 206910
* Disallow driver use in more Sema testsAlp Toker2014-04-191-0/+4
| | | | | | | There are now only a handful of Sema tests remaining that use %clang in SemaCXX, SemaObjC and SemaTemplate. llvm-svn: 206688
* Objective-C arc [Sema]. Allow bridge cast of a qualified-id expressionFariborz Jahanian2014-04-042-26/+26
| | | | | | | when bridged Objective-C type conforms to the protocols in CF types's Objective-C class. // rdar://16393330 llvm-svn: 205659
* Replace "can not" with "cannot" in diagnostics messages.Ismail Pazarbasi2014-03-071-1/+1
| | | | llvm-svn: 203302
* Improve diagnostic for using non-class/namespace/scoped enum in a nested ↵David Blaikie2014-02-091-3/+3
| | | | | | | | | | | | | | | name specifier. Rather than simply saying "X is not a class or namespace", clarify what X is by providing the aka type in the case where X is a type, or pointing to the named declaration if there's an unambiguous one to refer to. In the ambiguous case, the ambiguities are already enumerated (though could be clarified by describing what kind of entities they are) Included a few FIXMEs in tests where some further improvements could be made. llvm-svn: 201038
* A new conversion warning for when an Objective-C object literal is implicitlyRichard Trieu2014-01-281-0/+74
| | | | | | | | | cast into a boolean true value. This warning will catch code like: if (@0) {} if (@"foo") {} llvm-svn: 200356
* Remove the -cxx-abi command-line flag.Hans Wennborg2014-01-141-1/+1
| | | | | | | | | | | | | | | This makes the C++ ABI depend entirely on the target: MS ABI for -win32 triples, Itanium otherwise. It's no longer possible to do weird combinations. To be able to run a test with a specific ABI without constraining it to a specific triple, new substitutions are added to lit: %itanium_abi_triple and %ms_abi_triple can be used to get the current target triple adjusted to the desired ABI. For example, if the test suite is running with the i686-pc-win32 target, %itanium_abi_triple will expand to i686-pc-mingw32. Differential Revision: http://llvm-reviews.chandlerc.com/D2545 llvm-svn: 199250
* [ms-cxxabi] Elide dtor access checks for pass-by-val objects in calleesHans Wennborg2014-01-131-2/+3
| | | | | | | | | | | | | | | The ABI requires the destructor to be invoked in the callee, but the standard does not require access checks here so we avoid doing direct access checks on the destructor. If we end up needing to define an implicit destructor, we don't skip access checks for the base class, etc. Those checks are effectively part of generating the destructor definition, and aren't affected by which TU the check is performed in. Differential Revision: http://llvm-reviews.chandlerc.com/D2409 llvm-svn: 199120
* Objective-C ARC++: Prefer references to __strong/__weak over ↵Douglas Gregor2014-01-021-0/+16
| | | | | | | | __unsafe_unretained. Fixes <rdar://problem/15713945>. llvm-svn: 198343
* Implemented delayed processing of 'unavailable' checking, just like with ↵Ted Kremenek2013-12-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 'deprecated'. Fixes <rdar://problem/15584219> and <rdar://problem/12241361>. This change looks large, but all it does is reuse and consolidate the delayed diagnostic logic for deprecation warnings with unavailability warnings. By doing so, it showed various inconsistencies between the diagnostics, which were close, but not consistent. It also revealed some missing "note:"'s in the deprecated diagnostics that were showing up in the unavailable diagnostics, etc. This change also changes the wording of the core deprecation diagnostics. Instead of saying "function has been explicitly marked deprecated" we now saw "'X' has been been explicitly marked deprecated". It turns out providing a bit more context is useful, and often we got the actual term wrong or it was not very precise (e.g., "function" instead of "destructor"). By just saying the name of the thing that is deprecated/deleted/unavailable we define this issue away. This diagnostic can likely be further wordsmithed to be shorter. llvm-svn: 197627
* Allow Objective-C pointer conversions following an explicit user conversion.Douglas Gregor2013-12-181-0/+19
| | | | | | Finishes the work started in r194224, and fixes <rdar://problem/15494681>. llvm-svn: 197609
* ObjectiveC. Further improvements of useFariborz Jahanian2013-12-161-8/+4
| | | | | | | | | | of objc_bridge_related attribute; eliminate unnecessary diagnostics which is issued elsewhere, fixit now produces a valid AST tree per convention. This results in some simplification in handling of this attribute as well. // rdar://15499111 llvm-svn: 197436
* Objective-C: Improve on various diagnostics related toFariborz Jahanian2013-12-091-6/+6
| | | | | | use of objc_bridge_related attribute. // rdar://15499111 llvm-svn: 196828
* ObjectiveC. Continuing implementation of objc_bridge_relatedFariborz Jahanian2013-12-071-0/+31
| | | | | | | | | attribute in sema and issuing a variety of diagnostics lazily for misuse of this attribute (and what to do) when converting from CF types to ObjectiveC types (and vice versa). // rdar://15499111 llvm-svn: 196629
* Test to ensure no old-style-cast warning is emitted for objc-arc __bridge castsAlp Toker2013-12-031-0/+11
| | | | llvm-svn: 196204
* ObjectiveC migrator. Improve on definition, useFariborz Jahanian2013-11-222-2/+2
| | | | | | | | and testing of objc_bridgmutable attribute per Aaron Ballman's comments. // rdar://15498044 llvm-svn: 195396
* ObjectiveC. Allow toll free bridge cast warnings outsideFariborz Jahanian2013-11-212-0/+267
| | | | | | | ARC and in objectiveC/ObjectiveC++ MRR mode as well. // rdar://15454846 llvm-svn: 195288
* Fix new check for missing semicolon after struct definition to deal with theRichard Smith2013-11-201-4/+4
| | | | | | | case where the type in the following declaration is specified as a template-id, and refactor for clarity. llvm-svn: 195280
* Objective-C++ ARC: Improve the conversion to a const __unsafe_unretained ↵Douglas Gregor2013-11-081-0/+10
| | | | | | | | | | | | | reference. Under ARC++, a reference to a const Objective-C pointer is implicitly treated as __unsafe_unretained, and can be initialized with (e.g.) a __strong lvalue. Make sure this behavior does not break template argument deduction and (related) that partial ordering still prefers a 'T* const&' template over a 'T const&' template when this case kicks in. Fixes <rdar://problem/14467941>. llvm-svn: 194239
* Re-instate contextual conversion to Objective-C pointers in message sends.Douglas Gregor2013-11-071-0/+33
| | | | | | | | | When performing an Objective-C message send to a value of class type, perform a contextual conversion to an Objective-C pointer type. We've had this for a long time, but it recently regressed. Fixes <rdar://problem/15234703>. llvm-svn: 194224
* ObjectiveC++: support for passing C++11 style initialized temporaries to Fariborz Jahanian2013-10-161-0/+31
| | | | | | | objc++ properties using property-dot syntax. // rdar://14654207 llvm-svn: 192819
* Replace -fobjc-default-synthesize-properties with ↵Rafael Espindola2013-09-271-1/+1
| | | | | | | | | disable-objc-default-synthesize-properties. We want the modern behavior most of the time, so inverting the option simplifies the driver and the tests. llvm-svn: 191551
* Don't produce duplicate notes if we have deduction failure notes when resolvingRichard Smith2013-08-141-2/+1
| | | | | | the address of an overloaded function template. llvm-svn: 188334
* FIXME fix: improving diagnostics for template arguments deduction of class ↵Larisse Voufo2013-07-191-2/+4
| | | | | | | | templates and explicit specializations This patch essentially removes all the FIXMEs following calls to DeduceTemplateArguments() that want to keep track of deduction failure info. llvm-svn: 186730
* Revert "Use function overloading instead of template specialization for ↵Larisse Voufo2013-07-191-4/+2
| | | | | | | | diagnosis of bad template argument deductions." This reverts commit a730f548325756d050d4caaa28fcbffdae8dfe95. llvm-svn: 186729
* Use function overloading instead of template specialization for diagnosis of ↵Larisse Voufo2013-07-191-2/+4
| | | | | | bad template argument deductions. llvm-svn: 186727
* Fix recovery for missing * in objc property.Eli Friedman2013-07-091-0/+8
| | | | | | <rdar://problem/14354144> llvm-svn: 185897
* Remove referece type onproperty of abstractFariborz Jahanian2013-07-051-1/+1
| | | | | | class type. // rdar://14261999 llvm-svn: 185734
OpenPOWER on IntegriCloud