llvm-project/clang/lib/Basic
Douglas Gregor 20b2ebd785 Implement a new 'availability' attribute, that allows one to specify
which versions of an OS provide a certain facility. For example,

  void foo()
  __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6)));

says that the function "foo" was introduced in 10.2, deprecated in
10.4, and completely obsoleted in 10.6. This attribute ties in with
the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that
we want to deploy back to Mac OS X 10.1). There are several concrete
behaviors that this attribute enables, as illustrated with the
function foo() above:

  - If we choose a deployment target >= Mac OS X 10.4, uses of "foo"
    will result in a deprecation warning, as if we had placed
    attribute((deprecated)) on it (but with a better diagnostic)
  - If we choose a deployment target >= Mac OS X 10.6, uses of "foo"
    will result in an "unavailable" warning (in C)/error (in C++), as
    if we had placed attribute((unavailable)) on it
  - If we choose a deployment target prior to 10.2, foo() is
    weak-imported (if it is a kind of entity that can be weak
    imported), as if we had placed the weak_import attribute on it.

Naturally, there can be multiple availability attributes on a
declaration, for different platforms; only the current platform
matters when checking availability attributes.

The only platforms this attribute currently works for are "ios" and
"macosx", since we already have -mxxxx-version-min flags for them and we
have experience there with macro tricks translating down to the
deprecated/unavailable/weak_import attributes. The end goal is to open
this up to other platforms, and even extension to other "platforms"
that are really libraries (say, through a #pragma clang
define_system), but that hasn't yet been designed and we may want to
shake out more issues with this narrower problem first.

Addresses <rdar://problem/6690412>.

As a drive-by bug-fix, if an entity is both deprecated and
unavailable, we only emit the "unavailable" diagnostic.

llvm-svn: 128127
2011-03-23 00:50:03 +00:00
..
Builtins.cpp Test commit. 2011-02-20 00:59:54 +00:00
CMakeLists.txt Implement a new 'availability' attribute, that allows one to specify 2011-03-23 00:50:03 +00:00
ConvertUTF.c Remove tabs, and whitespace cleanups. 2009-09-09 15:08:12 +00:00
Diagnostic.cpp Relax assertion to fail during crash recovery cleanup. 2011-03-21 18:40:10 +00:00
DiagnosticIDs.cpp Teach TextDiagnosticPrinter to print out '-Werror' in addition to the warning flag for a warning mapped to an error. 2011-02-25 01:28:26 +00:00
FileManager.cpp Add FileManager::getNoncachedStatValue, which will resolve relative paths against the working directory specified in the file system options. 2011-03-18 19:23:19 +00:00
FileSystemStatCache.cpp Replace all uses of PathV1::isAbsolute with PathV2::is_{absolute,relative}. 2010-12-17 21:22:22 +00:00
IdentifierTable.cpp Move some of the logic about classifying Objective-C methods into 2011-03-02 01:50:55 +00:00
Makefile Basic: Simplify getClangRepositoryPath and getClangRevision. 2010-09-29 19:15:29 +00:00
SourceLocation.cpp Fix diagnostic pragmas. 2010-12-15 18:44:22 +00:00
SourceManager.cpp Add 'OverridenFilesKeepOriginalName' field in SourceManager which if true the SourceManager 2011-03-08 23:35:24 +00:00
TargetInfo.cpp Implement a new 'availability' attribute, that allows one to specify 2011-03-23 00:50:03 +00:00
Targets.cpp Implement a new 'availability' attribute, that allows one to specify 2011-03-23 00:50:03 +00:00
TokenKinds.cpp This patch adds a PUNCTUATOR macro (specialization of TOK) in TokenKinds.def and makes use of it in tok::getTokenSimpleSpelling. 2009-11-28 16:09:28 +00:00
Version.cpp Basic: Tweak attempt to make version tags work from 'svn export's again, clip 2010-10-11 23:50:34 +00:00
VersionTuple.cpp Implement a new 'availability' attribute, that allows one to specify 2011-03-23 00:50:03 +00:00