Skip to content

Commit ac2a625

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 7b07268 commit ac2a625

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
@@ -704,21 +704,15 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
704704
Opts.VerifySyntaxTree = true;
705705
}
706706

707+
// Configure lexing to parse and remember comments if:
708+
// - Emitting a swiftdoc/swiftsourceinfo
709+
// - Performing index-while-building
710+
// - Emitting a symbol graph file
707711
// If we are asked to emit a module documentation file, configure lexing and
708712
// parsing to remember comments.
709-
if (FrontendOpts.InputsAndOutputs.hasModuleDocOutputPath()) {
710-
Opts.AttachCommentsToDecls = true;
711-
}
712-
713-
// If we are doing index-while-building, configure lexing and parsing to
714-
// remember comments.
715-
if (!FrontendOpts.IndexStorePath.empty()) {
716-
Opts.AttachCommentsToDecls = true;
717-
}
718-
719-
// If we are emitting a symbol graph file, configure lexing and parsing to
720-
// remember comments.
721-
if (FrontendOpts.EmitSymbolGraph) {
713+
if (FrontendOpts.InputsAndOutputs.hasModuleDocOutputPath() ||
714+
FrontendOpts.InputsAndOutputs.hasModuleSourceInfoOutputPath() ||
715+
!FrontendOpts.IndexStorePath.empty() || FrontendOpts.EmitSymbolGraph) {
722716
Opts.AttachCommentsToDecls = true;
723717
}
724718

0 commit comments

Comments
 (0)