mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
RequirementMachine: Add flags for completion depth and step limits
This commit is contained in:
@@ -433,6 +433,14 @@ namespace swift {
|
|||||||
/// Enables debugging output from the requirement machine.
|
/// Enables debugging output from the requirement machine.
|
||||||
bool DebugRequirementMachine = false;
|
bool DebugRequirementMachine = false;
|
||||||
|
|
||||||
|
/// Maximum iteration count for requirement machine confluent completion
|
||||||
|
/// algorithm.
|
||||||
|
unsigned RequirementMachineStepLimit = 1000;
|
||||||
|
|
||||||
|
/// Maximum term length for requirement machine confluent completion
|
||||||
|
/// algorithm.
|
||||||
|
unsigned RequirementMachineDepthLimit = 10;
|
||||||
|
|
||||||
/// Sets the target we are building for and updates platform conditions
|
/// Sets the target we are building for and updates platform conditions
|
||||||
/// to match.
|
/// to match.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -283,6 +283,14 @@ def disable_requirement_machine : Flag<["-"], "disable-requirement-machine">,
|
|||||||
def debug_requirement_machine : Flag<["-"], "debug-requirement-machine">,
|
def debug_requirement_machine : Flag<["-"], "debug-requirement-machine">,
|
||||||
HelpText<"Enables debugging output from the generics implementation">;
|
HelpText<"Enables debugging output from the generics implementation">;
|
||||||
|
|
||||||
|
def requirement_machine_step_limit : Separate<["-"], "requirement-machine-step-limit">,
|
||||||
|
Flags<[FrontendOption, HelpHidden, DoesNotAffectIncrementalBuild]>,
|
||||||
|
HelpText<"Set the maximum steps before we give up on confluent completion">;
|
||||||
|
|
||||||
|
def requirement_machine_depth_limit : Separate<["-"], "requirement-machine-depth-limit">,
|
||||||
|
Flags<[FrontendOption, HelpHidden, DoesNotAffectIncrementalBuild]>,
|
||||||
|
HelpText<"Set the maximum depth before we give up on confluent completion">;
|
||||||
|
|
||||||
def debug_generic_signatures : Flag<["-"], "debug-generic-signatures">,
|
def debug_generic_signatures : Flag<["-"], "debug-generic-signatures">,
|
||||||
HelpText<"Debug generic signatures">;
|
HelpText<"Debug generic signatures">;
|
||||||
|
|
||||||
|
|||||||
@@ -205,8 +205,9 @@ void RequirementMachine::addGenericSignature(CanGenericSignature sig) {
|
|||||||
Impl->System.initialize(std::move(builder.Rules),
|
Impl->System.initialize(std::move(builder.Rules),
|
||||||
std::move(builder.Protocols));
|
std::move(builder.Protocols));
|
||||||
|
|
||||||
// FIXME: Add command line flag
|
auto result = Impl->System.computeConfluentCompletion(
|
||||||
auto result = Impl->System.computeConfluentCompletion(1000, 10);
|
Context.LangOpts.RequirementMachineStepLimit,
|
||||||
|
Context.LangOpts.RequirementMachineDepthLimit);
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case RewriteSystem::CompletionResult::Success:
|
case RewriteSystem::CompletionResult::Success:
|
||||||
|
|||||||
@@ -798,6 +798,28 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
|||||||
Opts.DebugRequirementMachine = Args.hasArg(
|
Opts.DebugRequirementMachine = Args.hasArg(
|
||||||
OPT_debug_requirement_machine);
|
OPT_debug_requirement_machine);
|
||||||
|
|
||||||
|
if (const Arg *A = Args.getLastArg(OPT_requirement_machine_step_limit)) {
|
||||||
|
unsigned limit;
|
||||||
|
if (StringRef(A->getValue()).getAsInteger(10, limit)) {
|
||||||
|
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
|
||||||
|
A->getAsString(Args), A->getValue());
|
||||||
|
HadError = true;
|
||||||
|
} else {
|
||||||
|
Opts.RequirementMachineStepLimit = limit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (const Arg *A = Args.getLastArg(OPT_requirement_machine_depth_limit)) {
|
||||||
|
unsigned limit;
|
||||||
|
if (StringRef(A->getValue()).getAsInteger(10, limit)) {
|
||||||
|
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
|
||||||
|
A->getAsString(Args), A->getValue());
|
||||||
|
HadError = true;
|
||||||
|
} else {
|
||||||
|
Opts.RequirementMachineDepthLimit = limit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return HadError || UnsupportedOS || UnsupportedArch;
|
return HadError || UnsupportedOS || UnsupportedArch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user