Skip to content

Commit e9dcc67

Browse files
committed
[Frontend] Attach comments to decls when emitting .swiftsourceinfo
.swiftsourceinfo contains comment ranges, so parsing should attach comments when it is being emitted. Generally this turned out to be fine because .swiftdoc is usually output as well, but when calling swift-frontend directly in tests that isn't necessarily the case.
1 parent 246bb41 commit e9dcc67

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -711,21 +711,15 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
711711
Opts.VerifySyntaxTree = true;
712712
}
713713

714+
// Configure lexing to parse and remember comments if:
715+
// - Emitting a swiftdoc/swiftsourceinfo
716+
// - Performing index-while-building
717+
// - Emitting a symbol graph file
714718
// If we are asked to emit a module documentation file, configure lexing and
715719
// parsing to remember comments.
716-
if (FrontendOpts.InputsAndOutputs.hasModuleDocOutputPath()) {
717-
Opts.AttachCommentsToDecls = true;
718-
}
719-
720-
// If we are doing index-while-building, configure lexing and parsing to
721-
// remember comments.
722-
if (!FrontendOpts.IndexStorePath.empty()) {
723-
Opts.AttachCommentsToDecls = true;
724-
}
725-
726-
// If we are emitting a symbol graph file, configure lexing and parsing to
727-
// remember comments.
728-
if (FrontendOpts.EmitSymbolGraph) {
720+
if (FrontendOpts.InputsAndOutputs.hasModuleDocOutputPath() ||
721+
FrontendOpts.InputsAndOutputs.hasModuleSourceInfoOutputPath() ||
722+
!FrontendOpts.IndexStorePath.empty() || FrontendOpts.EmitSymbolGraph) {
729723
Opts.AttachCommentsToDecls = true;
730724
}
731725

0 commit comments

Comments
 (0)