1 //===--- Availability.h - Classes for availability --------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This files defines some classes that implement availability checking.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_AST_AVAILABILITY_H
15 #define LLVM_CLANG_AST_AVAILABILITY_H
17 #include "clang/Basic/SourceLocation.h"
18 #include "clang/Basic/VersionTuple.h"
19 #include "llvm/ADT/StringRef.h"
23 /// \brief One specifier in an @available expression.
26 /// @available(macos 10.10, *)
29 /// Here, 'macos 10.10' and '*' both map to an instance of this type.
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
37 /// Name of the platform that Version corresponds to.
40 SourceLocation BeginLoc, EndLoc;
43 AvailabilitySpec(VersionTuple Version, StringRef Platform,
44 SourceLocation BeginLoc, SourceLocation EndLoc)
45 : Version(Version), Platform(Platform), BeginLoc(BeginLoc),
48 /// This constructor is used when representing the '*' case.
49 AvailabilitySpec(SourceLocation StarLoc)
50 : BeginLoc(StarLoc), EndLoc(StarLoc) {}
52 VersionTuple getVersion() const { return Version; }
53 StringRef getPlatform() const { return Platform; }
54 SourceLocation getBeginLoc() const { return BeginLoc; }
55 SourceLocation getEndLoc() const { return EndLoc; }
57 /// Returns true when this represents the '*' case.
58 bool isOtherPlatformSpec() const { return Version.empty(); }
61 } // end namespace clang