clang  9.0.0svn
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 
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 ///
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.
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
AvailabilitySpec(VersionTuple Version, StringRef Platform, SourceLocation BeginLoc, SourceLocation EndLoc)
Definition: Availability.h:42
StringRef getPlatform() const
Definition: Availability.h:52
AvailabilitySpec(SourceLocation StarLoc)
This constructor is used when representing the '*' case.
Definition: Availability.h:48
SourceLocation getBeginLoc() const
Definition: Availability.h:53
Encodes a location in the source.
VersionTuple getVersion() const
Definition: Availability.h:51
SourceLocation getEndLoc() const
Definition: Availability.h:54
Dataflow Directional Tag Classes.
Defines the clang::SourceLocation class and associated facilities.
bool isOtherPlatformSpec() const
Returns true when this represents the '*' case.
Definition: Availability.h:57
One specifier in an expression.
Definition: Availability.h:30