@@ -594,10 +594,6 @@ Driver::buildCompilation(const ToolChain &TC,
594
594
Incremental = false ;
595
595
}
596
596
597
- bool BatchMode = ArgList->hasFlag (options::OPT_enable_batch_mode,
598
- options::OPT_disable_batch_mode,
599
- false );
600
-
601
597
bool SaveTemps = ArgList->hasArg (options::OPT_save_temps);
602
598
bool ContinueBuildingAfterErrors =
603
599
ArgList->hasArg (options::OPT_continue_building_after_errors);
@@ -631,6 +627,8 @@ Driver::buildCompilation(const ToolChain &TC,
631
627
632
628
// Determine the OutputInfo for the driver.
633
629
OutputInfo OI;
630
+ bool BatchMode = false ;
631
+ OI.CompilerMode = computeCompilerMode (*TranslatedArgList, Inputs, BatchMode);
634
632
buildOutputInfo (TC, *TranslatedArgList, BatchMode, Inputs, OI);
635
633
636
634
if (Diags.hadAnyError ())
@@ -1122,8 +1120,6 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
1122
1120
? file_types::TY_Nothing
1123
1121
: file_types::TY_Object;
1124
1122
1125
- OI.CompilerMode = computeCompilerMode (Args, Inputs);
1126
-
1127
1123
if (const Arg *A = Args.getLastArg (options::OPT_num_threads)) {
1128
1124
if (BatchMode) {
1129
1125
Diags.diagnose (SourceLoc (), diag::warning_cannot_multithread_batch_mode);
@@ -1393,26 +1389,31 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
1393
1389
1394
1390
OutputInfo::Mode
1395
1391
Driver::computeCompilerMode (const DerivedArgList &Args,
1396
- const InputFileList &Inputs) const {
1392
+ const InputFileList &Inputs,
1393
+ bool &BatchModeOut) const {
1397
1394
1398
1395
if (driverKind == Driver::DriverKind::Interactive)
1399
1396
return Inputs.empty () ? OutputInfo::Mode::REPL
1400
1397
: OutputInfo::Mode::Immediate;
1401
1398
1402
- const Arg *ArgRequiringWMO = Args.getLastArg (
1399
+ const Arg *ArgRequiringSingleCompile = Args.getLastArg (
1403
1400
options::OPT_whole_module_optimization, options::OPT_index_file);
1404
1401
1405
- if (!ArgRequiringWMO)
1402
+ BatchModeOut = Args.hasFlag (options::OPT_enable_batch_mode,
1403
+ options::OPT_disable_batch_mode,
1404
+ false );
1405
+
1406
+ if (!ArgRequiringSingleCompile)
1406
1407
return OutputInfo::Mode::StandardCompile;
1407
1408
1408
- // Test for -enable- batch- mode, rather than the BatchMode flag that is
1409
- // passed into the caller because the diagnostic is intended to warn against
1410
- // overriding *explicit* batch mode. No warning should be given if in batch
1411
- // mode by default.
1412
- if (Args. hasArg (options::OPT_enable_batch_mode))
1409
+ // Override batch mode if given -wmo or -index-file.
1410
+ if (BatchModeOut) {
1411
+ BatchModeOut = false ;
1412
+ // Emit a warning about such overriding (FIXME: we might conditionalize
1413
+ // this based on the user or xcode passing -disable-batch-mode).
1413
1414
Diags.diagnose (SourceLoc (), diag::warn_ignoring_batch_mode,
1414
- ArgRequiringWMO ->getOption ().getPrefixedName ());
1415
-
1415
+ ArgRequiringSingleCompile ->getOption ().getPrefixedName ());
1416
+ }
1416
1417
return OutputInfo::Mode::SingleCompile;
1417
1418
}
1418
1419
0 commit comments