@@ -137,7 +137,8 @@ static constexpr auto educationalNotes = _EducationalNotes.value;
137
137
138
138
DiagnosticState::DiagnosticState () {
139
139
// Initialize our per-diagnostic state to default
140
- perDiagnosticBehavior.resize (LocalDiagID::NumDiags, Behavior::Unspecified);
140
+ perDiagnosticBehavior.resize (LocalDiagID::NumDiags,
141
+ DiagnosticBehavior::Unspecified);
141
142
}
142
143
143
144
static CharSourceRange toCharSourceRange (SourceManager &SM, SourceRange SR) {
@@ -778,20 +779,20 @@ void DiagnosticEngine::formatDiagnosticText(
778
779
}
779
780
}
780
781
781
- static DiagnosticKind toDiagnosticKind (DiagnosticState::Behavior behavior) {
782
+ static DiagnosticKind toDiagnosticKind (DiagnosticBehavior behavior) {
782
783
switch (behavior) {
783
- case DiagnosticState::Behavior ::Unspecified:
784
+ case DiagnosticBehavior ::Unspecified:
784
785
llvm_unreachable (" unspecified behavior" );
785
- case DiagnosticState::Behavior ::Ignore:
786
+ case DiagnosticBehavior ::Ignore:
786
787
llvm_unreachable (" trying to map an ignored diagnostic" );
787
- case DiagnosticState::Behavior ::Error:
788
- case DiagnosticState::Behavior ::Fatal:
788
+ case DiagnosticBehavior ::Error:
789
+ case DiagnosticBehavior ::Fatal:
789
790
return DiagnosticKind::Error;
790
- case DiagnosticState::Behavior ::Note:
791
+ case DiagnosticBehavior ::Note:
791
792
return DiagnosticKind::Note;
792
- case DiagnosticState::Behavior ::Warning:
793
+ case DiagnosticBehavior ::Warning:
793
794
return DiagnosticKind::Warning;
794
- case DiagnosticState::Behavior ::Remark:
795
+ case DiagnosticBehavior ::Remark:
795
796
return DiagnosticKind::Remark;
796
797
}
797
798
@@ -807,17 +808,17 @@ llvm::cl::opt<bool> AssertOnError("swift-diagnostics-assert-on-error",
807
808
llvm::cl::opt<bool > AssertOnWarning (" swift-diagnostics-assert-on-warning" ,
808
809
llvm::cl::init (false ));
809
810
810
- DiagnosticState::Behavior DiagnosticState::determineBehavior (DiagID id) {
811
- auto set = [this ](DiagnosticState::Behavior lvl) {
812
- if (lvl == Behavior ::Fatal) {
811
+ DiagnosticBehavior DiagnosticState::determineBehavior (DiagID id) {
812
+ auto set = [this ](DiagnosticBehavior lvl) {
813
+ if (lvl == DiagnosticBehavior ::Fatal) {
813
814
fatalErrorOccurred = true ;
814
815
anyErrorOccurred = true ;
815
- } else if (lvl == Behavior ::Error) {
816
+ } else if (lvl == DiagnosticBehavior ::Error) {
816
817
anyErrorOccurred = true ;
817
818
}
818
819
819
820
assert ((!AssertOnError || !anyErrorOccurred) && " We emitted an error?!" );
820
- assert ((!AssertOnWarning || (lvl != Behavior ::Warning)) &&
821
+ assert ((!AssertOnWarning || (lvl != DiagnosticBehavior ::Warning)) &&
821
822
" We emitted a warning?!" );
822
823
previousBehavior = lvl;
823
824
return lvl;
@@ -837,39 +838,40 @@ DiagnosticState::Behavior DiagnosticState::determineBehavior(DiagID id) {
837
838
// 1) If current state dictates a certain behavior, follow that
838
839
839
840
// Notes relating to ignored diagnostics should also be ignored
840
- if (previousBehavior == Behavior ::Ignore && isNote)
841
- return set (Behavior ::Ignore);
841
+ if (previousBehavior == DiagnosticBehavior ::Ignore && isNote)
842
+ return set (DiagnosticBehavior ::Ignore);
842
843
843
844
// Suppress diagnostics when in a fatal state, except for follow-on notes
844
845
if (fatalErrorOccurred)
845
846
if (!showDiagnosticsAfterFatalError && !isNote)
846
- return set (Behavior ::Ignore);
847
+ return set (DiagnosticBehavior ::Ignore);
847
848
848
849
// 2) If the user provided a behavior for this specific diagnostic, follow
849
850
// that
850
851
851
- if (perDiagnosticBehavior[(unsigned )id] != Behavior ::Unspecified)
852
+ if (perDiagnosticBehavior[(unsigned )id] != DiagnosticBehavior ::Unspecified)
852
853
return set (perDiagnosticBehavior[(unsigned )id]);
853
854
854
855
// 3) If the user provided a behavior for this diagnostic's kind, follow
855
856
// that
856
857
if (diagInfo.kind == DiagnosticKind::Warning) {
857
858
if (suppressWarnings)
858
- return set (Behavior ::Ignore);
859
+ return set (DiagnosticBehavior ::Ignore);
859
860
if (warningsAsErrors)
860
- return set (Behavior ::Error);
861
+ return set (DiagnosticBehavior ::Error);
861
862
}
862
863
863
864
// 4) Otherwise remap the diagnostic kind
864
865
switch (diagInfo.kind ) {
865
866
case DiagnosticKind::Note:
866
- return set (Behavior ::Note);
867
+ return set (DiagnosticBehavior ::Note);
867
868
case DiagnosticKind::Error:
868
- return set (diagInfo.isFatal ? Behavior::Fatal : Behavior::Error);
869
+ return set (diagInfo.isFatal ? DiagnosticBehavior::Fatal
870
+ : DiagnosticBehavior::Error);
869
871
case DiagnosticKind::Warning:
870
- return set (Behavior ::Warning);
872
+ return set (DiagnosticBehavior ::Warning);
871
873
case DiagnosticKind::Remark:
872
- return set (Behavior ::Remark);
874
+ return set (DiagnosticBehavior ::Remark);
873
875
}
874
876
875
877
llvm_unreachable (" Unhandled DiagnosticKind in switch." );
@@ -910,7 +912,7 @@ static AccessLevel getBufferAccessLevel(const Decl *decl) {
910
912
Optional<DiagnosticInfo>
911
913
DiagnosticEngine::diagnosticInfoForDiagnostic (const Diagnostic &diagnostic) {
912
914
auto behavior = state.determineBehavior (diagnostic.getID ());
913
- if (behavior == DiagnosticState::Behavior ::Ignore)
915
+ if (behavior == DiagnosticBehavior ::Ignore)
914
916
return None;
915
917
916
918
// Figure out the source location.
0 commit comments