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 16 #include "clang/Basic/SourceLocation.h" 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 /// 30 class AvailabilitySpec { 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: AvailabilitySpec(VersionTuple Version,StringRef Platform,SourceLocation BeginLoc,SourceLocation EndLoc)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. AvailabilitySpec(SourceLocation StarLoc)48 AvailabilitySpec(SourceLocation StarLoc) 49 : BeginLoc(StarLoc), EndLoc(StarLoc) {} 50 getVersion()51 VersionTuple getVersion() const { return Version; } getPlatform()52 StringRef getPlatform() const { return Platform; } getBeginLoc()53 SourceLocation getBeginLoc() const { return BeginLoc; } getEndLoc()54 SourceLocation getEndLoc() const { return EndLoc; } 55 56 /// Returns true when this represents the '*' case. isOtherPlatformSpec()57 bool isOtherPlatformSpec() const { return Version.empty(); } 58 }; 59 60 } // end namespace clang 61 62 #endif 63