Skip to content

Commit 392710c

Browse files
add AST printer support for _documentation attribute (#64326)
fixes #64309 fixes rdar://106657906
1 parent 93e77f3 commit 392710c

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

lib/AST/Attr.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,32 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
13941394
break;
13951395
}
13961396

1397+
case DAK_Documentation: {
1398+
auto *attr = cast<DocumentationAttr>(this);
1399+
1400+
Printer.printAttrName("@_documentation");
1401+
Printer << "(";
1402+
1403+
bool needs_comma = !attr->Metadata.empty() && attr->Visibility;
1404+
1405+
if (attr->Visibility) {
1406+
Printer << "visibility: ";
1407+
Printer << getAccessLevelSpelling(*attr->Visibility);
1408+
}
1409+
1410+
if (needs_comma) {
1411+
Printer << ", ";
1412+
}
1413+
1414+
if (!attr->Metadata.empty()) {
1415+
Printer << "metadata: ";
1416+
Printer << attr->Metadata;
1417+
}
1418+
1419+
Printer << ")";
1420+
break;
1421+
}
1422+
13971423
case DAK_Count:
13981424
llvm_unreachable("exceed declaration attribute kinds");
13991425

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@_documentation(visibility: public)
2+
enum E
3+
{
4+
}
5+
6+
// The @_documentation attribute caused sourcekit-lsp to crash
7+
// cf. https://github.com/apple/swift/issues/64309
8+
9+
// RUN: %sourcekitd-test -req=cursor -pos=2:6 %s -- %s

0 commit comments

Comments
 (0)