Skip to content

Commit 47bf147

Browse files
add AST printer support for _documentation attribute (#64326)
fixes #64309 fixes rdar://106657906
1 parent 7064e18 commit 47bf147

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
@@ -1393,6 +1393,32 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
13931393
break;
13941394
}
13951395

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

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)