Skip to content

Commit 8cd9319

Browse files
committed
AST: Improve ASTDumper output for AvailableAttr.
The platform field now indicates whether the attribute applies universally, to a specific platform, to the Swift language, or to package descriptions. Additionally the output now reflects whether or not the attribute specifies unconditional deprecation or unavailabity or is `noasync`.
1 parent cfb4b8f commit 8cd9319

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

lib/AST/ASTDumper.cpp

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3892,11 +3892,37 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, StringRef>,
38923892
}
38933893
void visitAvailableAttr(AvailableAttr *Attr, StringRef label) {
38943894
printCommon(Attr, "available_attr", label);
3895-
printField(Attr->getPlatform(), "platform");
3896-
if (!Attr->Message.empty())
3897-
printFieldQuoted(Attr->Message, "message");
3898-
if (!Attr->Rename.empty())
3899-
printFieldQuoted(Attr->Rename, "rename");
3895+
switch (Attr->getPlatformAgnosticAvailability()) {
3896+
case PlatformAgnosticAvailabilityKind::None:
3897+
case PlatformAgnosticAvailabilityKind::Deprecated:
3898+
case PlatformAgnosticAvailabilityKind::Unavailable:
3899+
case PlatformAgnosticAvailabilityKind::NoAsync:
3900+
printField(Attr->getPlatform(), "platform");
3901+
break;
3902+
case PlatformAgnosticAvailabilityKind::UnavailableInSwift:
3903+
case PlatformAgnosticAvailabilityKind::SwiftVersionSpecific:
3904+
printFieldQuoted("swift", "platform");
3905+
break;
3906+
case PlatformAgnosticAvailabilityKind::PackageDescriptionVersionSpecific:
3907+
printFieldQuoted("_PackageDescription", "platform");
3908+
break;
3909+
}
3910+
switch (Attr->getPlatformAgnosticAvailability()) {
3911+
case PlatformAgnosticAvailabilityKind::Deprecated:
3912+
printFlag("deprecated");
3913+
break;
3914+
case PlatformAgnosticAvailabilityKind::Unavailable:
3915+
case PlatformAgnosticAvailabilityKind::UnavailableInSwift:
3916+
printFlag("unavailable");
3917+
break;
3918+
case PlatformAgnosticAvailabilityKind::NoAsync:
3919+
printFlag("noasync");
3920+
break;
3921+
case PlatformAgnosticAvailabilityKind::None:
3922+
case PlatformAgnosticAvailabilityKind::SwiftVersionSpecific:
3923+
case PlatformAgnosticAvailabilityKind::PackageDescriptionVersionSpecific:
3924+
break;
3925+
}
39003926
if (Attr->Introduced.has_value())
39013927
printFieldRaw(
39023928
[&](auto &out) { out << Attr->Introduced.value().getAsString(); },
@@ -3909,6 +3935,10 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, StringRef>,
39093935
printFieldRaw(
39103936
[&](auto &out) { out << Attr->Obsoleted.value().getAsString(); },
39113937
"obsoleted");
3938+
if (!Attr->Message.empty())
3939+
printFieldQuoted(Attr->Message, "message");
3940+
if (!Attr->Rename.empty())
3941+
printFieldQuoted(Attr->Rename, "rename");
39123942
printFoot();
39133943
}
39143944
void visitBackDeployedAttr(BackDeployedAttr *Attr, StringRef label) {

0 commit comments

Comments
 (0)