summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaObjC/arc-decls.m
Commit message (Collapse)AuthorAgeFilesLines
* [Sema] Diagnose default-initialization, destruction, and copying ofAkira Hatanaka2019-09-071-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | non-trivial C union types This recommits r365985, which was reverted because it broke a few projects using unions containing non-trivial ObjC pointer fields in system headers. We now have a patch to fix the problem (see https://reviews.llvm.org/D65256). Original commit message: This patch diagnoses uses of non-trivial C unions and structs/unions containing non-trivial C unions in the following contexts, which require default-initialization, destruction, or copying of the union objects, instead of disallowing fields of non-trivial types in C unions, which is what we currently do: - function parameters. - function returns. - assignments. - compound literals. - block captures except capturing of `__block` variables by non-escaping blocks. - local and global variable definitions. - lvalue-to-rvalue conversions of volatile types. See the discussion in https://reviews.llvm.org/D62988 for more background. rdar://problem/50679094 Differential Revision: https://reviews.llvm.org/D63753 llvm-svn: 371275
* Revert "[Sema] Diagnose default-initialization, destruction, and copying of"Akira Hatanaka2019-07-261-1/+5
| | | | | | | | | | | | | | | This reverts commit r365985. Prior to r365985, clang used to mark C union fields that have non-trivial ObjC ownership qualifiers as unavailable if the union was declared in a system header. r365985 stopped doing so, which caused the swift compiler to crash when it tried to import a non-trivial union. I have a patch that fixes the crash (https://reviews.llvm.org/D65256), but I'm temporarily reverting the original patch until we can decide on whether it's taking the right approach. llvm-svn: 367076
* [Sema] Diagnose default-initialization, destruction, and copying ofAkira Hatanaka2019-07-131-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | non-trivial C union types This patch diagnoses uses of non-trivial C unions and structs/unions containing non-trivial C unions in the following contexts, which require default-initialization, destruction, or copying of the union objects, instead of disallowing fields of non-trivial types in C unions, which is what we currently do: - function parameters. - function returns. - assignments. - compound literals. - block captures except capturing of `__block` variables by non-escaping blocks. - local and global variable definitions. - lvalue-to-rvalue conversions of volatile types. See the discussion in https://reviews.llvm.org/D62988 for more background. rdar://problem/50679094 Differential Revision: https://reviews.llvm.org/D63753 llvm-svn: 365985
* [Sema][ObjC] Disallow non-trivial C struct fields in unions.Akira Hatanaka2019-02-071-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes a bug where clang doesn’t reject union fields of non-trivial C struct types. For example: ``` // This struct is non-trivial under ARC. struct S0 { id x; }; union U0 { struct S0 s0; // clang should reject this. struct S0 s1; // clang should reject this. }; void test(union U0 a) { // Previously, both 'a.s0.x' and 'a.s1.x' were released in this // function. } ``` rdar://problem/46677858 Differential Revision: https://reviews.llvm.org/D55659 llvm-svn: 353459
* [ObjC] Allow declaring __strong pointer fields in structs in Objective-CAkira Hatanaka2018-02-281-3/+3
| | | | | | | | | | | | | | | | | | | | | ARC mode. Declaring __strong pointer fields in structs was not allowed in Objective-C ARC until now because that would make the struct non-trivial to default-initialize, copy/move, and destroy, which is not something C was designed to do. This patch lifts that restriction. Special functions for non-trivial C structs are synthesized that are needed to default-initialize, copy/move, and destroy the structs and manage the ownership of the objects the __strong pointer fields point to. Non-trivial structs passed to functions are destructed in the callee function. rdar://problem/33599681 Differential Revision: https://reviews.llvm.org/D41228 llvm-svn: 326307
* [Sema][ObjC] Use SmallSetVector to fix a failing test on the reverseAkira Hatanaka2018-02-061-0/+22
| | | | | | | | | | | | | iteration bot. This commit reverts r315639, which was causing clang to print diagnostics that weren't printed before. Instead, it declares OverrideSearch::Overridden as a SmallSetVector to fix the non-deterministic behavior r315639 was trying to fix. rdar://problem/36445528 llvm-svn: 324425
* Suggest objc_method_family(none) for a property named -newFoo or similar.Jordan Rose2015-01-161-6/+29
| | | | | | | | | | | | | | | As mentioned in the previous commit, if a property (declared with @property) has a name that matches a special Objective-C method family, the getter picks up that family despite being declared by the property. The most correct way to solve this problem is to add the 'objc_method_family' attribute to the getter with an argument of 'none', which unfortunately requires an explicit declaration of the getter. This commit adds a note to the existing error (ARC) or warning (MRR) for such a poorly-named property that suggests the solution; if there's already a declaration of the getter, it even includes a fix-it. llvm-svn: 226339
* ObjectiveC. 1) Warn when @dynamic (as well as synthesize) Fariborz Jahanian2014-01-101-6/+14
| | | | | | | | | property has the naming convention that implies 'ownership'. 2) improve on diagnostic and make it property specific. 3) fix the line number in the case of default property synthesis. // rdar://15757510 llvm-svn: 198905
* ObjectiveC ARC. Removes a bogus warning when a weak Fariborz Jahanian2013-11-191-0/+5
| | | | | | | property is redeclared as 'weak' in class extension. // rdar://15465916 llvm-svn: 195146
* ObjectiveC arc. Warn when an implicitly 'strong' property Fariborz Jahanian2013-10-261-0/+13
| | | | | | | is redeclared as 'weak' in class extension. // rdar://15304886 llvm-svn: 193453
* Improving objc_ownership attribute test coverage.Aaron Ballman2013-09-011-0/+6
| | | | llvm-svn: 189731
* Undo my re-wording of the "ARC forbids Objective-C objects in ..."Douglas Gregor2013-01-281-4/+4
| | | | | | error. Jordan is right. llvm-svn: 173713
* Forbid the use of objects in unions in Objective-C++ ARC. FixesDouglas Gregor2013-01-281-4/+4
| | | | | | <rdar://problem/13098104>. llvm-svn: 173708
* objective-C arc: ns_returns_retained is a type attribute in ARC,Fariborz Jahanian2012-08-281-0/+2
| | | | | | | | and when used in property type declaration, is handled as type attribute. Do not issue the warning when declaraing the property. // rdar://12173491 llvm-svn: 162801
* Added a new attribute, objc_root_class, which informs the compiler when a ↵Patrick Beard2012-04-061-1/+1
| | | | | | | | | root class is intentionally declared. The warning this inhibits, -Wobjc-root-class, is opt-in for now. However, all clang unit tests that would trigger the warning have been updated to use -Wno-objc-root-class. <rdar://problem/7446698> llvm-svn: 154187
* Don't suppress access-control or invalid-type diagnostics from aJohn McCall2012-01-261-0/+11
| | | | | | | | | | | | | declarator just because we were able to build an invalid decl for it. The invalid-type diagnostics, in particular, are still useful to know, and may indicate something about why the decl is invalid. Also, recover from an illegal pointer/reference-to-unqualified-retainable type using __strong instead of __autoreleasing; in general, a random object is much more likely to be __strong, so this avoids unnecessary cascading errors in the most common case. llvm-svn: 149074
* objc-arc: better diagnostic when block is declaredFariborz Jahanian2011-12-121-1/+6
| | | | | | inside a struct/union. llvm-svn: 146444
* Make -fobjc-nonfragile-abi the -cc1 default, since it's theJohn McCall2011-10-021-1/+1
| | | | | | | | | | | | | | | | | | | increasingly prevailing case to the point that new features like ARC don't even support the fragile ABI anymore. This required a little bit of reshuffling with exceptions because a check was assuming that ObjCNonFragileABI was only being set in ObjC mode, and that's actually a bit obnoxious to do. Most, though, it involved a perl script to translate a ton of test cases. Mostly no functionality change for driver users, although there are corner cases with disabling language-specific exceptions that we should handle more correctly now. llvm-svn: 140957
* objcetive-c-arc: When overriding a method, its ns_consumed patameterFariborz Jahanian2011-09-271-0/+19
| | | | | | | | attribute must match its overriden method. Same also for ns_returns_retained/not_retained on the result type. This is one half of // rdar://10187884 llvm-svn: 140649
* Rename objc_lifetime -> objc_ownership, and modify diagnostics to talk about ↵Argyrios Kyrtzidis2011-06-241-6/+6
| | | | | | | | 'ownership', not 'lifetime'. rdar://9477613. llvm-svn: 133779
* Automatic Reference Counting.John McCall2011-06-151-0/+64
Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
OpenPOWER on IntegriCloud