add AST printer support for _documentation attribute (#64326)

fixes #64309
fixes rdar://106657906
This commit is contained in:
QuietMisdreavus
2023-03-31 10:33:16 -06:00
committed by GitHub
parent 7064e18c04
commit 47bf147605
2 changed files with 35 additions and 0 deletions

View File

@@ -1393,6 +1393,32 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
break;
}
case DAK_Documentation: {
auto *attr = cast<DocumentationAttr>(this);
Printer.printAttrName("@_documentation");
Printer << "(";
bool needs_comma = !attr->Metadata.empty() && attr->Visibility;
if (attr->Visibility) {
Printer << "visibility: ";
Printer << getAccessLevelSpelling(*attr->Visibility);
}
if (needs_comma) {
Printer << ", ";
}
if (!attr->Metadata.empty()) {
Printer << "metadata: ";
Printer << attr->Metadata;
}
Printer << ")";
break;
}
case DAK_Count:
llvm_unreachable("exceed declaration attribute kinds");

View File

@@ -0,0 +1,9 @@
@_documentation(visibility: public)
enum E
{
}
// The @_documentation attribute caused sourcekit-lsp to crash
// cf. https://github.com/apple/swift/issues/64309
// RUN: %sourcekitd-test -req=cursor -pos=2:6 %s -- %s