@@ -551,10 +551,6 @@ Driver::buildCompilation(const ToolChain &TC,
551
551
Incremental = false ;
552
552
}
553
553
554
- bool BatchMode = ArgList->hasFlag (options::OPT_enable_batch_mode,
555
- options::OPT_disable_batch_mode,
556
- false );
557
-
558
554
bool SaveTemps = ArgList->hasArg (options::OPT_save_temps);
559
555
bool ContinueBuildingAfterErrors =
560
556
ArgList->hasArg (options::OPT_continue_building_after_errors);
@@ -588,6 +584,8 @@ Driver::buildCompilation(const ToolChain &TC,
588
584
589
585
// Determine the OutputInfo for the driver.
590
586
OutputInfo OI;
587
+ bool BatchMode = false ;
588
+ OI.CompilerMode = computeCompilerMode (*TranslatedArgList, Inputs, BatchMode);
591
589
buildOutputInfo (TC, *TranslatedArgList, BatchMode, Inputs, OI);
592
590
593
591
if (Diags.hadAnyError ())
@@ -1102,8 +1100,6 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
1102
1100
? file_types::TY_Nothing
1103
1101
: file_types::TY_Object;
1104
1102
1105
- OI.CompilerMode = computeCompilerMode (Args, Inputs);
1106
-
1107
1103
if (const Arg *A = Args.getLastArg (options::OPT_num_threads)) {
1108
1104
if (BatchMode) {
1109
1105
Diags.diagnose (SourceLoc (), diag::warning_cannot_multithread_batch_mode);
@@ -1373,26 +1369,31 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
1373
1369
1374
1370
OutputInfo::Mode
1375
1371
Driver::computeCompilerMode (const DerivedArgList &Args,
1376
- const InputFileList &Inputs) const {
1372
+ const InputFileList &Inputs,
1373
+ bool &BatchModeOut) const {
1377
1374
1378
1375
if (driverKind == Driver::DriverKind::Interactive)
1379
1376
return Inputs.empty () ? OutputInfo::Mode::REPL
1380
1377
: OutputInfo::Mode::Immediate;
1381
1378
1382
- const Arg *ArgRequiringWMO = Args.getLastArg (
1379
+ const Arg *ArgRequiringSingleCompile = Args.getLastArg (
1383
1380
options::OPT_whole_module_optimization, options::OPT_index_file);
1384
1381
1385
- if (!ArgRequiringWMO)
1382
+ BatchModeOut = Args.hasFlag (options::OPT_enable_batch_mode,
1383
+ options::OPT_disable_batch_mode,
1384
+ false );
1385
+
1386
+ if (!ArgRequiringSingleCompile)
1386
1387
return OutputInfo::Mode::StandardCompile;
1387
1388
1388
- // Test for -enable- batch- mode, rather than the BatchMode flag that is
1389
- // passed into the caller because the diagnostic is intended to warn against
1390
- // overriding *explicit* batch mode. No warning should be given if in batch
1391
- // mode by default.
1392
- if (Args. hasArg (options::OPT_enable_batch_mode))
1389
+ // Override batch mode if given -wmo or -index-file.
1390
+ if (BatchModeOut) {
1391
+ BatchModeOut = false ;
1392
+ // Emit a warning about such overriding (FIXME: we might conditionalize
1393
+ // this based on the user or xcode passing -disable-batch-mode).
1393
1394
Diags.diagnose (SourceLoc (), diag::warn_ignoring_batch_mode,
1394
- ArgRequiringWMO ->getOption ().getPrefixedName ());
1395
-
1395
+ ArgRequiringSingleCompile ->getOption ().getPrefixedName ());
1396
+ }
1396
1397
return OutputInfo::Mode::SingleCompile;
1397
1398
}
1398
1399
0 commit comments