clang  6.0.0svn
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 
19 #include "llvm/ADT/StringRef.h"
20 
21 namespace clang {
22 
23 /// \brief 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 ///
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.
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
AvailabilitySpec(VersionTuple Version, StringRef Platform, SourceLocation BeginLoc, SourceLocation EndLoc)
Definition: Availability.h:43
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:26
StringRef getPlatform() const
Definition: Availability.h:53
AvailabilitySpec(SourceLocation StarLoc)
This constructor is used when representing the '*' case.
Definition: Availability.h:49
SourceLocation getBeginLoc() const
Definition: Availability.h:54
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero)...
Definition: VersionTuple.h:69
Encodes a location in the source.
VersionTuple getVersion() const
Definition: Availability.h:52
SourceLocation getEndLoc() const
Definition: Availability.h:55
Dataflow Directional Tag Classes.
Defines the clang::SourceLocation class and associated facilities.
Defines the clang::VersionTuple class, which represents a version in the form major[.minor[.subminor]].
bool isOtherPlatformSpec() const
Returns true when this represents the '*' case.
Definition: Availability.h:58
One specifier in an expression.
Definition: Availability.h:31