From fdd417fceed5acd610af14c3fc0621e3c9e1b1b9 Mon Sep 17 00:00:00 2001
From: Douglas Gregor
Date: Sun, 11 Mar 2012 04:53:21 +0000
Subject: [PATCH] Document the availability attribute
llvm-svn: 152531
---
clang/docs/LanguageExtensions.html | 44 ++++++++++++++++++++++++++++++
clang/lib/Parse/ParseDecl.cpp | 2 +-
2 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/clang/docs/LanguageExtensions.html b/clang/docs/LanguageExtensions.html
index 997d18489ec0..bdb04ac1a5aa 100644
--- a/clang/docs/LanguageExtensions.html
+++ b/clang/docs/LanguageExtensions.html
@@ -30,6 +30,7 @@
Vectors and Extended Vectors
Messages on deprecated and unavailable attributes
Attributes on enumerators
+Availability attribute
Checks for Standard Language Features
Query for this feature with __has_extension(enumerator_attributes).
+
+Availability attribute
+
+Clang introduces the availability
attribute, which can
+be placed on declarations to describe the lifecycle of that
+declaration relative to operating system versions. Consider the function declaration for a hypothetical function f
:
+
+
+void f(void) __attribute__((availability(macosx,introduced=10.4,deprecated=10.6,obsoleted=10.7)));
+
+
+The availability attribute states that f
was introduced in Mac OS X 10.4, deprecated in Mac OS X 10.6, and obsoleted in Mac OS X 10.7. This information is used by Clang to determine when it is safe to use f
: for example, if Clang is instructed to compile code for Mac OS X 10.5, a call to f()
succeeds. If Clang is instructed to compile code for Mac OS X 10.6, the call succeeds but Clang emits a warning specifying that the function is deprecated. Finally, if Clang is instructed to compile code for Mac OS X 10.7, the call fails because f()
is no longer available.
+
+The availablility attribute is a comma-separated list starting with the platform name and then including clauses specifying important milestones in the declaration's lifetime (in any order) along with additional information. Those clauses can be:
+
+
+ - introduced=version
+ - The first version in which this declaration was introduced.
+
+ - deprecated=version
+ - The first version in which this declaration was deprecated, meaning that users should migrate away from this API.
+
+ - obsoleted=version
+ - The first version in which this declaration was obsoleted, meaning that it was removed completely and can no longer be used.
+
+ - unavailable
+ - This declaration is never available on this platform.
+
+ - message=string-literal
+ - Additional message text that Clang will provide when emitting a warning or error about use of a deprecated or obsoleted declaration. Useful to direct users to replacement APIs.
+
+
+Multiple availability attributes can be placed on a declaration, which may correspond to different platforms. Only the availability attribute with the platform corresponding to the target platform will be used; any others will be ignored. If no availability attribute specifies availability for the current target platform, the availability attributes are ignored. Supported platforms are:
+
+
+ - ios
+ - Apple's iOS operating system. The minimum deployment target is specified by the
-mios-version-min=version
or -miphoneos-version-min=version
command-line arguments.
+
+ - macosx
+ - Apple's Mac OS X operating system. The minimum deployment target is specified by the
-mmacosx-version-min=version
command-line argument.
+
+
Checks for Standard Language Features
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 296a3f5facad..2eb66d50d821 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -536,7 +536,7 @@ VersionTuple Parser::ParseVersionTuple(SourceRange &Range) {
/// version-arg:
/// 'introduced' '=' version
/// 'deprecated' '=' version
-/// 'removed' = version
+/// 'obsoleted' = version
/// 'unavailable'
/// opt-message:
/// 'message' '='