mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Module groups: if group name collector is enabled, we continuously serialize doc-comment table for comment-free decls to preserve the group information.
This commit is contained in:
@@ -3607,6 +3607,9 @@ class DeclGroupNameContext {
|
||||
GroupNameCollectorFromJson(StringRef RecordPath) :
|
||||
GroupNameCollector(!RecordPath.empty()), RecordPath(RecordPath) {}
|
||||
StringRef getGroupNameInternal(const ValueDecl *VD) override {
|
||||
// We need the file path, so there has to be a location.
|
||||
if (VD->getLoc().isInvalid())
|
||||
return NullGroupName;
|
||||
auto PathOp = VD->getDeclContext()->getParentSourceFile()->getBufferID();
|
||||
if (!PathOp.hasValue())
|
||||
return NullGroupName;
|
||||
@@ -3647,6 +3650,10 @@ public:
|
||||
}
|
||||
return llvm::makeArrayRef(ViewBuffer);
|
||||
}
|
||||
|
||||
bool isEnable() {
|
||||
return pNameCollector->Enable;
|
||||
}
|
||||
};
|
||||
|
||||
static void writeGroupNames(const comment_block::GroupNamesLayout &GroupNames,
|
||||
@@ -3691,7 +3698,7 @@ static void writeDeclCommentTable(
|
||||
|
||||
// Skip the decl if it does not have a comment.
|
||||
RawComment Raw = VD->getRawComment();
|
||||
if (Raw.Comments.empty())
|
||||
if (Raw.Comments.empty() && !GroupContext.isEnable())
|
||||
return true;
|
||||
|
||||
// Compute USR.
|
||||
|
||||
@@ -100,6 +100,7 @@ func nonDefaultArgNames(external1 local1: Int, _ local2: Int, external3 local3:
|
||||
// CHECK2-NEXT: s:ZFsoi1pFTSiSi_Si
|
||||
// CHECK2-NEXT: (Int, Int) -> Int{{$}}
|
||||
// CHECK2-NEXT: Swift{{$}}
|
||||
// CHECK2-NEXT: <Group>Math</Group>
|
||||
// CHECK2-NEXT: SYSTEM
|
||||
// CHECK2-NEXT: <Declaration>func +(lhs: <Type usr="s:Si">Int</Type>, rhs: <Type usr="s:Si">Int</Type>) -> <Type usr="s:Si">Int</Type></Declaration>
|
||||
// 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>) -> <ref.struct usr="s:Si">Int</ref.struct></decl.function.operator.infix>
|
||||
|
||||
Reference in New Issue
Block a user