Commit Graph

15 Commits

Author SHA1 Message Date
Douglas Gregor e5e8347496 Don't inherit the "unavailable" attribute from an overridden superclass method.
Fixes rdar://problem/22922259.

llvm-svn: 248950
2015-09-30 21:34:33 +00:00
Douglas Gregor d2a713e41b Don't inherit availability information when implementing a protocol requirement.
When an Objective-C method implements a protocol requirement, do not
inherit any availability information from the protocol
requirement. Rather, check that the implementation is not less
available than the protocol requirement, as we do when overriding a
method that has availability. Fixes rdar://problem/22734745.

llvm-svn: 248949
2015-09-30 21:27:42 +00:00
Ted Kremenek c004b4d3a1 Tweak availability checking to look through typedef declarations.
llvm-svn: 237396
2015-05-14 22:07:25 +00:00
Nico Weber 0055a19926 Add -Wpartial-availability.
This warns when using decls that are not available on all deployment targets.
For example, a call to

  - (void)ppartialMethod __attribute__((availability(macosx,introduced=10.8)));

will warn if -mmacosx-version-min is set to less than 10.8.

To silence the warning, one has to explicitly redeclare the method like so:

  @interface Whatever(MountainLionAPI)
  - (void)ppartialMethod;
  @end

This way, one cannot accidentally call a function that isn't available
everywhere.  Having to add the redeclaration will hopefully remind the user
to add an explicit respondsToSelector: call as well.

Some projects build against old SDKs to get this effect, but building against
old SDKs suppresses some bug fixes -- see http://crbug.com/463171 for examples.
The hope is that SDK headers are annotated well enough with availability
attributes that new SDK + this warning offers the same amount of protection
as using an old SDK.

llvm-svn: 232750
2015-03-19 19:18:22 +00:00
Fariborz Jahanian 38c53fbf1f Objective-C. Recover from missing interface decl.
and checking on availability of method declaration
instead of crashing. // rdar://18059669

llvm-svn: 216191
2014-08-21 17:06:57 +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
Ted Kremenek c20bb32c45 Add test case calling a deprecated method from a subclass that reimplements that method gets a warning.
Test case from <rdar://problem/11627873>.

llvm-svn: 179070
2013-04-08 23:39:32 +00:00
Ted Kremenek b54457242c Rework how ObjC method inherit deprecated/availability.
New rule:
- Method decls in @implementation are considered "redeclarations"
  and inherit deprecated/availability from the @interface.
- All other cases are consider overrides, which do not inherit
  deprecated/availability.  For example:

  (a) @interface redeclares a method in an adopted protocol.
  (b) A subclass redeclares a method in a superclass.
  (c) A protocol redeclares a method from another protocol it adopts.

The idea is that API authors should have the ability to easily
move availability/deprecated up and down a class/protocol hierarchy.
A redeclaration means that the availability/deprecation is a blank
slate.

Fixes <rdar://problem/13574571>

llvm-svn: 178937
2013-04-06 00:34:27 +00:00
Douglas Gregor 43dc0c7d60 One can have an unavailable method overridden by an available method,
but not vice-versa. Fix bug introduced in r172567 and noticed by
Jordan, thanks!

llvm-svn: 172586
2013-01-16 00:54:48 +00:00
Douglas Gregor 66a8ca0f7f When checking availability attributes for consistency between an
overriding and overridden method, allow the overridden method to have
a narrower contract (introduced earlier, deprecated/obsoleted later)
than the overriding method. Fixes <rdar://problem/12992023>.

llvm-svn: 172567
2013-01-15 22:43:08 +00:00
Fariborz Jahanian c491c3f27a availability in structured documents. Takes
care of comments by Dimitri and Doug.

llvm-svn: 164957
2012-10-01 18:42:25 +00:00
Fariborz Jahanian 3da28f80e3 objective-c: merge deprecated/unavailable attributes to
the overriding deprecated/unavailable method.
// rdar://11475360

llvm-svn: 158022
2012-06-05 21:14:46 +00:00
Fariborz Jahanian 08a1eb77c5 with -Wdeprecated, include a note to its deprecated declaration
location. // rdar://10893232

llvm-svn: 155385
2012-04-23 20:30:52 +00:00
Douglas Gregor 83dea558bc Add a test triple. Who knew that all the world wasn't darwin?
llvm-svn: 140408
2011-09-23 20:28:32 +00:00
Douglas Gregor b1fa148837 Don't propagate the 'availability' attribute through declaration
merging for overrides. One might want to make a method's availability
in a superclass different from that of its subclass. Fixes
<rdar://problem/10166223>.

llvm-svn: 140406
2011-09-23 20:23:42 +00:00