Skip to content

Commit 8649e82

Browse files
committed
[Frontend] Rework -emit-supported-features mode into -emit-supported-arguments
The "featues" part was never actually implemented and Swift Driver is replying on information about arguments, so instead of removing this mode, let's scope it down to "arguments" to be deprecated in the future.
1 parent ab4ff0a commit 8649e82

File tree

11 files changed

+49
-44
lines changed

11 files changed

+49
-44
lines changed

include/swift/Basic/FileTypes.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ TYPE("fine-module-trace", FineModuleTrace, "", "")
7878
// Complete dependency information for the given Swift files as JSON.
7979
TYPE("json-dependencies", JSONDependencies, "dependencies.json", "")
8080

81-
// Complete feature information for the given Swift compiler.
82-
TYPE("json-features", JSONFeatures, "features.json", "")
81+
// Complete supported argument information for the given Swift compiler.
82+
TYPE("json-arguments", JSONArguments, "arguments.json", "")
8383

8484
// Gathered compile-time-known value information for the given Swift input file as JSON.
8585
TYPE("const-values", ConstValues, "swiftconstvalues", "")

include/swift/Frontend/FrontendOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class FrontendOptions {
201201

202202
ScanDependencies, ///< Scan dependencies of Swift source files
203203
PrintVersion, ///< Print version information.
204-
PrintFeature, ///< Print supported feature of this compiler
204+
PrintArguments, ///< Print supported arguments of this compiler
205205
};
206206

207207
/// Indicates the action the user requested that the frontend perform.

include/swift/Option/Options.td

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,9 +1654,13 @@ def scan_dependencies : Flag<["-"], "scan-dependencies">,
16541654
HelpText<"Scan dependencies of the given Swift sources">, ModeOpt,
16551655
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>;
16561656

1657-
def emit_supported_features : Flag<["-"], "emit-supported-features">,
1658-
HelpText<"Emit a JSON file including all supported compiler features">, ModeOpt,
1657+
def emit_supported_arguments : Flag<["-"], "emit-supported-arguments">,
1658+
HelpText<"Emit a JSON file including all supported compiler arguments">, ModeOpt,
16591659
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>;
1660+
def emit_supported_features : Flag<["-"], "emit-supported-features">,
1661+
HelpText<"This is a compatibility alias for '-emit-supported-arguments'">, ModeOpt,
1662+
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild, HelpHidden]>,
1663+
Alias<emit_supported_arguments>;
16601664

16611665
def enable_incremental_imports :
16621666
Flag<["-"], "enable-incremental-imports">,

lib/Basic/FileTypes.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ bool file_types::isTextual(ID Id) {
112112
case file_types::TY_PackageSwiftModuleInterfaceFile:
113113
case file_types::TY_SwiftOverlayFile:
114114
case file_types::TY_JSONDependencies:
115-
case file_types::TY_JSONFeatures:
115+
case file_types::TY_JSONArguments:
116116
case file_types::TY_SwiftABIDescriptor:
117117
case file_types::TY_SwiftAPIDescriptor:
118118
case file_types::TY_ConstValues:
@@ -195,7 +195,7 @@ bool file_types::isAfterLLVM(ID Id) {
195195
case file_types::TY_PrivateSwiftModuleInterfaceFile:
196196
case file_types::TY_PackageSwiftModuleInterfaceFile:
197197
case file_types::TY_JSONDependencies:
198-
case file_types::TY_JSONFeatures:
198+
case file_types::TY_JSONArguments:
199199
case file_types::TY_IndexUnitOutputPath:
200200
case file_types::TY_SwiftABIDescriptor:
201201
case file_types::TY_SwiftAPIDescriptor:
@@ -257,7 +257,7 @@ bool file_types::isPartOfSwiftCompilation(ID Id) {
257257
case file_types::TY_YAMLOptRecord:
258258
case file_types::TY_BitstreamOptRecord:
259259
case file_types::TY_JSONDependencies:
260-
case file_types::TY_JSONFeatures:
260+
case file_types::TY_JSONArguments:
261261
case file_types::TY_IndexUnitOutputPath:
262262
case file_types::TY_SwiftABIDescriptor:
263263
case file_types::TY_SwiftAPIDescriptor:
@@ -321,7 +321,7 @@ bool file_types::isProducedFromDiagnostics(ID Id) {
321321
case file_types::TY_YAMLOptRecord:
322322
case file_types::TY_BitstreamOptRecord:
323323
case file_types::TY_JSONDependencies:
324-
case file_types::TY_JSONFeatures:
324+
case file_types::TY_JSONArguments:
325325
case file_types::TY_IndexUnitOutputPath:
326326
case file_types::TY_SwiftABIDescriptor:
327327
case file_types::TY_SwiftAPIDescriptor:

lib/Driver/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,7 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
17081708
case file_types::TY_SwiftCrossImportDir:
17091709
case file_types::TY_SwiftOverlayFile:
17101710
case file_types::TY_JSONDependencies:
1711-
case file_types::TY_JSONFeatures:
1711+
case file_types::TY_JSONArguments:
17121712
case file_types::TY_SwiftABIDescriptor:
17131713
case file_types::TY_SwiftAPIDescriptor:
17141714
case file_types::TY_ConstValues:

lib/Driver/ToolChains.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,8 @@ const char *ToolChain::JobContext::computeFrontendModeForCompile() const {
754754
return "-emit-imported-modules";
755755
case file_types::TY_JSONDependencies:
756756
return "-scan-dependencies";
757-
case file_types::TY_JSONFeatures:
758-
return "-emit-supported-features";
757+
case file_types::TY_JSONArguments:
758+
return "-emit-supported-arguments";
759759
case file_types::TY_IndexData:
760760
return "-typecheck";
761761
case file_types::TY_Remapping:
@@ -1041,7 +1041,7 @@ ToolChain::constructInvocation(const BackendJobAction &job,
10411041
case file_types::TY_ClangModuleFile:
10421042
case file_types::TY_IndexData:
10431043
case file_types::TY_JSONDependencies:
1044-
case file_types::TY_JSONFeatures:
1044+
case file_types::TY_JSONArguments:
10451045
llvm_unreachable("Cannot be output from backend job");
10461046
case file_types::TY_Swift:
10471047
case file_types::TY_dSYM:

lib/Frontend/ArgsToFrontendOptionsConverter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,8 +682,8 @@ ArgsToFrontendOptionsConverter::determineRequestedAction(const ArgList &args) {
682682
return FrontendOptions::ActionType::CompileModuleFromInterface;
683683
if (Opt.matches(OPT_typecheck_module_from_interface))
684684
return FrontendOptions::ActionType::TypecheckModuleFromInterface;
685-
if (Opt.matches(OPT_emit_supported_features))
686-
return FrontendOptions::ActionType::PrintFeature;
685+
if (Opt.matches(OPT_emit_supported_arguments))
686+
return FrontendOptions::ActionType::PrintArguments;
687687
llvm_unreachable("Unhandled mode option");
688688
}
689689

lib/Frontend/ArgsToFrontendOutputsConverter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ static bool shouldEmitFineModuleTrace(FrontendOptions::ActionType action) {
451451
case swift::FrontendOptions::ActionType::DumpPCM:
452452
case swift::FrontendOptions::ActionType::ScanDependencies:
453453
case swift::FrontendOptions::ActionType::PrintVersion:
454-
case swift::FrontendOptions::ActionType::PrintFeature:
454+
case swift::FrontendOptions::ActionType::PrintArguments:
455455
return false;
456456
}
457457
}

lib/Frontend/FrontendOptions.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bool FrontendOptions::needsProperModuleName(ActionType action) {
5858
case ActionType::Immediate:
5959
case ActionType::REPL:
6060
case ActionType::PrintVersion:
61-
case ActionType::PrintFeature:
61+
case ActionType::PrintArguments:
6262
return false;
6363
case ActionType::EmitAssembly:
6464
case ActionType::EmitIRGen:
@@ -82,7 +82,7 @@ bool FrontendOptions::shouldActionOnlyParse(ActionType action) {
8282
case ActionType::EmitImportedModules:
8383
case ActionType::ScanDependencies:
8484
case ActionType::PrintVersion:
85-
case ActionType::PrintFeature:
85+
case ActionType::PrintArguments:
8686
return true;
8787
default:
8888
return false;
@@ -103,7 +103,7 @@ bool FrontendOptions::doesActionRequireSwiftStandardLibrary(ActionType action) {
103103
case ActionType::DumpPCM:
104104
case ActionType::CompileModuleFromInterface:
105105
case ActionType::TypecheckModuleFromInterface:
106-
case ActionType::PrintFeature:
106+
case ActionType::PrintArguments:
107107
return false;
108108
case ActionType::ResolveImports:
109109
case ActionType::Typecheck:
@@ -138,7 +138,7 @@ bool FrontendOptions::doesActionRequireInputs(ActionType action) {
138138
switch (action) {
139139
case ActionType::NoneAction:
140140
case ActionType::PrintVersion:
141-
case ActionType::PrintFeature:
141+
case ActionType::PrintArguments:
142142
return false;
143143
case ActionType::REPL:
144144
case ActionType::Parse:
@@ -181,7 +181,7 @@ bool FrontendOptions::doesActionPerformEndOfPipelineActions(ActionType action) {
181181
switch (action) {
182182
case ActionType::NoneAction:
183183
case ActionType::PrintVersion:
184-
case ActionType::PrintFeature:
184+
case ActionType::PrintArguments:
185185
case ActionType::EmitPCH:
186186
case ActionType::EmitPCM:
187187
case ActionType::DumpPCM:
@@ -226,7 +226,7 @@ bool FrontendOptions::supportCompilationCaching(ActionType action) {
226226
switch (action) {
227227
case ActionType::NoneAction:
228228
case ActionType::PrintVersion:
229-
case ActionType::PrintFeature:
229+
case ActionType::PrintArguments:
230230
case ActionType::DumpPCM:
231231
case ActionType::REPL:
232232
case ActionType::Parse:
@@ -362,8 +362,8 @@ FrontendOptions::formatForPrincipalOutputFileForAction(ActionType action) {
362362

363363
case ActionType::ScanDependencies:
364364
return TY_JSONDependencies;
365-
case ActionType::PrintFeature:
366-
return TY_JSONFeatures;
365+
case ActionType::PrintArguments:
366+
return TY_JSONArguments;
367367
}
368368
llvm_unreachable("unhandled action");
369369
}
@@ -386,7 +386,7 @@ bool FrontendOptions::canActionEmitDependencies(ActionType action) {
386386
case ActionType::REPL:
387387
case ActionType::DumpPCM:
388388
case ActionType::PrintVersion:
389-
case ActionType::PrintFeature:
389+
case ActionType::PrintArguments:
390390
return false;
391391
case ActionType::ResolveImports:
392392
case ActionType::Typecheck:
@@ -432,7 +432,7 @@ bool FrontendOptions::canActionEmitReferenceDependencies(ActionType action) {
432432
case ActionType::DumpPCM:
433433
case ActionType::ScanDependencies:
434434
case ActionType::PrintVersion:
435-
case ActionType::PrintFeature:
435+
case ActionType::PrintArguments:
436436
return false;
437437
case ActionType::Typecheck:
438438
case ActionType::MergeModules:
@@ -482,7 +482,7 @@ bool FrontendOptions::canActionEmitModuleSummary(ActionType action) {
482482
case ActionType::MergeModules:
483483
case ActionType::EmitModuleOnly:
484484
case ActionType::PrintVersion:
485-
case ActionType::PrintFeature:
485+
case ActionType::PrintArguments:
486486
return false;
487487
case ActionType::EmitSIL:
488488
case ActionType::EmitLoweredSIL:
@@ -519,7 +519,7 @@ bool FrontendOptions::canActionEmitClangHeader(ActionType action) {
519519
case ActionType::DumpPCM:
520520
case ActionType::ScanDependencies:
521521
case ActionType::PrintVersion:
522-
case ActionType::PrintFeature:
522+
case ActionType::PrintArguments:
523523
return false;
524524
case ActionType::Typecheck:
525525
case ActionType::MergeModules:
@@ -560,7 +560,7 @@ bool FrontendOptions::canActionEmitLoadedModuleTrace(ActionType action) {
560560
case ActionType::DumpPCM:
561561
case ActionType::ScanDependencies:
562562
case ActionType::PrintVersion:
563-
case ActionType::PrintFeature:
563+
case ActionType::PrintArguments:
564564
return false;
565565
case ActionType::ResolveImports:
566566
case ActionType::Typecheck:
@@ -610,7 +610,7 @@ bool FrontendOptions::canActionEmitModuleSemanticInfo(ActionType action) {
610610
case ActionType::DumpPCM:
611611
case ActionType::ScanDependencies:
612612
case ActionType::PrintVersion:
613-
case ActionType::PrintFeature:
613+
case ActionType::PrintArguments:
614614
case ActionType::EmitSIL:
615615
case ActionType::EmitLoweredSIL:
616616
case ActionType::EmitSIBGen:
@@ -653,7 +653,7 @@ bool FrontendOptions::canActionEmitConstValues(ActionType action) {
653653
case ActionType::DumpPCM:
654654
case ActionType::ScanDependencies:
655655
case ActionType::PrintVersion:
656-
case ActionType::PrintFeature:
656+
case ActionType::PrintArguments:
657657
return false;
658658
case ActionType::Typecheck:
659659
case ActionType::MergeModules:
@@ -698,7 +698,7 @@ bool FrontendOptions::canActionEmitModule(ActionType action) {
698698
case ActionType::DumpPCM:
699699
case ActionType::ScanDependencies:
700700
case ActionType::PrintVersion:
701-
case ActionType::PrintFeature:
701+
case ActionType::PrintArguments:
702702
return false;
703703
case ActionType::MergeModules:
704704
case ActionType::EmitModuleOnly:
@@ -744,7 +744,7 @@ bool FrontendOptions::canActionEmitInterface(ActionType action) {
744744
case ActionType::EmitPCM:
745745
case ActionType::DumpPCM:
746746
case ActionType::ScanDependencies:
747-
case ActionType::PrintFeature:
747+
case ActionType::PrintArguments:
748748
return false;
749749
case ActionType::ResolveImports:
750750
case ActionType::Typecheck:
@@ -787,7 +787,7 @@ bool FrontendOptions::canActionEmitAPIDescriptor(ActionType action) {
787787
case ActionType::EmitPCM:
788788
case ActionType::DumpPCM:
789789
case ActionType::ScanDependencies:
790-
case ActionType::PrintFeature:
790+
case ActionType::PrintArguments:
791791
return false;
792792
case ActionType::ResolveImports:
793793
case ActionType::Typecheck:
@@ -838,7 +838,7 @@ bool FrontendOptions::doesActionProduceOutput(ActionType action) {
838838
case ActionType::EmitPCM:
839839
case ActionType::DumpPCM:
840840
case ActionType::ScanDependencies:
841-
case ActionType::PrintFeature:
841+
case ActionType::PrintArguments:
842842
return true;
843843

844844
case ActionType::TypecheckModuleFromInterface:
@@ -889,7 +889,7 @@ bool FrontendOptions::doesActionProduceTextualOutput(ActionType action) {
889889
case ActionType::DumpPCM:
890890
case ActionType::ScanDependencies:
891891
case ActionType::PrintVersion:
892-
case ActionType::PrintFeature:
892+
case ActionType::PrintArguments:
893893
return true;
894894
}
895895
llvm_unreachable("unhandled action");
@@ -916,7 +916,7 @@ bool FrontendOptions::doesActionGenerateSIL(ActionType action) {
916916
case ActionType::DumpPCM:
917917
case ActionType::ScanDependencies:
918918
case ActionType::PrintVersion:
919-
case ActionType::PrintFeature:
919+
case ActionType::PrintArguments:
920920
return false;
921921
case ActionType::EmitSILGen:
922922
case ActionType::EmitSIBGen:
@@ -967,7 +967,7 @@ bool FrontendOptions::doesActionGenerateIR(ActionType action) {
967967
case ActionType::DumpPCM:
968968
case ActionType::ScanDependencies:
969969
case ActionType::PrintVersion:
970-
case ActionType::PrintFeature:
970+
case ActionType::PrintArguments:
971971
return false;
972972
case ActionType::Immediate:
973973
case ActionType::REPL:
@@ -1011,7 +1011,7 @@ bool FrontendOptions::doesActionBuildModuleFromInterface(ActionType action) {
10111011
case ActionType::DumpPCM:
10121012
case ActionType::ScanDependencies:
10131013
case ActionType::PrintVersion:
1014-
case ActionType::PrintFeature:
1014+
case ActionType::PrintArguments:
10151015
case ActionType::Immediate:
10161016
case ActionType::REPL:
10171017
case ActionType::EmitIRGen:

lib/FrontendTool/FrontendTool.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ static void printSingleFrontendOpt(llvm::opt::OptTable &table, options::ID id,
11311131
}
11321132
}
11331133

1134-
static bool printSwiftFeature(CompilerInstance &instance) {
1134+
static bool printSwiftArguments(CompilerInstance &instance) {
11351135
ASTContext &context = instance.getASTContext();
11361136
const CompilerInvocation &invocation = instance.getInvocation();
11371137
const FrontendOptions &opts = invocation.getFrontendOptions();
@@ -1223,8 +1223,8 @@ static bool performAction(CompilerInstance &Instance,
12231223
return Instance.getASTContext().hadError();
12241224
case FrontendOptions::ActionType::PrintVersion:
12251225
return printSwiftVersion(Instance.getInvocation());
1226-
case FrontendOptions::ActionType::PrintFeature:
1227-
return printSwiftFeature(Instance);
1226+
case FrontendOptions::ActionType::PrintArguments:
1227+
return printSwiftArguments(Instance);
12281228
case FrontendOptions::ActionType::REPL:
12291229
llvm::report_fatal_error("Compiler-internal integrated REPL has been "
12301230
"removed; use the LLDB-enhanced REPL instead.");
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
// RUN: %target-swift-frontend -emit-supported-arguments %s | %FileCheck %s
12
// RUN: %target-swift-frontend -emit-supported-features %s | %FileCheck %s
23

34
// CHECK: "SupportedArguments"
45
// CHECK: "abi"
56
// CHECK: "emit-module"
67
// CHECK: "LastOption"
7-
// CHECK: "SupportedFeatures"
8-
// CHECK: "LastFeature"
8+
// CHECK-NOT: "SupportedFeatures"
9+
// CHECK-NOT: "LastFeature"

0 commit comments

Comments
 (0)