Files
swift-mirror/test/diagnostics/assert_on_error.swift
T
Michael Gottesman c36f842bed [diagnostic] Convert diagnostics-assert-on-{error,warning} and sil-region-isolation-assert-on-unknown-pattern from llvm::cl::opt globals to Swift frontend flags, and add -diagnostics-assert-on-group
llvm::cl::opt flags are compiled out in non-asserts builds, making these
debug flags unavailable in an important category of use cases — debugging
a release compiler in lldb. By promoting them to Swift frontend flags stored
in DiagnosticOptions/SILOptions, they are available in all build
configurations.

The three existing flags are migrated:
  -diagnostics-assert-on-error
  -diagnostics-assert-on-warning
  -sil-region-isolation-assert-on-unknown-pattern
    (backing field renamed to AbortOnUnknownRegionIsolationPatternError)

A new flag is added:
  -diagnostics-assert-on-group <group>
    Traps when any diagnostic belonging to the named group is emitted,
    allowing targeted breakpoints on a single diagnostic group rather than
    all errors or all warnings.

The assert-on-{error,warning,group} flags are intentionally kept separate
from the normal diagnostic suppression/escalation machinery so that they
remain useful while other diagnostics are also being emitted.

Tests are added for all four flags.
2026-05-14 17:36:08 -07:00

12 lines
402 B
Swift

// RUN: not --crash %target-swift-frontend -typecheck -diagnostics-assert-on-error %s 2>&1 | %FileCheck %s
// RUN: %target-swift-frontend -typecheck -diagnostics-assert-on-error -DNO_ERROR %s 2>&1
// Verify that -diagnostics-assert-on-error traps when an error is emitted
// and does nothing when no errors are emitted.
// CHECK: We emitted an error?!
#if !NO_ERROR
let _: Int = "not an int"
#endif