================
@@ -2697,6 +2698,74 @@ static void handleAvailabilityAttr(Sema &S, Decl *D,
const ParsedAttr &AL) {
}
}
+ // Handle anyAppleOS specially: create implicit platform-specific attributes
+ // instead of the original anyAppleOS attribute.
+ if (II->getName() == "anyappleos") {
+ // Validate and correct anyAppleOS versions.
+ auto ValidateAndCorrectVersion =
+ [&](const llvm::VersionTuple &Version,
+ SourceLocation Loc) -> llvm::VersionTuple {
+ if (Version.empty())
+ return Version;
+ auto [IsValid, CorrectedVersion] =
+ AvailabilitySpec::validateAnyAppleOSVersion(Version);
+ if (!IsValid) {
+ S.Diag(Loc, diag::warn_availability_invalid_os_version)
+ << Version.getAsString() << "anyAppleOS";
+ S.Diag(Loc, diag::note_availability_invalid_os_version_adjusted)
+ << CorrectedVersion.getAsString();
+ }
+ return CorrectedVersion;
+ };
+
+ // Correct the versions.
+ auto CorrectedIntroduced =
+ ValidateAndCorrectVersion(Introduced.Version, Introduced.KeywordLoc);
+ auto CorrectedDeprecated =
+ ValidateAndCorrectVersion(Deprecated.Version, Deprecated.KeywordLoc);
+ auto CorrectedObsoleted =
+ ValidateAndCorrectVersion(Obsoleted.Version, Obsoleted.KeywordLoc);
+
+ auto GetPlatformName = [](const llvm::Triple &T) -> StringRef {
----------------
ahatanak wrote:
I used lambda CreateImplicitAvailabilityAttr because it was called from
multiple places in our internal branch, but it's not needed for open source. I
removed both lambdas.
https://github.com/llvm/llvm-project/pull/181953
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits