@@ -435,6 +435,10 @@ static void ParseModuleInterfaceArgs(ModuleInterfaceOptions &Opts,
435
435
// / Checks if an arg is generally allowed to be included
436
436
// / in a module interface
437
437
static bool ShouldIncludeModuleInterfaceArg (const Arg *A) {
438
+ if (!A->getOption ().hasFlag (options::ModuleInterfaceOption) &&
439
+ !A->getOption ().hasFlag (options::ModuleInterfaceOptionIgnorable))
440
+ return false ;
441
+
438
442
if (!A->getOption ().matches (options::OPT_enable_experimental_feature))
439
443
return true ;
440
444
@@ -459,43 +463,47 @@ static void SaveModuleInterfaceArgs(ModuleInterfaceOptions &Opts,
459
463
ArgList &Args, DiagnosticEngine &Diags) {
460
464
if (!FOpts.InputsAndOutputs .hasModuleInterfaceOutputPath ())
461
465
return ;
462
-
463
- ArgStringList RenderedArgs;
464
- ArgStringList RenderedArgsForPackageOnly;
465
- ArgStringList RenderedArgsIgnorable;
466
+
467
+ struct RenderedInterfaceArgs {
468
+ ArgStringList Standard = {};
469
+ ArgStringList Ignorable = {};
470
+ };
471
+
472
+ RenderedInterfaceArgs PublicArgs{};
473
+ RenderedInterfaceArgs PackageArgs{};
474
+
475
+ auto interfaceArgListForArg = [&](Arg *A) -> ArgStringList & {
476
+ bool ignorable =
477
+ A->getOption ().hasFlag (options::ModuleInterfaceOptionIgnorable);
478
+ if (ShouldIncludeArgInPackageInterfaceOnly (A, Args))
479
+ return ignorable ? PackageArgs.Ignorable : PackageArgs.Standard ;
480
+
481
+ return ignorable ? PublicArgs.Ignorable : PublicArgs.Standard ;
482
+ };
466
483
467
484
for (auto A : Args) {
468
485
if (!ShouldIncludeModuleInterfaceArg (A))
469
486
continue ;
470
487
471
- if (A->getOption ().hasFlag (options::ModuleInterfaceOptionIgnorable)) {
472
- A->render (Args, RenderedArgsIgnorable);
473
- } else if (A->getOption ().hasFlag (options::ModuleInterfaceOption)) {
474
- if (ShouldIncludeArgInPackageInterfaceOnly (A, Args))
475
- A->render (Args, RenderedArgsForPackageOnly);
476
- else
477
- A->render (Args, RenderedArgs);
478
- }
479
- }
480
- {
481
- llvm::raw_string_ostream OS (Opts.Flags );
482
- interleave (RenderedArgs,
483
- [&](const char *Argument) { PrintArg (OS, Argument, StringRef ()); },
484
- [&] { OS << " " ; });
485
- }
486
- {
487
- llvm::raw_string_ostream OS (Opts.FlagsForPackageOnly );
488
- interleave (
489
- RenderedArgsForPackageOnly,
490
- [&](const char *Argument) { PrintArg (OS, Argument, StringRef ()); },
491
- [&] { OS << " " ; });
492
- }
493
- {
494
- llvm::raw_string_ostream OS (Opts.IgnorableFlags );
495
- interleave (RenderedArgsIgnorable,
496
- [&](const char *Argument) { PrintArg (OS, Argument, StringRef ()); },
497
- [&] { OS << " " ; });
498
- }
488
+ ArgStringList &ArgList = interfaceArgListForArg (A);
489
+ A->render (Args, ArgList);
490
+ }
491
+
492
+ auto updateInterfaceOpts = [](ModuleInterfaceOptions::InterfaceFlags &Flags,
493
+ RenderedInterfaceArgs &RenderedArgs) {
494
+ auto printFlags = [](std::string &str, ArgStringList argList) {
495
+ llvm::raw_string_ostream OS (str);
496
+ interleave (
497
+ argList,
498
+ [&](const char *Argument) { PrintArg (OS, Argument, StringRef ()); },
499
+ [&] { OS << " " ; });
500
+ };
501
+ printFlags (Flags.Flags , RenderedArgs.Standard );
502
+ printFlags (Flags.IgnorableFlags , RenderedArgs.Ignorable );
503
+ };
504
+
505
+ updateInterfaceOpts (Opts.PublicFlags , PublicArgs);
506
+ updateInterfaceOpts (Opts.PackageFlags , PackageArgs);
499
507
}
500
508
501
509
enum class CxxCompatMode {
0 commit comments