[ast] Enable the ASTVerifier behind the enable-ast-verifier flag in no-asserts builds.

This follows the design of how we handled this with
sil-verify-all. Specifically, the default behavior is to run only in asserts
builds, but one can use the two flags: enable-ast-verifier and
disable-ast-verifier to override the default behavior.

The reason why this is interesting is that this means that when compiling
normally, we will not run the verifier, so we won't have a perf hit. But we can
now ask the user to run with this flag (or in a future maybe a re-run in the
driver would do this for them), saving us time when screening bugs by avoiding
the need to build an asserts compiler to triage if the ASTVerifier would catch
the bug.
This commit is contained in:
Michael Gottesman
2021-01-25 10:31:23 -08:00
parent f205b200a8
commit 1de2d3f7c0
10 changed files with 106 additions and 33 deletions

View File

@@ -689,6 +689,21 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.AllowModuleWithCompilerErrors = true;
}
if (auto A =
Args.getLastArg(OPT_enable_ast_verifier, OPT_disable_ast_verifier)) {
using ASTVerifierOverrideKind = LangOptions::ASTVerifierOverrideKind;
if (A->getOption().matches(OPT_enable_ast_verifier)) {
Opts.ASTVerifierOverride = ASTVerifierOverrideKind::EnableVerifier;
} else if (A->getOption().matches(OPT_disable_ast_verifier)) {
Opts.ASTVerifierOverride = ASTVerifierOverrideKind::DisableVerifier;
} else {
// This is an assert since getLastArg should not have let us get here if
// we did not have one of enable/disable specified.
llvm_unreachable(
"Should have found one of enable/disable ast verifier?!");
}
}
return HadError || UnsupportedOS || UnsupportedArch;
}