mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user