Skip to content

Commit 5b2891b

Browse files
authored
Merge pull request #25006 from gottesmm/pr-66c042e5dfc5a03a389d4af3fb1242143870effe
[diagnostics] Add the llvm option swift-diagnostics-assert-on-warning…
2 parents 2d22a37 + 69335f0 commit 5b2891b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/AST/DiagnosticEngine.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,14 @@ static DiagnosticKind toDiagnosticKind(DiagnosticState::Behavior behavior) {
622622
llvm_unreachable("Unhandled DiagnosticKind in switch.");
623623
}
624624

625-
/// A special option only for compiler writers that causes Diagnostics to assert
626-
/// when a failure diagnostic is emitted. Intended for use in the debugger.
625+
// A special option only for compiler writers that causes Diagnostics to assert
626+
// when a failure diagnostic is emitted. Intended for use in the debugger.
627627
llvm::cl::opt<bool> AssertOnError("swift-diagnostics-assert-on-error",
628628
llvm::cl::init(false));
629+
// A special option only for compiler writers that causes Diagnostics to assert
630+
// when a warning diagnostic is emitted. Intended for use in the debugger.
631+
llvm::cl::opt<bool> AssertOnWarning("swift-diagnostics-assert-on-warning",
632+
llvm::cl::init(false));
629633

630634
DiagnosticState::Behavior DiagnosticState::determineBehavior(DiagID id) {
631635
auto set = [this](DiagnosticState::Behavior lvl) {
@@ -637,6 +641,8 @@ DiagnosticState::Behavior DiagnosticState::determineBehavior(DiagID id) {
637641
}
638642

639643
assert((!AssertOnError || !anyErrorOccurred) && "We emitted an error?!");
644+
assert((!AssertOnWarning || (lvl != Behavior::Warning)) &&
645+
"We emitted a warning?!");
640646
previousBehavior = lvl;
641647
return lvl;
642648
};

0 commit comments

Comments
 (0)