mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Introduce a command-line option to limit the # of typo corrections.
Typo correction can be particularly expensive, so introduce a command-line flag to limit the number of typo corrections we will perform per type-checker instance. Default this limit to 10. Addresses rdar://problem/28469270 to some extent.
This commit is contained in:
@@ -981,7 +981,21 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
||||
= A->getOption().matches(OPT_enable_access_control);
|
||||
}
|
||||
|
||||
Opts.DisableTypoCorrection |= Args.hasArg(OPT_disable_typo_correction);
|
||||
if (auto A = Args.getLastArg(OPT_disable_typo_correction,
|
||||
OPT_typo_correction_limit)) {
|
||||
if (A->getOption().matches(OPT_disable_typo_correction))
|
||||
Opts.TypoCorrectionLimit = 0;
|
||||
else {
|
||||
unsigned limit;
|
||||
if (StringRef(A->getValue()).getAsInteger(10, limit)) {
|
||||
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
|
||||
A->getAsString(Args), A->getValue());
|
||||
return true;
|
||||
}
|
||||
|
||||
Opts.TypoCorrectionLimit = limit;
|
||||
}
|
||||
}
|
||||
|
||||
Opts.CodeCompleteInitsInPostfixExpr |=
|
||||
Args.hasArg(OPT_code_complete_inits_in_postfix_expr);
|
||||
|
||||
Reference in New Issue
Block a user