Skip to content

Commit 4c5d87e

Browse files
committed
[Gardening] Move options setup code into argument parsing
1 parent 1fd2ac5 commit 4c5d87e

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,23 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
634634
Opts.VerifySyntaxTree = true;
635635
}
636636

637+
// If we are asked to emit a module documentation file, configure lexing and
638+
// parsing to remember comments.
639+
if (FrontendOpts.InputsAndOutputs.hasModuleDocOutputPath()) {
640+
Opts.AttachCommentsToDecls = true;
641+
}
642+
643+
// If we are doing index-while-building, configure lexing and parsing to
644+
// remember comments.
645+
if (!FrontendOpts.IndexStorePath.empty()) {
646+
Opts.AttachCommentsToDecls = true;
647+
}
648+
649+
// If we're parsing SIL, access control doesn't make sense to enforce.
650+
if (FrontendOpts.InputKind == InputFileKind::SIL) {
651+
Opts.EnableAccessControl = false;
652+
}
653+
637654
return HadError || UnsupportedOS || UnsupportedArch;
638655
}
639656

lib/Frontend/Frontend.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -298,24 +298,8 @@ bool CompilerInstance::setup(const CompilerInvocation &Invok) {
298298
setUpLLVMArguments();
299299
setUpDiagnosticOptions();
300300

301-
const auto &frontendOpts = Invocation.getFrontendOptions();
302-
303-
// If we are asked to emit a module documentation file, configure lexing and
304-
// parsing to remember comments.
305-
if (frontendOpts.InputsAndOutputs.hasModuleDocOutputPath())
306-
Invocation.getLangOptions().AttachCommentsToDecls = true;
307-
308-
// If we are doing index-while-building, configure lexing and parsing to
309-
// remember comments.
310-
if (!frontendOpts.IndexStorePath.empty()) {
311-
Invocation.getLangOptions().AttachCommentsToDecls = true;
312-
}
313-
314301
assert(Lexer::isIdentifier(Invocation.getModuleName()));
315302

316-
if (isInSILMode())
317-
Invocation.getLangOptions().EnableAccessControl = false;
318-
319303
if (setUpInputs())
320304
return true;
321305

0 commit comments

Comments
 (0)