Skip to content

Commit 4a01b56

Browse files
committed
[NFC] Pass whole diagnostic into determineBehavior()
1 parent ed0f1f2 commit 4a01b56

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

include/swift/AST/DiagnosticEngine.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ namespace swift {
636636

637637
/// Figure out the Behavior for the given diagnostic, taking current
638638
/// state such as fatality into account.
639-
DiagnosticBehavior determineBehavior(DiagID id);
639+
DiagnosticBehavior determineBehavior(const Diagnostic &diag);
640640

641641
bool hadAnyError() const { return anyErrorOccurred; }
642642
bool hasFatalErrorOccurred() const { return fatalErrorOccurred; }
@@ -1105,7 +1105,7 @@ namespace swift {
11051105
Engine.TentativeDiagnostics.end());
11061106

11071107
for (auto &diagnostic : diagnostics) {
1108-
auto behavior = Engine.state.determineBehavior(diagnostic.getID());
1108+
auto behavior = Engine.state.determineBehavior(diagnostic);
11091109
if (behavior == DiagnosticBehavior::Fatal ||
11101110
behavior == DiagnosticBehavior::Error)
11111111
return true;

lib/AST/DiagnosticEngine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ llvm::cl::opt<bool> AssertOnError("swift-diagnostics-assert-on-error",
807807
llvm::cl::opt<bool> AssertOnWarning("swift-diagnostics-assert-on-warning",
808808
llvm::cl::init(false));
809809

810-
DiagnosticBehavior DiagnosticState::determineBehavior(DiagID id) {
810+
DiagnosticBehavior DiagnosticState::determineBehavior(const Diagnostic &diag) {
811811
auto set = [this](DiagnosticBehavior lvl) {
812812
if (lvl == DiagnosticBehavior::Fatal) {
813813
fatalErrorOccurred = true;
@@ -830,7 +830,7 @@ DiagnosticBehavior DiagnosticState::determineBehavior(DiagID id) {
830830
// that
831831
// 4) Otherwise remap the diagnostic kind
832832

833-
auto diagInfo = storedDiagnosticInfos[(unsigned)id];
833+
auto diagInfo = storedDiagnosticInfos[(unsigned)diag.getID()];
834834
bool isNote = diagInfo.kind == DiagnosticKind::Note;
835835

836836
// 1) If current state dictates a certain behavior, follow that
@@ -907,7 +907,7 @@ static AccessLevel getBufferAccessLevel(const Decl *decl) {
907907

908908
Optional<DiagnosticInfo>
909909
DiagnosticEngine::diagnosticInfoForDiagnostic(const Diagnostic &diagnostic) {
910-
auto behavior = state.determineBehavior(diagnostic.getID());
910+
auto behavior = state.determineBehavior(diagnostic);
911911
if (behavior == DiagnosticBehavior::Ignore)
912912
return None;
913913

0 commit comments

Comments
 (0)