Add -warn-long-expression-type-checking=<limit> frontend option.

Generates a warning for any expression that takes longer than <limit>
milliseconds to type check. This compliments the existing
-warn-long-function-body=<limit> option.
This commit is contained in:
Mark Lacey
2017-06-12 17:25:46 -07:00
parent 5af026608e
commit d26c859222
10 changed files with 80 additions and 13 deletions

View File

@@ -216,6 +216,16 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
}
}
if (const Arg *A = Args.getLastArg(OPT_warn_long_expression_type_checking)) {
unsigned attempt;
if (StringRef(A->getValue()).getAsInteger(10, attempt)) {
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
A->getAsString(Args), A->getValue());
} else {
Opts.WarnLongExpressionTypeChecking = attempt;
}
}
Opts.PlaygroundTransform |= Args.hasArg(OPT_playground);
if (Args.hasArg(OPT_disable_playground_transform))
Opts.PlaygroundTransform = false;