Commit Graph

1271 Commits

Author SHA1 Message Date
Fariborz Jahanian 65b1377911 ObjectiveC. 1) Warn when @dynamic (as well as synthesize)
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
2014-01-10 00:53:48 +00:00
Ted Kremenek ce0e3f8a09 Have attribute 'objc_precise_lifetime' suppress -Wunused.
Fixes <rdar://problem/15596883>

In ARC, __attribute__((objc_precise_lifetime)) guarantees that the
object stored in it will survive to the end of the variable's formal
lifetime.  It is therefore useful even if it completely unused.

llvm-svn: 198888
2014-01-09 20:19:45 +00:00
Argyrios Kyrtzidis 2080d90f37 [objc] Refactor and improve functionality for the -Wunused-property-ivar warning.
- Remove the additions to ObjCMethodDecl & ObjCIVarDecl that were getting de/serialized and consolidate
  all functionality for the checking for this warning in Sema::DiagnoseUnusedBackingIvarInAccessor
- Don't check immediately after the method body is finished, check when the @implementation is finished.
  This is so we can see if the ivar was referenced by any other method, even if the method was defined after the accessor.
- Don't silence the warning if any method is called from the accessor silence it if the accessor delegates to another method via self.

rdar://15727325

llvm-svn: 198432
2014-01-03 18:32:18 +00:00
Aaron Ballman 34b3475cd3 Reworded the NSObject attribute diagnostics to be more consistent with other attribute diagnostics. Also updated the associated test case.
llvm-svn: 198368
2014-01-02 22:45:33 +00:00
Fariborz Jahanian 5b3105d2cb ObjectiveC. Remove false positive warning for missing property
backing ivar by not issuing this warning if ivar is referenced
somewhere and accessor makes method calls. // rdar://15727325

llvm-svn: 198367
2014-01-02 22:42:09 +00:00
Aaron Ballman 05e420abad Updated the wording of two attribute-related diagnostics so that they print the offending attribute name. Also updates the associated test cases.
llvm-svn: 198355
2014-01-02 21:26:14 +00:00
Fariborz Jahanian 1cc7ae1d08 ObjectiveC. Class methods must be ignored when looking for
property accessor's missing backing ivar. This eliminates
the bogus warning being issued. // rdar://15728901

llvm-svn: 198322
2014-01-02 17:24:32 +00:00
Ted Kremenek 1654511884 Wordsmith "maybe" into "may be" in diagnostic, and move warning under flag.
llvm-svn: 197736
2013-12-19 22:47:11 +00:00
Aaron Ballman 37c5f5da32 After discussing with John McCall, removing the ns_bridged attribute as it is unused.
llvm-svn: 197729
2013-12-19 22:12:51 +00:00
Fariborz Jahanian 4b7946a28a ObjectiveC. Sema test for property, methods
'section' attribute. // rdar://15450637

llvm-svn: 197704
2013-12-19 17:22:23 +00:00
Ted Kremenek b79ee57080 Implemented delayed processing of 'unavailable' checking, just like with '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
2013-12-18 23:30:06 +00:00
Fariborz Jahanian 8ef938972a ObjectiveC. Fixes the sentence in a diagnostic.
// rdar://15397430

llvm-svn: 197586
2013-12-18 16:51:06 +00:00
Fariborz Jahanian 1b30b593ba ObjectiveC. typo fix in my last patch,
per Jordan's review. 

llvm-svn: 197540
2013-12-18 00:52:54 +00:00
Fariborz Jahanian 7e350d23b2 Objctive-C. warn if dealloc is being overridden in
a category implementation. // rdar://15397430

llvm-svn: 197534
2013-12-17 22:44:28 +00:00
Fariborz Jahanian 381edf5759 ObjectiveC. Further improvements of use
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
2013-12-16 22:54:37 +00:00
Alp Toker 099b0d3741 Fix test containing backslash and newline separated by space
This was silently accepted by clang without warning due to a lexer bug.

llvm-svn: 197330
2013-12-14 23:32:27 +00:00
Argyrios Kyrtzidis 0f7f222c59 [objc] Add a test to make sure that a class can add a secondary initializer via a category
and still inherit the designated initializers of its super class.

llvm-svn: 197301
2013-12-14 02:16:41 +00:00
Fariborz Jahanian 07e7e6cbc8 Objective-C. Remove obsolete option from test.
// rdar://15641300

llvm-svn: 197263
2013-12-13 19:06:55 +00:00
Fariborz Jahanian 059021a369 Objective-C. Do not issue warning when 'readonly'
property declaration has a memory management
attribute (retain, copy, etc.). Sich properties
are usually overridden to become 'readwrite'
via a class extension (which require the memory
management attribute specified). In the absence of class
extension override, memory management attribute is
needed to produce correct Code Gen. for the
property getter in any case and this warning becomes
confusing to user. // rdar://15641300

llvm-svn: 197251
2013-12-13 18:19:59 +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
Argyrios Kyrtzidis d664a34de8 [objc] If we don't know for sure what the designated initializers of the superclass are,
assume that a [super init..] inside a designated initializer also refers to a designated one
and do not warn.

llvm-svn: 197202
2013-12-13 03:48:17 +00:00
Ted Kremenek 6d69ac8b8a Enhance "auto synthesis will not synthesize property in protocol" to include property and protocol name.
Implements <rdar://problem/15617839>.

llvm-svn: 197187
2013-12-12 23:40:14 +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
Fariborz Jahanian 54f87385c0 ObjectiveC. Fixes a bug where an 'unused property ivar'
warning is coming out incorrectly too early
becuase of unrelated scope pop. // rdar://15630719

llvm-svn: 196989
2013-12-11 00:53:48 +00:00
Fariborz Jahanian ddd28dc061 Objective-C. Minor change to a diagnostic.
// rdar://15499111

llvm-svn: 196977
2013-12-10 22:22:45 +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
Fariborz Jahanian 7c04a55545 Improve on an objc_bridge_related diagnostic.
// rdar://15499111

llvm-svn: 196950
2013-12-10 19:22:41 +00:00
Fariborz Jahanian 67379e25c6 Objective-C: Improve on various diagnostics related to
use of objc_bridge_related attribute. // rdar://15499111

llvm-svn: 196828
2013-12-09 22:04:26 +00:00
Alp Toker 3cde27785b Fix three tests that weren't checking anything
Add -verify and update the test directives to match current expectations.

Also add a FIXME to an ObjC test that has expected-* directives but no -verify.

llvm-svn: 196737
2013-12-08 22:22:31 +00:00
Argyrios Kyrtzidis e818681c88 Add a SubsetSubject in Attr.td to automate checking of where the objc_designated_initializer
attribute is acceptable.

llvm-svn: 196644
2013-12-07 06:08:04 +00:00
Fariborz Jahanian 1f0b3bfd75 ObjectiveC. Continuing implementation of objc_bridge_related
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
2013-12-07 00:34:23 +00:00
Fariborz Jahanian f3077a29ce ObjectiveC: Don't warn when method implemented in
category is declared in category's primary
class's super class. Because the super class is
expected to implemented the method. // rdar://15580969

llvm-svn: 196531
2013-12-05 20:52:31 +00:00
Alp Toker f6a24ce40f Fix a tranche of comment, test and doc typos
llvm-svn: 196510
2013-12-05 16:25:25 +00:00
Argyrios Kyrtzidis b9a405b33e [objc] If an interface has no initializer marked as designated and introduces at least one new initializer,
don't assume that it inherits the designated initializers from the super class.

If the assumption was wrong because a new initializer was a designated one that was not marked as such,
we will emit misleading warnings for subclasses of the interface.

llvm-svn: 196476
2013-12-05 07:07:03 +00:00
Alp Toker d473363876 Correct hyphenations in comments and assert messages
This patch tries to avoid unrelated changes other than fixing a few
hyphen-related ambiguities in nearby lines.

llvm-svn: 196466
2013-12-05 04:47:09 +00:00
Argyrios Kyrtzidis db5ce0f71e [objc] Add a warning when a class that provides a designated initializer, does not
override all of the designated initializers of its superclass.

llvm-svn: 196319
2013-12-03 21:11:54 +00:00
Argyrios Kyrtzidis b66d3cf5cf [objc] Emit warning when the implementation of a secondary initializer calls on
super another initializer and when the implementation does not delegate to
another initializer via a call on 'self'.

A secondary initializer is an initializer method not marked as a designated
initializer within a class that has at least one initializer marked as a
designated initializer.

llvm-svn: 196318
2013-12-03 21:11:49 +00:00
Argyrios Kyrtzidis fcded9b93a [objc] Emit warnings when the implementation of a designated initializer calls on
super an initializer that is not a designated one or any initializer on self.

llvm-svn: 196317
2013-12-03 21:11:43 +00:00
Argyrios Kyrtzidis 22bfa2c28b [objc] Emit a warning when the implementation of a designated initializer does not chain to
an init method that is a designated initializer for the superclass.

llvm-svn: 196316
2013-12-03 21:11:36 +00:00
Argyrios Kyrtzidis d1438b446e [objc] Introduce attribute 'objc_designated_initializer'.
It only applies to methods of init family in an interface declaration.

llvm-svn: 196314
2013-12-03 21:11:25 +00:00
Aaron Ballman 80469038c0 Enables support for custom subject lists for attributes. As a testbed, uses the custom subject for the ibaction attribute.
llvm-svn: 195960
2013-11-29 14:57:58 +00:00
Aaron Ballman f361453519 Making some attribute diagnostics more consistent. Removes a newly-unused diagnostic.
Reviewed by Fariborz Jahanian

llvm-svn: 195578
2013-11-24 20:36:50 +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
Fariborz Jahanian 36129a953d ObjectiveC. Remove warning diagnostic which checks
attribute on method declaration and implementation
match. This makes no sense. Most annotations are
meant for declarations only and one is for implementation.
This has been constant source of regresions and hackery to
get around special cases. I am removing this check.
Such checks must be done on a case by case basis and
when it makes sense. For example, it makes sense
for availability/deprecated and I will file a radar
for that. // rdar://15531984

llvm-svn: 195524
2013-11-23 00:14:32 +00:00
Fariborz Jahanian 2651ac5445 ObjectiveC migrator. Improve on definition, use
and testing of objc_bridgmutable attribute per
Aaron Ballman's comments.
// rdar://15498044

llvm-svn: 195396
2013-11-22 00:02:22 +00:00
Fariborz Jahanian 87c7791bb7 ObjectiveC. Implement attribute 'objc_bridge_mutable'
whose semantic is currently identical to objc_bridge,
but their differences may manifest down the road with
further enhancements. // rdar://15498044

llvm-svn: 195376
2013-11-21 20:50:32 +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