]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/AST/Availability.h
Update clang to release_39 branch r276489, and resolve conflicts.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / AST / Availability.h
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 "clang/Basic/VersionTuple.h"
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 ///
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