Skip to content

[AST] Do not verify when allowing compiler errors #37667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/AST/ASTVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3674,6 +3674,11 @@ class Verifier : public ASTWalker {
} // end anonymous namespace

static bool shouldVerifyGivenContext(const ASTContext &ctx) {
// Never verify when allowing errors, since the AST can necessarily be
// invalid
if (ctx.LangOpts.AllowModuleWithCompilerErrors)
return false;

using ASTVerifierOverrideKind = LangOptions::ASTVerifierOverrideKind;
switch (ctx.LangOpts.ASTVerifierOverride) {
case ASTVerifierOverrideKind::EnableVerifier:
Expand Down
8 changes: 8 additions & 0 deletions test/Serialization/AllowErrors/invalid-ifconfig.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// RUN: %empty-directory(%t)

// RUN: %target-swift-frontend -module-name errors -emit-module -o %t/mods/errors.swiftmodule -experimental-skip-all-function-bodies -experimental-allow-module-with-compiler-errors %s

// Performing AST verification would crash here, so check that we don't verify
// when allowing errors
#if os(
struct Anything {