@@ -475,6 +475,10 @@ static void ParseModuleInterfaceArgs(ModuleInterfaceOptions &Opts,
475
475
// / Checks if an arg is generally allowed to be included
476
476
// / in a module interface
477
477
static bool ShouldIncludeModuleInterfaceArg (const Arg *A) {
478
+ if (!A->getOption ().hasFlag (options::ModuleInterfaceOption) &&
479
+ !A->getOption ().hasFlag (options::ModuleInterfaceOptionIgnorable))
480
+ return false ;
481
+
478
482
if (!A->getOption ().matches (options::OPT_enable_experimental_feature))
479
483
return true ;
480
484
@@ -499,43 +503,47 @@ static void SaveModuleInterfaceArgs(ModuleInterfaceOptions &Opts,
499
503
ArgList &Args, DiagnosticEngine &Diags) {
500
504
if (!FOpts.InputsAndOutputs .hasModuleInterfaceOutputPath ())
501
505
return ;
502
-
503
- ArgStringList RenderedArgs;
504
- ArgStringList RenderedArgsForPackageOnly;
505
- ArgStringList RenderedArgsIgnorable;
506
+
507
+ struct RenderedInterfaceArgs {
508
+ ArgStringList Standard = {};
509
+ ArgStringList Ignorable = {};
510
+ };
511
+
512
+ RenderedInterfaceArgs PublicArgs{};
513
+ RenderedInterfaceArgs PackageArgs{};
514
+
515
+ auto interfaceArgListForArg = [&](Arg *A) -> ArgStringList & {
516
+ bool ignorable =
517
+ A->getOption ().hasFlag (options::ModuleInterfaceOptionIgnorable);
518
+ if (ShouldIncludeArgInPackageInterfaceOnly (A, Args))
519
+ return ignorable ? PackageArgs.Ignorable : PackageArgs.Standard ;
520
+
521
+ return ignorable ? PublicArgs.Ignorable : PublicArgs.Standard ;
522
+ };
506
523
507
524
for (auto A : Args) {
508
525
if (!ShouldIncludeModuleInterfaceArg (A))
509
526
continue ;
510
527
511
- if (A->getOption ().hasFlag (options::ModuleInterfaceOptionIgnorable)) {
512
- A->render (Args, RenderedArgsIgnorable);
513
- } else if (A->getOption ().hasFlag (options::ModuleInterfaceOption)) {
514
- if (ShouldIncludeArgInPackageInterfaceOnly (A, Args))
515
- A->render (Args, RenderedArgsForPackageOnly);
516
- else
517
- A->render (Args, RenderedArgs);
518
- }
519
- }
520
- {
521
- llvm::raw_string_ostream OS (Opts.Flags );
522
- interleave (RenderedArgs,
523
- [&](const char *Argument) { PrintArg (OS, Argument, StringRef ()); },
524
- [&] { OS << " " ; });
525
- }
526
- {
527
- llvm::raw_string_ostream OS (Opts.FlagsForPackageOnly );
528
- interleave (
529
- RenderedArgsForPackageOnly,
530
- [&](const char *Argument) { PrintArg (OS, Argument, StringRef ()); },
531
- [&] { OS << " " ; });
532
- }
533
- {
534
- llvm::raw_string_ostream OS (Opts.IgnorableFlags );
535
- interleave (RenderedArgsIgnorable,
536
- [&](const char *Argument) { PrintArg (OS, Argument, StringRef ()); },
537
- [&] { OS << " " ; });
538
- }
528
+ ArgStringList &ArgList = interfaceArgListForArg (A);
529
+ A->render (Args, ArgList);
530
+ }
531
+
532
+ auto updateInterfaceOpts = [](ModuleInterfaceOptions::InterfaceFlags &Flags,
533
+ RenderedInterfaceArgs &RenderedArgs) {
534
+ auto printFlags = [](std::string &str, ArgStringList argList) {
535
+ llvm::raw_string_ostream OS (str);
536
+ interleave (
537
+ argList,
538
+ [&](const char *Argument) { PrintArg (OS, Argument, StringRef ()); },
539
+ [&] { OS << " " ; });
540
+ };
541
+ printFlags (Flags.Flags , RenderedArgs.Standard );
542
+ printFlags (Flags.IgnorableFlags , RenderedArgs.Ignorable );
543
+ };
544
+
545
+ updateInterfaceOpts (Opts.PublicFlags , PublicArgs);
546
+ updateInterfaceOpts (Opts.PackageFlags , PackageArgs);
539
547
}
540
548
541
549
enum class CxxCompatMode {
0 commit comments