Commit Graph

19 Commits

Author SHA1 Message Date
Fariborz Jahanian c985a7f6df Objective-C [qoi]. When reporting that a property is not
auto synthesized because it is synthesized in its super
class. locate property declaration in super class
which will default synthesize the property. rdar://18488727

llvm-svn: 219535
2014-10-10 22:08:23 +00:00
Fariborz Jahanian c9b771560a Objective-C. Tweak diagnosing properties that are not auto-synthesized.
Do not warn when property declared in class's protocol will be auto-synthesized
by its uper class implementation because super class has also declared this
property while this class has not. Continue to warn if current class
has declared the property also (because this declaration will not result
in a 2nd synthesis).
rdar://18152478

llvm-svn: 216753
2014-08-29 18:31:16 +00:00
Fariborz Jahanian 261aa1f23a Objective-C. Improve diagnostic when property is
not auto synthesized in current implementation.
rdar://17774815

llvm-svn: 214090
2014-07-28 16:35:45 +00:00
Fariborz Jahanian 6c9ee7b0c8 Objective-C. Issue more warning diagnostic when certain
properties are not synthesized in property auto-synthesis,
as it can potentiall lead to runtime errors.
rdar://17774815

llvm-svn: 214032
2014-07-26 20:52:26 +00:00
Ted Kremenek 760a2acbb5 Fix recursion bug in logic to validate 'objc_protocol_requires_explicit_implementation' conformance.
llvm-svn: 203024
2014-03-05 23:18:22 +00:00
Ted Kremenek 4b3c66e6e8 Adjust logic for 'objc_protocol_requires_explicit_implementation' for inherited protocols and protocols already conformed in the class hierarchy.
Per more discussion, 'objc_protocol_requires_explicit_implementation' is
refinement that it mainly adds that requirement that a protocol must be
explicitly satisfied at the moment the first class in the class hierarchy
conforms to it.  Any subclasses that also conform to that protocol,
either directly or via conforming to a protocol that inherits that protocol,
do not need to re-implement that protocol.

Doing this requires first doing a pass on the super class hierarchy,
gathering the set of protocols conformed to by the super classes,
and then culling those out when determining conformance.  This
two-pass algorithm could be generalized for all protocol checking,
and could possibly be a performance win in some cases.  For now
we restrict this change to protocols with this attribute to isolate
the change in logic (especially as the design continues to evolve).

This change needs to be adjusted for properties as well; this
only impacts methods right now.

llvm-svn: 202948
2014-03-05 08:13:08 +00:00
Ted Kremenek 294c08265d Add category test case for attribute 'objc_protocol_requires_explicit_implementation'.
This test also illustrates that checking for properties is not working properly with
this attribute, as we are missing a diagnostic for a property not being implemented.

llvm-svn: 202335
2014-02-27 01:28:58 +00:00
Ted Kremenek 204c3c50b9 [ObjC] Make attribute 'objc_protocol_requires_explicit_implementation' behave correctly with default property synthesis.
In particular, if we see an @property within the @interface of a class
conforming to a protocol with this attribute, we treat that as
if the implementation were available, per the rules of default
property synthesis.

llvm-svn: 201911
2014-02-22 00:02:03 +00:00
Ted Kremenek 27cfe10df8 Add requirement that attribute 'objc_protocol_requires_explicit_implementation' can only be applied to protocol definitions.
llvm-svn: 201899
2014-02-21 22:49:04 +00:00
Ted Kremenek 38882022af [ObjC] add support for properties in attribute 'objc_protocol_requires_explicit_implementation'.
llvm-svn: 201880
2014-02-21 19:41:39 +00:00
Ted Kremenek 15478b32cb Add more test cases for attribute 'objc_protocol_requires_explicit_implementation'.
llvm-svn: 199480
2014-01-17 08:34:19 +00:00
Ted Kremenek 33e430fc58 Refine 'objc_protocol_requires_explicit_implementation' attribute to better handle indirect protocols.
llvm-svn: 197209
2013-12-13 06:26:14 +00:00
Ted Kremenek 2ccf19e1ab Change 'method X in protocol not implemented' warning to include the name of the protocol.
This removes an extra "note:", which wasn't really all that more useful
and overall reduces the diagnostic spew for this case.

llvm-svn: 197207
2013-12-13 05:58:51 +00:00
Ted Kremenek c152c528b0 Add more test cases for 'objc_protocol_requires_explicit_implementation'.
llvm-svn: 197128
2013-12-12 06:20:42 +00:00
Ted Kremenek f41cf7f10f Rename attribute 'objc_suppress_protocol_methods' to 'objc_protocol_requires_explicit_implementation'.
That's a mouthful, and not necessarily the final name.  This also
reflects a semantic change where this attribute is now on the
protocol itself instead of a class.  This attribute will require
that a protocol, when adopted by a class, is explicitly implemented
by the class itself (instead of walking the super class chain).

Note that this attribute is not "done".  This should be considered
a WIP.

llvm-svn: 196955
2013-12-10 19:43:48 +00:00
Ted Kremenek 7559b47fa2 Remove optional parameter bit from attribute ObjCSuppressProtocol.
This refines some diagnostics and reduces some boilerplate checking logic.

llvm-svn: 195560
2013-11-23 22:29:11 +00:00
Ted Kremenek 28eace65c0 Add back experimental attribute objc_suppress_protocol_methods (slightly renamed).
This is still an experimental attribute, but I wanted it in tree
for review.  It may still get yanked.

This attribute can only be applied to a class @interface, not
a class extension or category.  It does not change the type
system rules for Objective-C, but rather the implementation checking
for Objective-C classes that explicitly conform to a protocol.
During protocol conformance checking, clang recursively searches
up the class hierarchy for the set of methods that compose
a protocol.  This attribute will cause the compiler to not consider
the methods contributed by a super class, its categories, and those
from its ancestor classes.  Thus this attribute is used to force
subclasses to redeclare (and hopefully re-implement) methods if
they decide to explicitly conform to a protocol where some of those
methods may be provided by a super class.

This attribute intentionally leaves out properties, which are associated
with state.  This attribute only considers methods (at least right now)
that are non-property accessors.  These represent methods that "do something"
as dictated by the protocol.  This may be further refined, and this
should be considered a WIP until documentation gets written or this
gets removed.

llvm-svn: 195533
2013-11-23 01:01:34 +00:00
Ted Kremenek a14c3119ac Revert "Add new attribute 'objc_suppress_protocol' to suppress protocol conformance for a class."
After implementing this patch, a few concerns about the language
feature itself emerged in my head that I had previously not considered.
I want to resolve those design concerns first before having
a half-designed language feature in the tree.

llvm-svn: 195328
2013-11-21 07:57:53 +00:00
Ted Kremenek a4bd9a0c0e Add new attribute 'objc_suppress_protocol' to suppress protocol conformance for a class.
The idea is to allow a class to stipulate that its methods (and those
of its parents) cannot be used for protocol conformance in a subclass.
A subclass is then explicitly required to re-implement those methods
of they are present in the class marked with this attribute.

Currently the attribute can only be applied to an @interface, and
not a category or class extension.  This is by design.  Unlike
protocol conformance, where a category can add explicit conformance
of a protocol to class, this anti-conformance really needs to be
observed uniformly by all clients of the class.  That's because
the absence of the attribute implies more permissive checking of
protocol conformance.

This unfortunately required changing method lookup in ObjCInterfaceDecl
to take an optional protocol parameter.  This should not slow down
method lookup in most cases, and is just used for protocol conformance.

llvm-svn: 195323
2013-11-21 07:20:42 +00:00