@@ -94,6 +94,19 @@ class AvailabilitySpec : public ASTAllocated<AvailabilitySpec> {
9494 llvm::VersionTuple version,
9595 SourceRange versionRange);
9696
97+ // / Creates an availability specification that guards execution based on the
98+ // / run-time platform and version, e.g., macOS >= 10.10.
99+ static AvailabilitySpec *createPlatformVersioned (ASTContext &ctx,
100+ PlatformKind platform,
101+ SourceLoc platformLoc,
102+ llvm::VersionTuple version,
103+ SourceRange versionRange);
104+
105+ AvailabilitySpec *clone (ASTContext &ctx) const {
106+ return new (ctx)
107+ AvailabilitySpec (Kind, Domain, SrcRange, Version, VersionStartLoc);
108+ }
109+
97110 AvailabilitySpecKind getKind () const { return Kind; }
98111
99112 bool isWildcard () { return getKind () == AvailabilitySpecKind::Wildcard; }
@@ -112,6 +125,11 @@ class AvailabilitySpec : public ASTAllocated<AvailabilitySpec> {
112125 // The platform version to compare against.
113126 llvm::VersionTuple getVersion () const ;
114127
128+ // The version to be used in codegen for version comparisons at run time.
129+ // This is required to support beta versions of macOS Big Sur that
130+ // report 10.16 at run time.
131+ llvm::VersionTuple getRuntimeVersion () const { return Version; }
132+
115133 SourceRange getVersionSrcRange () const {
116134 if (!VersionStartLoc)
117135 return SourceRange ();
@@ -123,44 +141,6 @@ class AvailabilitySpec : public ASTAllocated<AvailabilitySpec> {
123141 void setMacroLoc (SourceLoc loc) { MacroLoc = loc; }
124142};
125143
126- // / An availability specification that guards execution based on the
127- // / run-time platform and version, e.g., OS X >= 10.10.
128- class PlatformVersionConstraintAvailabilitySpec : public AvailabilitySpec {
129- static std::optional<AvailabilityDomain>
130- getDomainForPlatform (PlatformKind Platform) {
131- if (Platform != PlatformKind::none)
132- return AvailabilityDomain::forPlatform (Platform);
133- return std::nullopt ;
134- }
135-
136- public:
137- PlatformVersionConstraintAvailabilitySpec (PlatformKind Platform,
138- SourceLoc PlatformLoc,
139- llvm::VersionTuple Version,
140- SourceRange VersionSrcRange)
141- : AvailabilitySpec(AvailabilitySpecKind::PlatformVersionConstraint,
142- getDomainForPlatform (Platform),
143- SourceRange(PlatformLoc, VersionSrcRange.End), Version,
144- VersionSrcRange.Start) {}
145- // The version to be used in codegen for version comparisons at run time.
146- // This is required to support beta versions of macOS Big Sur that
147- // report 10.16 at run time.
148- llvm::VersionTuple getRuntimeVersion () const ;
149-
150- void print (raw_ostream &OS, unsigned Indent) const ;
151-
152- static bool classof (const AvailabilitySpec *Spec) {
153- return Spec->getKind () == AvailabilitySpecKind::PlatformVersionConstraint;
154- }
155-
156- void *
157- operator new (size_t Bytes, ASTContext &C,
158- unsigned Alignment = alignof (PlatformVersionConstraintAvailabilitySpec)){
159- return AvailabilitySpec::operator new (Bytes, C, AllocationArena::Permanent,
160- Alignment);
161- }
162- };
163-
164144// / Maps of macro name and version to availability specifications.
165145// / Organized as two nested \c DenseMap keyed first on the macro name then
166146// / the macro version. This structure allows to peek at macro names before
0 commit comments