Add -Wpartial-availability.
authorNico Weber <nicolasweber@gmx.de>
Thu, 19 Mar 2015 19:18:22 +0000 (19:18 +0000)
committerNico Weber <nicolasweber@gmx.de>
Thu, 19 Mar 2015 19:18:22 +0000 (19:18 +0000)
commit0055a19926b7b23cfc49b5b645769698ba5aa129
tree80013c2d762e266554b7c5e8c0e0b25640bf6598
parentf3d3db65de4e2937cd2efa3de984b2d35c9ec5c0
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
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/DelayedDiagnostic.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/attr-availability.c
clang/test/SemaObjC/attr-availability.m
clang/test/SemaObjC/property-deprecated-warning.m