[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.
This commit is contained in:
Pavel Yaskevich
2025-04-16 16:34:06 -07:00
parent 55bd906906
commit 18703d64d6
11 changed files with 46 additions and 50 deletions

View File

@@ -78,8 +78,8 @@ TYPE("fine-module-trace", FineModuleTrace, "", "")
// Complete dependency information for the given Swift files as JSON.
TYPE("json-dependencies", JSONDependencies, "dependencies.json", "")
// Complete feature information for the given Swift compiler.
TYPE("json-features", JSONFeatures, "features.json", "")
// Complete supported argument information for the given Swift compiler.
TYPE("json-arguments", JSONArguments, "arguments.json", "")
// Gathered compile-time-known value information for the given Swift input file as JSON.
TYPE("const-values", ConstValues, "swiftconstvalues", "")

View File

@@ -201,7 +201,7 @@ public:
ScanDependencies, ///< Scan dependencies of Swift source files
PrintVersion, ///< Print version information.
PrintFeature, ///< Print supported feature of this compiler
PrintArguments, ///< Print supported arguments of this compiler
};
/// Indicates the action the user requested that the frontend perform.

View File

@@ -1654,9 +1654,13 @@ def scan_dependencies : Flag<["-"], "scan-dependencies">,
HelpText<"Scan dependencies of the given Swift sources">, ModeOpt,
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>;
def emit_supported_features : Flag<["-"], "emit-supported-features">,
HelpText<"Emit a JSON file including all supported compiler features">, ModeOpt,
def emit_supported_arguments : Flag<["-"], "emit-supported-arguments">,
HelpText<"Emit a JSON file including all supported compiler arguments">, ModeOpt,
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>;
def emit_supported_features : Flag<["-"], "emit-supported-features">,
HelpText<"This is a compatibility alias for '-emit-supported-arguments'">, ModeOpt,
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild, HelpHidden]>,
Alias<emit_supported_arguments>;
def enable_incremental_imports :
Flag<["-"], "enable-incremental-imports">,

View File

@@ -112,7 +112,7 @@ bool file_types::isTextual(ID Id) {
case file_types::TY_PackageSwiftModuleInterfaceFile:
case file_types::TY_SwiftOverlayFile:
case file_types::TY_JSONDependencies:
case file_types::TY_JSONFeatures:
case file_types::TY_JSONArguments:
case file_types::TY_SwiftABIDescriptor:
case file_types::TY_SwiftAPIDescriptor:
case file_types::TY_ConstValues:
@@ -195,7 +195,7 @@ bool file_types::isAfterLLVM(ID Id) {
case file_types::TY_PrivateSwiftModuleInterfaceFile:
case file_types::TY_PackageSwiftModuleInterfaceFile:
case file_types::TY_JSONDependencies:
case file_types::TY_JSONFeatures:
case file_types::TY_JSONArguments:
case file_types::TY_IndexUnitOutputPath:
case file_types::TY_SwiftABIDescriptor:
case file_types::TY_SwiftAPIDescriptor:
@@ -257,7 +257,7 @@ bool file_types::isPartOfSwiftCompilation(ID Id) {
case file_types::TY_YAMLOptRecord:
case file_types::TY_BitstreamOptRecord:
case file_types::TY_JSONDependencies:
case file_types::TY_JSONFeatures:
case file_types::TY_JSONArguments:
case file_types::TY_IndexUnitOutputPath:
case file_types::TY_SwiftABIDescriptor:
case file_types::TY_SwiftAPIDescriptor:
@@ -321,7 +321,7 @@ bool file_types::isProducedFromDiagnostics(ID Id) {
case file_types::TY_YAMLOptRecord:
case file_types::TY_BitstreamOptRecord:
case file_types::TY_JSONDependencies:
case file_types::TY_JSONFeatures:
case file_types::TY_JSONArguments:
case file_types::TY_IndexUnitOutputPath:
case file_types::TY_SwiftABIDescriptor:
case file_types::TY_SwiftAPIDescriptor:

View File

@@ -1708,7 +1708,7 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
case file_types::TY_SwiftCrossImportDir:
case file_types::TY_SwiftOverlayFile:
case file_types::TY_JSONDependencies:
case file_types::TY_JSONFeatures:
case file_types::TY_JSONArguments:
case file_types::TY_SwiftABIDescriptor:
case file_types::TY_SwiftAPIDescriptor:
case file_types::TY_ConstValues:

View File

@@ -754,8 +754,8 @@ const char *ToolChain::JobContext::computeFrontendModeForCompile() const {
return "-emit-imported-modules";
case file_types::TY_JSONDependencies:
return "-scan-dependencies";
case file_types::TY_JSONFeatures:
return "-emit-supported-features";
case file_types::TY_JSONArguments:
return "-emit-supported-arguments";
case file_types::TY_IndexData:
return "-typecheck";
case file_types::TY_Remapping:
@@ -1041,7 +1041,7 @@ ToolChain::constructInvocation(const BackendJobAction &job,
case file_types::TY_ClangModuleFile:
case file_types::TY_IndexData:
case file_types::TY_JSONDependencies:
case file_types::TY_JSONFeatures:
case file_types::TY_JSONArguments:
llvm_unreachable("Cannot be output from backend job");
case file_types::TY_Swift:
case file_types::TY_dSYM:

View File

@@ -682,8 +682,8 @@ ArgsToFrontendOptionsConverter::determineRequestedAction(const ArgList &args) {
return FrontendOptions::ActionType::CompileModuleFromInterface;
if (Opt.matches(OPT_typecheck_module_from_interface))
return FrontendOptions::ActionType::TypecheckModuleFromInterface;
if (Opt.matches(OPT_emit_supported_features))
return FrontendOptions::ActionType::PrintFeature;
if (Opt.matches(OPT_emit_supported_arguments))
return FrontendOptions::ActionType::PrintArguments;
llvm_unreachable("Unhandled mode option");
}

View File

@@ -451,7 +451,7 @@ static bool shouldEmitFineModuleTrace(FrontendOptions::ActionType action) {
case swift::FrontendOptions::ActionType::DumpPCM:
case swift::FrontendOptions::ActionType::ScanDependencies:
case swift::FrontendOptions::ActionType::PrintVersion:
case swift::FrontendOptions::ActionType::PrintFeature:
case swift::FrontendOptions::ActionType::PrintArguments:
return false;
}
}

View File

@@ -58,7 +58,7 @@ bool FrontendOptions::needsProperModuleName(ActionType action) {
case ActionType::Immediate:
case ActionType::REPL:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return false;
case ActionType::EmitAssembly:
case ActionType::EmitIRGen:
@@ -82,7 +82,7 @@ bool FrontendOptions::shouldActionOnlyParse(ActionType action) {
case ActionType::EmitImportedModules:
case ActionType::ScanDependencies:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return true;
default:
return false;
@@ -103,7 +103,7 @@ bool FrontendOptions::doesActionRequireSwiftStandardLibrary(ActionType action) {
case ActionType::DumpPCM:
case ActionType::CompileModuleFromInterface:
case ActionType::TypecheckModuleFromInterface:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return false;
case ActionType::ResolveImports:
case ActionType::Typecheck:
@@ -138,7 +138,7 @@ bool FrontendOptions::doesActionRequireInputs(ActionType action) {
switch (action) {
case ActionType::NoneAction:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return false;
case ActionType::REPL:
case ActionType::Parse:
@@ -181,7 +181,7 @@ bool FrontendOptions::doesActionPerformEndOfPipelineActions(ActionType action) {
switch (action) {
case ActionType::NoneAction:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
case ActionType::EmitPCH:
case ActionType::EmitPCM:
case ActionType::DumpPCM:
@@ -226,7 +226,7 @@ bool FrontendOptions::supportCompilationCaching(ActionType action) {
switch (action) {
case ActionType::NoneAction:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
case ActionType::DumpPCM:
case ActionType::REPL:
case ActionType::Parse:
@@ -362,8 +362,8 @@ FrontendOptions::formatForPrincipalOutputFileForAction(ActionType action) {
case ActionType::ScanDependencies:
return TY_JSONDependencies;
case ActionType::PrintFeature:
return TY_JSONFeatures;
case ActionType::PrintArguments:
return TY_JSONArguments;
}
llvm_unreachable("unhandled action");
}
@@ -386,7 +386,7 @@ bool FrontendOptions::canActionEmitDependencies(ActionType action) {
case ActionType::REPL:
case ActionType::DumpPCM:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return false;
case ActionType::ResolveImports:
case ActionType::Typecheck:
@@ -432,7 +432,7 @@ bool FrontendOptions::canActionEmitReferenceDependencies(ActionType action) {
case ActionType::DumpPCM:
case ActionType::ScanDependencies:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return false;
case ActionType::Typecheck:
case ActionType::MergeModules:
@@ -482,7 +482,7 @@ bool FrontendOptions::canActionEmitModuleSummary(ActionType action) {
case ActionType::MergeModules:
case ActionType::EmitModuleOnly:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return false;
case ActionType::EmitSIL:
case ActionType::EmitLoweredSIL:
@@ -519,7 +519,7 @@ bool FrontendOptions::canActionEmitClangHeader(ActionType action) {
case ActionType::DumpPCM:
case ActionType::ScanDependencies:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return false;
case ActionType::Typecheck:
case ActionType::MergeModules:
@@ -560,7 +560,7 @@ bool FrontendOptions::canActionEmitLoadedModuleTrace(ActionType action) {
case ActionType::DumpPCM:
case ActionType::ScanDependencies:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return false;
case ActionType::ResolveImports:
case ActionType::Typecheck:
@@ -610,7 +610,7 @@ bool FrontendOptions::canActionEmitModuleSemanticInfo(ActionType action) {
case ActionType::DumpPCM:
case ActionType::ScanDependencies:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
case ActionType::EmitSIL:
case ActionType::EmitLoweredSIL:
case ActionType::EmitSIBGen:
@@ -653,7 +653,7 @@ bool FrontendOptions::canActionEmitConstValues(ActionType action) {
case ActionType::DumpPCM:
case ActionType::ScanDependencies:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return false;
case ActionType::Typecheck:
case ActionType::MergeModules:
@@ -698,7 +698,7 @@ bool FrontendOptions::canActionEmitModule(ActionType action) {
case ActionType::DumpPCM:
case ActionType::ScanDependencies:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return false;
case ActionType::MergeModules:
case ActionType::EmitModuleOnly:
@@ -744,7 +744,7 @@ bool FrontendOptions::canActionEmitInterface(ActionType action) {
case ActionType::EmitPCM:
case ActionType::DumpPCM:
case ActionType::ScanDependencies:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return false;
case ActionType::ResolveImports:
case ActionType::Typecheck:
@@ -787,7 +787,7 @@ bool FrontendOptions::canActionEmitAPIDescriptor(ActionType action) {
case ActionType::EmitPCM:
case ActionType::DumpPCM:
case ActionType::ScanDependencies:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return false;
case ActionType::ResolveImports:
case ActionType::Typecheck:
@@ -838,7 +838,7 @@ bool FrontendOptions::doesActionProduceOutput(ActionType action) {
case ActionType::EmitPCM:
case ActionType::DumpPCM:
case ActionType::ScanDependencies:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return true;
case ActionType::TypecheckModuleFromInterface:
@@ -889,7 +889,7 @@ bool FrontendOptions::doesActionProduceTextualOutput(ActionType action) {
case ActionType::DumpPCM:
case ActionType::ScanDependencies:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return true;
}
llvm_unreachable("unhandled action");
@@ -916,7 +916,7 @@ bool FrontendOptions::doesActionGenerateSIL(ActionType action) {
case ActionType::DumpPCM:
case ActionType::ScanDependencies:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return false;
case ActionType::EmitSILGen:
case ActionType::EmitSIBGen:
@@ -967,7 +967,7 @@ bool FrontendOptions::doesActionGenerateIR(ActionType action) {
case ActionType::DumpPCM:
case ActionType::ScanDependencies:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
return false;
case ActionType::Immediate:
case ActionType::REPL:
@@ -1011,7 +1011,7 @@ bool FrontendOptions::doesActionBuildModuleFromInterface(ActionType action) {
case ActionType::DumpPCM:
case ActionType::ScanDependencies:
case ActionType::PrintVersion:
case ActionType::PrintFeature:
case ActionType::PrintArguments:
case ActionType::Immediate:
case ActionType::REPL:
case ActionType::EmitIRGen:

View File

@@ -1131,7 +1131,7 @@ static void printSingleFrontendOpt(llvm::opt::OptTable &table, options::ID id,
}
}
static bool printSwiftFeature(CompilerInstance &instance) {
static bool printSwiftArguments(CompilerInstance &instance) {
ASTContext &context = instance.getASTContext();
const CompilerInvocation &invocation = instance.getInvocation();
const FrontendOptions &opts = invocation.getFrontendOptions();
@@ -1227,8 +1227,8 @@ static bool performAction(CompilerInstance &Instance,
return Instance.getASTContext().hadError();
case FrontendOptions::ActionType::PrintVersion:
return printSwiftVersion(Instance.getInvocation());
case FrontendOptions::ActionType::PrintFeature:
return printSwiftFeature(Instance);
case FrontendOptions::ActionType::PrintArguments:
return printSwiftArguments(Instance);
case FrontendOptions::ActionType::REPL:
llvm::report_fatal_error("Compiler-internal integrated REPL has been "
"removed; use the LLDB-enhanced REPL instead.");

View File

@@ -1,8 +0,0 @@
// RUN: %target-swift-frontend -emit-supported-features %s | %FileCheck %s
// CHECK: "SupportedArguments"
// CHECK: "abi"
// CHECK: "emit-module"
// CHECK: "LastOption"
// CHECK: "SupportedFeatures"
// CHECK: "LastFeature"