summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaObjCXX
Commit message (Collapse)AuthorAgeFilesLines
* [ObjCXX] Warn undeclared identifiers.Manman Ren2016-03-251-0/+23
| | | | | | | | | | | | | | | | | | | | Instantiation dependence were not being handled correctly for OpqaueValueExpr AST nodes. As a result, if an undeclared identifier was used in a CXXNewExpr that is assigned to a ObjC property, there would be no error during parsing, and there would be a crash during code gen. This patch makes sure that an error will be issued during parsing in this case. Before the fix, if CXXNewExpr has a typo, its InstantiationDependent will be set to true, but if it is wrapped in a OpaqueValueExpr, the OpaqueValueExpr will not be instantiation dependent, causing the TypoExpr not be to resolved. The fix propagates InstantiationDependent to OpaqueValueExpr from its SourceExpr. It also propagates the other instantiation bits. rdar://24975562 Differential Revision: http://reviews.llvm.org/D18461 llvm-svn: 264444
* Improve some infrastructure for extended parameter infos andJohn McCall2016-03-032-2/+10
| | | | | | | fix a bug with the instantiation of ns_consumed parameter attributes in ARC. llvm-svn: 262551
* Test template instantiation of ns_consumed and ns_returns_retained.John McCall2016-03-011-1/+125
| | | | llvm-svn: 262311
* [Sema] Remove assert in TreeTransform<Derived>::TransformObjCObjectType.Akira Hatanaka2016-02-251-0/+9
| | | | | | | | | | | | | The assert isn't correct since TypeLoc::ObjCObjectTypeLoc doesn't indicate whether the type is a dependent type. The function returns false for a type like "<SomeProtocol>" which is a synonym for "id<SomeProtocol>". rdar://problem/23838912 Differential Revision: http://reviews.llvm.org/D17355 llvm-svn: 261829
* [Sema] Fix bug in TypeLocBuilder::pushImplAkira Hatanaka2016-02-181-0/+12
| | | | | | | | | | | | | | The code in TypeLocBuilder::pushImpl wasn't correctly handling the case where an element that has an 8-byte alignment was being pushed. I plan to follow up with a patch to remove redundancies and simplify the function. rdar://problem/23838912 Differential Revision: http://reviews.llvm.org/D16843 llvm-svn: 261260
* ObjCXX: fix a crash during typo correction.Manman Ren2016-02-021-0/+27
| | | | | | | | | | | | | For ObjCXX, we can create a CastExpr with Kind being CK_UserDefinedConversion and SubExpr being BlockExpr. Specifically one can return BlockExpr from BuildCXXMemberCallExpr and the result can be used to build a CastExpr. Fix the assumption in CastExpr::getSubExprAsWritten that SubExpr can only be CXXMemberCallExpr. rdar://problem/24364077 llvm-svn: 259591
* Allow pseudo-destructor calls on forward-declared Objective-C class pointers.John McCall2015-12-141-0/+23
| | | | | | rdar://18522255 llvm-svn: 255531
* [Lit Test] Updated 20 Lit tests to be C++11 compatible.Charles Li2015-12-101-3/+16
| | | | | | | | This is the 5th Lit test patch. Expanded expected diagnostics to vary by C++ dialect. Expanded RUN line to: default, C++98/03 and C++11. llvm-svn: 255196
* Objective-C properties: fix bogus use of "isa<>" on a QualType.Douglas Gregor2015-12-081-0/+10
| | | | | | | | | The code used "isa" to check the type and then "getAs" to look through sugar; we need to look through the sugar when checking, too, otherwise any kind of sugar (nullability qualifiers in the example; or a typedef) will thwart this semantic check. Fixes rdar://problem/23804250. llvm-svn: 255066
* [Lit Test] Updated 26 Lit tests to be C++11 compatible.Charles Li2015-11-112-3/+14
| | | | | | | Expected diagnostics have been expanded to vary by C++ dialect. RUN line has also been expanded to: default, C++98/03 and C++11. llvm-svn: 252785
* Stop back-patching 'readonly' Objective-C properties with 'readwrite' ones.Douglas Gregor2015-11-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | A 'readonly' Objective-C property declared in the primary class can effectively be shadowed by a 'readwrite' property declared within an extension of that class, so long as the types and attributes of the two property declarations are compatible. Previously, this functionality was implemented by back-patching the original 'readonly' property to make it 'readwrite', destroying source information and causing some hideously redundant, incorrect code. Simplify the implementation to express how this should actually be modeled: as a separate property declaration in the extension that shadows (via the name lookup rules) the declaration in the primary class. While here, correct some broken Fix-Its, eliminate a pile of redundant code, clean up the ARC migrator's handling of properties declared in extensions, and fix debug info's naming of methods that come from categories. A wonderous side effect of doing this write is that it eliminates the "AddedObjCPropertyInClassExtension" method from the AST mutation listener, which in turn eliminates the last place where we rewrite entire declarations in a chained PCH file or a module file. This change (which fixes rdar://problem/18475765) will allow us to eliminate the rewritten-decls logic from the serialization library, and fixes a crash (rdar://problem/23247794) illustrated by the test/PCH/chain-categories.m example. llvm-svn: 251874
* Refine r251469 to give better (and more localizable) diagnosticsJohn McCall2015-10-281-2/+2
| | | | | | for all the reasons that ARC makes things implicitly unavailable. llvm-svn: 251496
* Add the ability to define "fake" arguments on attributes.John McCall2015-10-281-1/+1
| | | | | | | | | | | | | | Fake arguments are automatically handled for serialization, cloning, and other representational tasks, but aren't included in pretty-printing or parsing (should we eventually ever automate that). This is chiefly useful for attributes that can be written by the user, but which are also frequently synthesized by the compiler, and which we'd like to remember details of the synthesis for. As a simple example, use this to narrow the cases in which we were generating a specialized note for implicitly unavailable declarations. llvm-svn: 251469
* Be more conservative about diagnosing "incorrect" uses of __weak:John McCall2015-10-271-1/+1
| | | | | | | | | | | | allow them to be written in certain kinds of user declaration and diagnose on the use-site instead. Also, improve and fix some diagnostics relating to __weak and properties. rdar://23228631 llvm-svn: 251384
* Some minor ARC diagnostic improvements.John McCall2015-10-211-2/+2
| | | | llvm-svn: 250917
* Fix inference of _Nullable for weak Objective-C properties.Douglas Gregor2015-10-092-0/+15
| | | | | | | | | | | | | | | | | | | | The inference of _Nullable for weak Objective-C properties was broken in several ways: * It was back-patching the type information very late in the process of checking the attributes for an Objective-C property, which is just wrong. * It was using ad hoc checks to try to suppress the warning about missing nullability specifiers (-Wnullability-completeness), which didn't actual work in all cases (rdar://problem/22985457) * It was inferring _Nullable even outside of assumes-nonnull regions, which is wrong. Putting the inference of _Nullable for weak Objective-C properties in the same place as all of the other inference logic fixes all of these ills. llvm-svn: 249896
* Perform Objective-C lifetime adjustments before comparing deduced lambda ↵Douglas Gregor2015-10-011-0/+19
| | | | | | | | | | result types. Objective-C ARC lifetime qualifiers are dropped when canonicalizing function types. Perform the same adjustment before comparing the deduced result types of lambdas. Fixes rdar://problem/22344904. llvm-svn: 249065
* Forbid qualifiers on ObjC generic parameters and arguments, butJohn McCall2015-09-231-0/+119
| | | | | | | | | | | | | | 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
* Don't crash when passing &@selector to a _Nonnull parameter. Fixes PR24774.Nico Weber2015-09-151-1/+6
| | | | | | | | | The root cause here is that ObjCSelectorExpr is an rvalue, yet it can have its address taken. That's kind of awkward, but fixing this is awkward in other ways, see https://llvm.org/bugs/show_bug.cgi?id=24774#c16 . For now, just fix the crash. llvm-svn: 247740
* Move sel-address.mm from test/CodeGenCXX to test/SemaObjCXX, it's not a ↵Nico Weber2015-09-101-0/+14
| | | | | | codegen test. llvm-svn: 247327
* Add a new frontend warning for referencing members from the handler of a ↵Aaron Ballman2015-09-011-5/+4
| | | | | | | | constructor or destructor function-try-block, which is UB in C++. This corresponds to the CERT secure coding rule ERR53-CPP. llvm-svn: 246548
* [Sema] Be consistent about diagnostic wording: always use "cannot".Davide Italiano2015-08-151-1/+1
| | | | | | Discussed with Richard Smith. llvm-svn: 245162
* Cleanup ObjCInterfaceDecl lookup for ObjC literalsAlex Denisov2015-07-241-1/+1
| | | | llvm-svn: 243092
* Add missing files for objc_boxable feature.Alex Denisov2015-07-231-0/+118
| | | | | | Original patch [r240761] is missing all new files because of committer's mistake. llvm-svn: 243018
* [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
OpenPOWER on IntegriCloud