clang 10.0.0git

Availability.h
Go to the documentation of this file.
1 //===--- Availability.h - Classes for availability --------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This files defines some classes that implement availability checking.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef LLVM_CLANG_AST_AVAILABILITY_H
14 #define LLVM_CLANG_AST_AVAILABILITY_H
15
16 #include "clang/Basic/SourceLocation.h"
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/Support/VersionTuple.h"
19
20 namespace clang {
21
22 /// One specifier in an @available expression.
23 ///
24 /// \code
25 /// @available(macos 10.10, *)
26 /// \endcode
27 ///
28 /// Here, 'macos 10.10' and '*' both map to an instance of this type.
29 ///
30 class AvailabilitySpec {
31 /// Represents the version that this specifier requires. If the host OS
32 /// version is greater than or equal to Version, the @available will evaluate
33 /// to true.
34 VersionTuple Version;
35
36 /// Name of the platform that Version corresponds to.
37 StringRef Platform;
38
39 SourceLocation BeginLoc, EndLoc;
40
41 public:
42 AvailabilitySpec(VersionTuple Version, StringRef Platform,
43 SourceLocation BeginLoc, SourceLocation EndLoc)
44 : Version(Version), Platform(Platform), BeginLoc(BeginLoc),
45 EndLoc(EndLoc) {}
46
47 /// This constructor is used when representing the '*' case.
48 AvailabilitySpec(SourceLocation StarLoc)
49 : BeginLoc(StarLoc), EndLoc(StarLoc) {}
50
51 VersionTuple getVersion() const { return Version; }
52 StringRef getPlatform() const { return Platform; }
53 SourceLocation getBeginLoc() const { return BeginLoc; }
54 SourceLocation getEndLoc() const { return EndLoc; }
55
56 /// Returns true when this represents the '*' case.
57 bool isOtherPlatformSpec() const { return Version.empty(); }
58 };
59
60 } // end namespace clang
61
62 #endif
clang::AvailabilitySpec::AvailabilitySpec
AvailabilitySpec(VersionTuple Version, StringRef Platform, SourceLocation BeginLoc, SourceLocation EndLoc)
Definition: Availability.h:42
clang::AvailabilitySpec::getPlatform
StringRef getPlatform() const
Definition: Availability.h:52
clang::AvailabilitySpec::AvailabilitySpec
AvailabilitySpec(SourceLocation StarLoc)
This constructor is used when representing the &#39;*&#39; case.
Definition: Availability.h:48
clang::AvailabilitySpec::getBeginLoc
SourceLocation getBeginLoc() const
Definition: Availability.h:53
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::AvailabilitySpec::getVersion
VersionTuple getVersion() const
Definition: Availability.h:51
clang::AvailabilitySpec::getEndLoc
SourceLocation getEndLoc() const
Definition: Availability.h:54
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
SourceLocation.h
Defines the clang::SourceLocation class and associated facilities.
clang::AvailabilitySpec::isOtherPlatformSpec
bool isOtherPlatformSpec() const
Returns true when this represents the &#39;*&#39; case.
Definition: Availability.h:57
clang::AvailabilitySpec
One specifier in an expression.
Definition: Availability.h:30