Skip to content

Commit 31314b1

Browse files
committed
Add ignoreAllWarnings API
New API on DiagnosticEngine to disable the reporting of warnings. No tests currently, as this is not exposed upwards to any test-able level, but tests will come when this is exposed e.g. through command line arguments.
1 parent 767597d commit 31314b1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

include/swift/AST/DiagnosticEngine.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,9 @@ namespace swift {
398398
/// fatal error
399399
bool showDiagnosticsAfterFatalError = false;
400400

401+
/// \brief Don't emit any warnings
402+
bool ignoreAllWarnings = false;
403+
401404
/// \brief Whether a fatal error has occurred
402405
bool fatalErrorOccurred = false;
403406

@@ -420,6 +423,10 @@ namespace swift {
420423
showDiagnosticsAfterFatalError = val;
421424
}
422425

426+
/// \brief Whether to skip emitting warnings
427+
void setIgnoreAllWarnings(bool val) { ignoreAllWarnings = val; }
428+
bool getIgnoreAllWarnings() const { return ignoreAllWarnings; }
429+
423430
void resetHadAnyError() {
424431
anyErrorOccurred = false;
425432
fatalErrorOccurred = false;
@@ -484,6 +491,12 @@ namespace swift {
484491
state.setShowDiagnosticsAfterFatalError(val);
485492
}
486493

494+
/// \brief Whether to skip emitting warnings
495+
void setIgnoreAllWarnings(bool val) { state.setIgnoreAllWarnings(val); }
496+
bool getIgnoreAllWarnings() const {
497+
return state.getIgnoreAllWarnings();
498+
}
499+
487500
void resetHadAnyError() {
488501
state.resetHadAnyError();
489502
}

lib/AST/DiagnosticEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ DiagnosticState::Behavior DiagnosticState::getBehavior(const Diagnostic &diag) {
485485
case DiagnosticKind::Error:
486486
return set(Behavior::Err);
487487
case DiagnosticKind::Warning:
488-
return set(Behavior::Warn);
488+
return set(ignoreAllWarnings ? Behavior::Ignore : Behavior::Warn);
489489
case DiagnosticKind::Note:
490490
return set(Behavior::Note);
491491
}

0 commit comments

Comments
 (0)