summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaObjCProperty.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* objective-c: reverse patch for // rdar://9818354Fariborz Jahanian2011-08-011-8/+0
| | | | llvm-svn: 136658
* In ARC we emit an error when compiling:Argyrios Kyrtzidis2011-07-261-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | @interface Foo : NSObject @property (readonly) id myProp; @end @implementation Foo @synthesize myProp; @end t.m:9:13: error: ARC forbids synthesizing a property of an Objective-C object with unspecified storage attribute @synthesize myProp; ^ which is fine, we want the ownership of the synthesized ivar to be explicit. But we should _not_ emit an error for the following cases, because we can get the ownership either from the declared ivar or from the property type: @interface Foo : NSObject { __weak id _myProp1; id myProp2; } @property (readonly) id myProp1; @property (readonly) id myProp2; @property (readonly) __strong id myProp3; @end @implementation Foo @synthesize myProp1 = _myProp1; @synthesize myProp2; @synthesize myProp3; @end  rdar://9844006. llvm-svn: 136155
* objective-c: Any use of @synthesize or @dynamic lexically after a method (or ↵Fariborz Jahanian2011-07-221-0/+8
| | | | | | | | | | C function) implementation will be rejected with a compilation error in ARC mode, and a compiler warning otherwise. This may cause breakage in non-arc (and arc) tests which don't expect warning/error. Feel free to fix the tests, or reverse the patch, if I am unavailable. // rdar://9818354 - WIP llvm-svn: 135740
* When creating a property in a class extension, make sure to check itsDouglas Gregor2011-07-151-0/+1
| | | | | | attributes. Fixes <rdar://problem/9561076>. llvm-svn: 135273
* objc++: Some level of covariance is allowed in ObjC properties.Fariborz Jahanian2011-07-131-6/+9
| | | | | | | Make it also available in ObjC++ propeties. Use common code for objc and objc++ so they don't diverge. // rdar://9740328 llvm-svn: 135050
* objc++: Some level of covariance is allowed in ObjC properties.Fariborz Jahanian2011-07-121-1/+1
| | | | | | Make it also available in ObjC++ propeties. // rdar://9740328 llvm-svn: 135001
* [ARC] Complain about property without storage attribute when @synthesizing ↵Argyrios Kyrtzidis2011-07-121-20/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | it, not at its declaration. For this sample: @interface Foo @property id x; @end we get: t.m:2:1: error: ARC forbids properties of Objective-C objects with unspecified storage attribute @property id x; ^ 1 error generated. The error should be imposed on the implementor of the interface, not the user. If the user uses a header of a non-ARC library whose source code he does not have, we are basically asking him to go change the header of the library (bad in general), possible overriding how the property is implemented if he gets confused and says "Oh I'll just add 'copy' then" (even worse). Second issue is that we don't emit any error for 'readonly' properties, e.g: @interface Foo @property (readonly) id x; // no error here @end @implementation Foo @synthesize x; // no error here too @end We should give an error when the implementor is @synthesizing a property which doesn't have any storage specifier; this is when the explicit specifier is important, because we are going to create an ivar and we want its ownership to be explicit. Related improvements: -OBJC_PR_unsafe_unretained turned out to not fit in ObjCPropertyDecl's bitfields, fix it. -For properties of extension classes don't drop PropertyAttributesAsWritten values. -Have PropertyAttributesAsWritten actually only reflect what the user wrote rdar://9756610. llvm-svn: 134960
* Change the driver's logic about Objective-C runtimes: abstract out aJohn McCall2011-07-061-1/+1
| | | | | | | | | | | | structure to hold inferred information, then propagate each invididual bit down to -cc1. Separate the bits of "supports weak" and "has a native ARC runtime"; make the latter a CodeGenOption. The tool chain is still driving this decision, because it's the place that has the required deployment target information on Darwin, but at least it's better-factored now. llvm-svn: 134453
* objc-arc/mrc: Allow ns_returns_not_retained attribute on propertiesFariborz Jahanian2011-06-251-1/+11
| | | | | | | | | to turn off warning on those properties which follow Cocoa naming convention for retaining objects and yet they were not meant for such purposes. Also, perform consistancy checking for declared getters of such methods. // rdar://9636091 llvm-svn: 133849
* No need to warn if 'unavailable' method/property Fariborz Jahanian2011-06-241-1/+1
| | | | | | is not implemented. // rdar://9651605 llvm-svn: 133819
* Rename objc_lifetime -> objc_ownership, and modify diagnostics to talk about ↵Argyrios Kyrtzidis2011-06-241-3/+3
| | | | | | | | 'ownership', not 'lifetime'. rdar://9477613. llvm-svn: 133779
* Automatic Reference Counting.John McCall2011-06-151-33/+350
| | | | | | | | | | 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
* Restore 'atomic' as an attribute of objcFariborz Jahanian2011-06-111-2/+6
| | | | | | properties. llvm-svn: 132866
* Remove 'atomic' as a property attribute keyword.Fariborz Jahanian2011-06-081-6/+2
| | | | | | | It is not a sanctioned keyword and is assumed as default. // rdar://8790791 llvm-svn: 132753
* fix a bunch of comment typos found by codespell. Patch byChris Lattner2011-04-151-1/+1
| | | | | | Luis Felipe Strano Moraes! llvm-svn: 129559
* de-sugared when accessing property reference type.Fariborz Jahanian2011-03-301-1/+1
| | | | | | Add a test case for synthesize ivar. // rdar://9070460 llvm-svn: 128554
* Implements property of reference types. AddingFariborz Jahanian2011-03-281-12/+14
| | | | | | | an executable test to llvm test suite. // rdar://9070460. llvm-svn: 128435
* Implement a new 'availability' attribute, that allows one to specifyDouglas Gregor2011-03-231-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which versions of an OS provide a certain facility. For example, void foo() __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6))); says that the function "foo" was introduced in 10.2, deprecated in 10.4, and completely obsoleted in 10.6. This attribute ties in with the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that we want to deploy back to Mac OS X 10.1). There are several concrete behaviors that this attribute enables, as illustrated with the function foo() above: - If we choose a deployment target >= Mac OS X 10.4, uses of "foo" will result in a deprecation warning, as if we had placed attribute((deprecated)) on it (but with a better diagnostic) - If we choose a deployment target >= Mac OS X 10.6, uses of "foo" will result in an "unavailable" warning (in C)/error (in C++), as if we had placed attribute((unavailable)) on it - If we choose a deployment target prior to 10.2, foo() is weak-imported (if it is a kind of entity that can be weak imported), as if we had placed the weak_import attribute on it. Naturally, there can be multiple availability attributes on a declaration, for different platforms; only the current platform matters when checking availability attributes. The only platforms this attribute currently works for are "ios" and "macosx", since we already have -mxxxx-version-min flags for them and we have experience there with macro tricks translating down to the deprecated/unavailable/weak_import attributes. The end goal is to open this up to other platforms, and even extension to other "platforms" that are really libraries (say, through a #pragma clang define_system), but that hasn't yet been designed and we may want to shake out more issues with this narrower problem first. Addresses <rdar://problem/6690412>. As a drive-by bug-fix, if an entity is both deprecated and unavailable, we only emit the "unavailable" diagnostic. llvm-svn: 128127
* Fixed source range for all DeclaratorDecl's.Abramo Bagnara2011-03-081-3/+5
| | | | llvm-svn: 127225
* Improve the diagnostic for -Wcustom-atomic-properties. Suggestion by Fariborz!Argyrios Kyrtzidis2011-01-311-2/+2
| | | | llvm-svn: 124620
* Add -Wcustom-atomic-properties which warns if an atomic-by-default property ↵Argyrios Kyrtzidis2011-01-311-4/+30
| | | | | | | | | | | has custom getter or setter. The rationale is that it is highly likely that the user's getter/setter isn't atomically implemented. Off by default. Addresses rdar://8782645. -Wcustom-atomic-properties and -Wimplicit-atomic-properties are under the -Watomic-properties group. llvm-svn: 124609
* Give OpaqueValueExpr a source location, because its source locationDouglas Gregor2011-01-281-3/+7
| | | | | | | | might be queried in places where we absolutely require a valid location (e.g., for template instantiation). Fixes some major brokenness in the use of __is_convertible_to. llvm-svn: 124465
* Initialize a variable, found by Ted.Fariborz Jahanian2011-01-201-1/+1
| | | | llvm-svn: 123948
* Don't warn on missing 'copy' attribute on a 'block'Fariborz Jahanian2011-01-051-0/+1
| | | | | | property when it is 'readonly'. // rdar://8820813 llvm-svn: 122923
* Guard lazy synthesis of provisional ivars under the newFariborz Jahanian2011-01-031-1/+2
| | | | | | -fobjc-default-synthesize-properties flag. llvm-svn: 122757
* Warn when synthesizing a property which isFariborz Jahanian2010-12-171-0/+12
| | | | | | | implicitly atomic under -Wimplicit-atomic-properties flag. // rdar://8774580 llvm-svn: 122095
* ivars craeted for explicit @synthesize and thoseFariborz Jahanian2010-12-151-1/+1
| | | | | | | created for auto-synthesis are @private. Fixes: // rdar://8769582 llvm-svn: 121913
* Any property declared in a class extension might have userFariborz Jahanian2010-12-101-1/+4
| | | | | | | | | | | declared setter or getter in current class extension or one of the other class extensions. Mark them as synthesized as property will be synthesized when property with same name is seen in the @implementation. This prevents bogus warning about unimplemented methods to be issued for these methods. Fixes // rdar://8747333 llvm-svn: 121597
* Rename CXXExprWithTemporaries -> ExprWithCleanups; there's no theoreticalJohn McCall2010-12-061-1/+1
| | | | | | reason this is limited to C++, and it's certainly not limited to temporaries. llvm-svn: 120996
* Calculate the value kind of an expression when it's created andJohn McCall2010-11-181-6/+6
| | | | | | | | | | | | | store it on the expression node. Also store an "object kind", which distinguishes ordinary "addressed" l-values (like variable references and pointer dereferences) and bitfield, @property, and vector-component l-values. Currently we're not using these for much, but I aim to switch pretty much everything calculating l-valueness over to them. For now they shouldn't necessarily be trusted. llvm-svn: 119685
* For an Objective-C @synthesize statement, e.g.,Douglas Gregor2010-11-171-3/+5
| | | | | | | | | @synthesize foo = _foo; keep track of the location of the ivar ("_foo"). Teach libclang to visit the ivar as a member reference. llvm-svn: 119447
* Kill off the remaining places which generate CK_Unknown casts.John McCall2010-11-161-8/+4
| | | | llvm-svn: 119326
* Assorted work leading towards the elimination of CK_Unknown.John McCall2010-11-151-4/+9
| | | | llvm-svn: 119138
* Check for duplicate declaration of a property in current andFariborz Jahanian2010-11-101-9/+16
| | | | | | other class extensions. // rdar://7629420 llvm-svn: 118689
* Propagate the deprecated and unavailable attributes from aJohn McCall2010-11-101-0/+17
| | | | | | | | | | @property declaration to the autogenerated methods. I'm uncertain whether this should apply to attributes in general, but these are a reasonable core. Implements rdar://problem/8617301 llvm-svn: 118676
* Tweak diagnostics for redeclaration of a @property in a class extension ↵Ted Kremenek2010-10-211-1/+10
| | | | | | | | | | where the redelcaration and original declaration have the 'readwrite' attribute. This is a common case, and we can issue a more lucid diagnostic. Fixes <rdar://problem/7629420>. llvm-svn: 117045
* Check for ivar being a C++ object before attempting toFariborz Jahanian2010-10-151-2/+4
| | | | | | | | | find a copy constructor/assignment operator used in getter/setter synthesis. This removes an unintended diagnostics and makes objc++ consistant with objective-c. // rdar: //8550657. llvm-svn: 116631
* Put line number on the diagnostic. //rdar: //8550657.Fariborz Jahanian2010-10-141-1/+1
| | | | llvm-svn: 116519
* Default synthesized ivars don't really have a location in the source. Using ↵Ted Kremenek2010-09-241-3/+8
| | | | | | | | | the location of the @implementation is just confusing for clients that want to use SourceLocations for syntactic references. Fixes: <rdar://problem/8470540> llvm-svn: 114714
* For properties declared in a @protocol and redeclared in a class extension, ↵Ted Kremenek2010-09-231-2/+7
| | | | | | | | | use the class extension as the lexical DeclContext for the @property declaration that gets auto-created for the @interface. Fixes: <rdar://problem/8467189> llvm-svn: 114693
* Correctly register the class extension as the lexical DeclContext for ObjC ↵Ted Kremenek2010-09-211-6/+9
| | | | | | | | | | | | methods declared with @property in class extensions. This matches the behavior for setters. Also pass the class extension to ProcessPropertyDecl as the lexical DeclContext, even when not redeclaring the @property. This fixes the remaining issues in <rdar://problem/7410145>. llvm-svn: 114477
* For ObjCPropertyDecls in class extensions, use the class extension as the ↵Ted Kremenek2010-09-211-12/+18
| | | | | | | | | | | lexical DeclContext for newly created ObjCMethodDecls. Further, use the location of the new property declaration as the location of new ObjCMethodDecls (if they didn't previously exist). This fixes more of the issues reported in <rdar://problem/7410145>. llvm-svn: 114456
* Split ObjCInterfaceDecl::ReferencedProtocols into two lists: ↵Ted Kremenek2010-09-011-11/+16
| | | | | | | | | | | | | ReferencedProtocols and AllReferencedProtocols. ReferencedProtocols (and thus protocol_begin(), protocol_end()) now only contains the list of protocols that were directly referenced in an @interface declaration. 'all_referenced_protocol_[begin,end]()' now returns the set of protocols that were referenced in both the @interface and class extensions. The latter is needed for semantic analysis/codegen, while the former is needed to maintain the lexical information of the original source. Fixes <rdar://problem/8380046>. llvm-svn: 112691
* De-memberify the VarDecl and FunctionDecl StorageClass enums.John McCall2010-08-261-2/+2
| | | | | | This lets us remove Sema.h's dependency on Expr.h and Decl.h. llvm-svn: 112156
* Split out a header to hold APIs meant for the Sema implementation from Sema.h.John McCall2010-08-251-1/+1
| | | | | | | Clients of Sema don't need to know (for example) the list of diagnostics we support. llvm-svn: 112093
* GCC didn't care for my attempt at API compatibility, so brute-force everythingJohn McCall2010-08-251-1/+1
| | | | | | to the new constants. llvm-svn: 112047
* Remove the DenseSet dependency from Sema.h.John McCall2010-08-251-0/+1
| | | | llvm-svn: 112030
* No need to default synthesize property if implementation Fariborz Jahanian2010-08-251-0/+6
| | | | | | | has its own getter and setter methods declared. Fixed 8349319 (nonfragile-abi2). llvm-svn: 112003
* Fix a bug in nonfragile-abi2 when attempting to diagnoseFariborz Jahanian2010-08-241-2/+4
| | | | | | | | previous use of a synthesized 'ivar' with property of same name declared as @dynamic. In this case, 'ivar' is in the inherited class and no diagnostics should be issued. llvm-svn: 111940
* Struggle mightily against header inclusion in Sema.h.John McCall2010-08-241-0/+1
| | | | llvm-svn: 111904
OpenPOWER on IntegriCloud