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:
Doug Gregor
2017-07-10 11:04:41 -07:00
parent a6516a90c6
commit f03685b6d0
10 changed files with 48 additions and 8 deletions

View File

@@ -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);