clang 8.0.0

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