Skip to content

Commit a1d885c

Browse files
committed
Module groups: if group name collector is enabled, we continuously serialize doc-comment table for comment-free decls to preserve the group information.
1 parent 90ca7be commit a1d885c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/Serialization/Serialization.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3607,6 +3607,9 @@ class DeclGroupNameContext {
36073607
GroupNameCollectorFromJson(StringRef RecordPath) :
36083608
GroupNameCollector(!RecordPath.empty()), RecordPath(RecordPath) {}
36093609
StringRef getGroupNameInternal(const ValueDecl *VD) override {
3610+
// We need the file path, so there has to be a location.
3611+
if (VD->getLoc().isInvalid())
3612+
return NullGroupName;
36103613
auto PathOp = VD->getDeclContext()->getParentSourceFile()->getBufferID();
36113614
if (!PathOp.hasValue())
36123615
return NullGroupName;
@@ -3647,6 +3650,10 @@ class DeclGroupNameContext {
36473650
}
36483651
return llvm::makeArrayRef(ViewBuffer);
36493652
}
3653+
3654+
bool isEnable() {
3655+
return pNameCollector->Enable;
3656+
}
36503657
};
36513658

36523659
static void writeGroupNames(const comment_block::GroupNamesLayout &GroupNames,
@@ -3691,7 +3698,7 @@ static void writeDeclCommentTable(
36913698

36923699
// Skip the decl if it does not have a comment.
36933700
RawComment Raw = VD->getRawComment();
3694-
if (Raw.Comments.empty())
3701+
if (Raw.Comments.empty() && !GroupContext.isEnable())
36953702
return true;
36963703

36973704
// Compute USR.

test/SourceKit/SourceDocInfo/cursor_info.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func nonDefaultArgNames(external1 local1: Int, _ local2: Int, external3 local3:
100100
// CHECK2-NEXT: s:ZFsoi1pFTSiSi_Si
101101
// CHECK2-NEXT: (Int, Int) -> Int{{$}}
102102
// CHECK2-NEXT: Swift{{$}}
103+
// CHECK2-NEXT: <Group>Math</Group>
103104
// CHECK2-NEXT: SYSTEM
104105
// CHECK2-NEXT: <Declaration>func +(lhs: <Type usr="s:Si">Int</Type>, rhs: <Type usr="s:Si">Int</Type>) -&gt; <Type usr="s:Si">Int</Type></Declaration>
105106
// CHECK2-NEXT: <decl.function.operator.infix>func <decl.name>+</decl.name>(<decl.var.parameter><decl.var.parameter.name.local>lhs</decl.var.parameter.name.local>: <ref.struct usr="s:Si">Int</ref.struct></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name.local>rhs</decl.var.parameter.name.local>: <ref.struct usr="s:Si">Int</ref.struct></decl.var.parameter>) -&gt; <ref.struct usr="s:Si">Int</ref.struct></decl.function.operator.infix>

0 commit comments

Comments
 (0)