]> granicus.if.org Git - clang/commit
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)
commit86877a86797ac4e347e43ae2eab6cad0944e59a4
tree7b7af45a2545cdd70a83bd11dd928108f1b93248
parented642255720097e356e4e4d4e8fae3e1d6aa1bf4
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232750 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Sema/Sema.h
lib/Sema/DelayedDiagnostic.cpp
lib/Sema/SemaDeclAttr.cpp
lib/Sema/SemaExpr.cpp
test/Sema/attr-availability.c
test/SemaObjC/attr-availability.m
test/SemaObjC/property-deprecated-warning.m