File indexing completed on 2026-05-10 08:36:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_CLANG_AST_AVAILABILITY_H
0014 #define LLVM_CLANG_AST_AVAILABILITY_H
0015
0016 #include "clang/Basic/SourceLocation.h"
0017 #include "llvm/ADT/SmallString.h"
0018 #include "llvm/ADT/StringRef.h"
0019 #include "llvm/Support/VersionTuple.h"
0020
0021 namespace clang {
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 class AvailabilitySpec {
0032
0033
0034
0035 VersionTuple Version;
0036
0037
0038 StringRef Platform;
0039
0040 SourceLocation BeginLoc, EndLoc;
0041
0042 public:
0043 AvailabilitySpec(VersionTuple Version, StringRef Platform,
0044 SourceLocation BeginLoc, SourceLocation EndLoc)
0045 : Version(Version), Platform(Platform), BeginLoc(BeginLoc),
0046 EndLoc(EndLoc) {}
0047
0048
0049 AvailabilitySpec(SourceLocation StarLoc)
0050 : BeginLoc(StarLoc), EndLoc(StarLoc) {}
0051
0052 VersionTuple getVersion() const { return Version; }
0053 StringRef getPlatform() const { return Platform; }
0054 SourceLocation getBeginLoc() const { return BeginLoc; }
0055 SourceLocation getEndLoc() const { return EndLoc; }
0056
0057
0058 bool isOtherPlatformSpec() const { return Version.empty(); }
0059 };
0060
0061 class Decl;
0062
0063
0064 struct AvailabilityInfo {
0065
0066 llvm::SmallString<32> Domain;
0067 VersionTuple Introduced;
0068 VersionTuple Deprecated;
0069 VersionTuple Obsoleted;
0070 bool Unavailable = false;
0071 bool UnconditionallyDeprecated = false;
0072 bool UnconditionallyUnavailable = false;
0073
0074 AvailabilityInfo() = default;
0075
0076
0077 bool isDefault() const { return *this == AvailabilityInfo(); }
0078
0079
0080 bool isObsoleted() const { return !Obsoleted.empty(); }
0081
0082
0083
0084 bool isUnavailable() const {
0085 return Unavailable || isUnconditionallyUnavailable();
0086 }
0087
0088
0089
0090
0091 bool isUnconditionallyDeprecated() const { return UnconditionallyDeprecated; }
0092
0093
0094
0095
0096 bool isUnconditionallyUnavailable() const {
0097 return UnconditionallyUnavailable;
0098 }
0099
0100
0101
0102 void mergeWith(AvailabilityInfo Other);
0103
0104 AvailabilityInfo(StringRef Domain, VersionTuple I, VersionTuple D,
0105 VersionTuple O, bool U, bool UD, bool UU)
0106 : Domain(Domain), Introduced(I), Deprecated(D), Obsoleted(O),
0107 Unavailable(U), UnconditionallyDeprecated(UD),
0108 UnconditionallyUnavailable(UU) {}
0109
0110 friend bool operator==(const AvailabilityInfo &Lhs,
0111 const AvailabilityInfo &Rhs);
0112
0113 public:
0114 static AvailabilityInfo createFromDecl(const Decl *Decl);
0115 };
0116
0117 inline bool operator==(const AvailabilityInfo &Lhs,
0118 const AvailabilityInfo &Rhs) {
0119 return std::tie(Lhs.Introduced, Lhs.Deprecated, Lhs.Obsoleted,
0120 Lhs.Unavailable, Lhs.UnconditionallyDeprecated,
0121 Lhs.UnconditionallyUnavailable) ==
0122 std::tie(Rhs.Introduced, Rhs.Deprecated, Rhs.Obsoleted,
0123 Rhs.Unavailable, Rhs.UnconditionallyDeprecated,
0124 Rhs.UnconditionallyUnavailable);
0125 }
0126
0127 }
0128
0129 #endif