Sema: Reject version specs in @available attributes for custom domains.

This commit is contained in:
Allan Shortlidge
2025-01-30 22:21:17 -08:00
parent 5c61a2d53e
commit 1e76f19be9
9 changed files with 62 additions and 31 deletions

View File

@@ -3319,7 +3319,7 @@ public:
return attr->getRawIntroduced();
}
/// The source range of the `introduced:` component.
/// The source range of the `introduced:` version component.
SourceRange getIntroducedSourceRange() const { return attr->IntroducedRange; }
/// Returns the effective range in which the declaration with this attribute
@@ -3331,11 +3331,17 @@ public:
return attr->getRawDeprecated();
}
/// The source range of the `deprecated:` version component.
SourceRange getDeprecatedSourceRange() const { return attr->DeprecatedRange; }
/// The version tuple written in source for the `obsoleted:` component.
std::optional<llvm::VersionTuple> getObsoleted() const {
return attr->getRawObsoleted();
}
/// The source range of the `obsoleted:` version component.
SourceRange getObsoletedSourceRange() const { return attr->ObsoletedRange; }
/// Returns the `message:` field of the attribute, or an empty string.
StringRef getMessage() const { return attr->Message; }

View File

@@ -190,6 +190,10 @@ public:
return PlatformKind::none;
}
/// Returns true if availability for this domain can be specified in terms of
/// version ranges.
bool isVersioned() const;
/// Returns true if this domain is considered active in the current
/// compilation context.
bool isActive(const ASTContext &ctx) const;

View File

@@ -1579,10 +1579,6 @@ ERROR(attr_availability_expected_equal,none,
ERROR(attr_availability_expected_version,none,
"expected version number in '%0' attribute", (StringRef))
WARNING(attr_availability_nonspecific_platform_unexpected_version,none,
"unexpected version number in '%0' attribute for non-specific platform "
"'*'", (StringRef))
WARNING(attr_availability_wildcard_ignored,none,
"* as platform name has no effect in '%0' attribute", (StringRef))

View File

@@ -6735,6 +6735,9 @@ ERROR(attr_availability_requires_custom_availability, none,
"specifying '%0' in '%1' attribute requires "
"-enable-experimental-feature CustomAvailability",
(StringRef, const DeclAttribute))
WARNING(attr_availability_unexpected_version,none,
"unexpected version number in '%0' attribute for '%1'",
(const DeclAttribute, StringRef))
ERROR(availability_decl_unavailable, none,
"%0 is unavailable%select{ in %2|}1%select{|: %3}3",