[tint][diagnostics] Remove ICE / Fatal severities
The InternalCompilerErrorReporter is now a different system to diagnostics. Ideally when an ICE is raised, the handler should abort.
Change-Id: I6cbe7e0da00aaa6ff838d26c28b82bc6a18e34db
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/186621
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/dawn/native/CompilationMessages.cpp b/src/dawn/native/CompilationMessages.cpp
index c3feb40..64f23c5 100644
--- a/src/dawn/native/CompilationMessages.cpp
+++ b/src/dawn/native/CompilationMessages.cpp
@@ -237,19 +237,17 @@
size_t errorCount = 0;
for (auto& diag : diagnostics) {
switch (diag.severity) {
- case (tint::diag::Severity::Fatal):
- case (tint::diag::Severity::Error):
- case (tint::diag::Severity::InternalCompilerError): {
+ case tint::diag::Severity::Error: {
errorCount++;
messageList.Add(diag);
break;
}
- case (tint::diag::Severity::Warning): {
+ case tint::diag::Severity::Warning: {
warningCount++;
messageList.Add(diag);
break;
}
- case (tint::diag::Severity::Note): {
+ case tint::diag::Severity::Note: {
messageList.Add(diag);
break;
}
diff --git a/src/tint/lang/wgsl/diagnostic_severity.cc b/src/tint/lang/wgsl/diagnostic_severity.cc
index d47944d..4fd7c55 100644
--- a/src/tint/lang/wgsl/diagnostic_severity.cc
+++ b/src/tint/lang/wgsl/diagnostic_severity.cc
@@ -49,7 +49,7 @@
case DiagnosticSeverity::kInfo:
return diag::Severity::Note;
default:
- return diag::Severity::InternalCompilerError;
+ return diag::Severity::Error;
}
}
diff --git a/src/tint/lang/wgsl/diagnostic_severity.cc.tmpl b/src/tint/lang/wgsl/diagnostic_severity.cc.tmpl
index fdc3a8d..ff0f70e 100644
--- a/src/tint/lang/wgsl/diagnostic_severity.cc.tmpl
+++ b/src/tint/lang/wgsl/diagnostic_severity.cc.tmpl
@@ -26,7 +26,7 @@
case DiagnosticSeverity::kInfo:
return diag::Severity::Note;
default:
- return diag::Severity::InternalCompilerError;
+ return diag::Severity::Error;
}
}
diff --git a/src/tint/lang/wgsl/ls/diagnostics.cc b/src/tint/lang/wgsl/ls/diagnostics.cc
index 58ed542..98ff03c 100644
--- a/src/tint/lang/wgsl/ls/diagnostics.cc
+++ b/src/tint/lang/wgsl/ls/diagnostics.cc
@@ -49,8 +49,6 @@
d.severity = lsp::DiagnosticSeverity::kWarning;
break;
case diag::Severity::Error:
- case diag::Severity::InternalCompilerError:
- case diag::Severity::Fatal:
d.severity = lsp::DiagnosticSeverity::kError;
break;
}
diff --git a/src/tint/lang/wgsl/resolver/resolver.cc b/src/tint/lang/wgsl/resolver/resolver.cc
index b1a1775..ba65744 100644
--- a/src/tint/lang/wgsl/resolver/resolver.cc
+++ b/src/tint/lang/wgsl/resolver/resolver.cc
@@ -5048,7 +5048,7 @@
TINT_ICE() << msg;
}
diag::Diagnostic err{};
- err.severity = diag::Severity::InternalCompilerError;
+ err.severity = diag::Severity::Error;
err.system = diag::System::Resolver;
err.source = source;
diagnostics_.Add(std::move(err)) << msg;
diff --git a/src/tint/utils/diagnostic/diagnostic.h b/src/tint/utils/diagnostic/diagnostic.h
index 69f77d2..5c71762 100644
--- a/src/tint/utils/diagnostic/diagnostic.h
+++ b/src/tint/utils/diagnostic/diagnostic.h
@@ -28,8 +28,8 @@
#ifndef SRC_TINT_UTILS_DIAGNOSTIC_DIAGNOSTIC_H_
#define SRC_TINT_UTILS_DIAGNOSTIC_DIAGNOSTIC_H_
+#include <cstdint>
#include <memory>
-#include <ostream>
#include <string>
#include <utility>
@@ -41,7 +41,7 @@
namespace tint::diag {
/// Severity is an enumerator of diagnostic severities.
-enum class Severity { Note, Warning, Error, InternalCompilerError, Fatal };
+enum class Severity : uint8_t { Note, Warning, Error };
/// @return true iff `a` is more than, or of equal severity to `b`
inline bool operator>=(Severity a, Severity b) {
@@ -216,23 +216,6 @@
return Add(std::move(error));
}
- /// Adds an internal compiler error message to the end of this list.
- /// @param system the system raising the error message
- /// @param source the source of the internal compiler error
- /// @param file the Source::File owned by this diagnostic
- /// @returns a reference to the new diagnostic.
- /// @note The returned reference must not be used after the list is mutated again.
- diag::Diagnostic& AddIce(System system,
- const Source& source,
- std::shared_ptr<Source::File> file) {
- diag::Diagnostic ice{};
- ice.severity = diag::Severity::InternalCompilerError;
- ice.system = system;
- ice.source = source;
- ice.owned_file = std::move(file);
- return Add(std::move(ice));
- }
-
/// @returns true iff the diagnostic list contains errors diagnostics (or of
/// higher severity).
bool ContainsErrors() const { return error_count_ > 0; }
diff --git a/src/tint/utils/diagnostic/diagnostic_test.cc b/src/tint/utils/diagnostic/diagnostic_test.cc
index 3d76f1e..9a00566 100644
--- a/src/tint/utils/diagnostic/diagnostic_test.cc
+++ b/src/tint/utils/diagnostic/diagnostic_test.cc
@@ -36,7 +36,7 @@
TEST(DiagListTest, CtorInitializerList) {
Diagnostic err_a, err_b;
err_a.severity = Severity::Error;
- err_b.severity = Severity::Fatal;
+ err_b.severity = Severity::Warning;
List list{err_a, err_b};
EXPECT_EQ(list.Count(), 2u);
}
@@ -44,7 +44,7 @@
TEST(DiagListTest, CtorVectorRef) {
Diagnostic err_a, err_b;
err_a.severity = Severity::Error;
- err_b.severity = Severity::Fatal;
+ err_b.severity = Severity::Warning;
List list{Vector{err_a, err_b}};
EXPECT_EQ(list.Count(), 2u);
}
diff --git a/src/tint/utils/diagnostic/formatter.cc b/src/tint/utils/diagnostic/formatter.cc
index 9fd279b..5b5c574 100644
--- a/src/tint/utils/diagnostic/formatter.cc
+++ b/src/tint/utils/diagnostic/formatter.cc
@@ -50,10 +50,6 @@
return "warning";
case Severity::Error:
return "error";
- case Severity::InternalCompilerError:
- return "internal compiler error";
- case Severity::Fatal:
- return "fatal";
}
return "";
}
@@ -127,10 +123,6 @@
case Severity::Error:
style = style::Error + style::Bold;
break;
- case Severity::Fatal:
- case Severity::InternalCompilerError:
- style = style::Fatal + style::Bold;
- break;
}
prefix.Push(TextAndStyle{ToString(diag.severity), style});
}
diff --git a/src/tint/utils/diagnostic/formatter_test.cc b/src/tint/utils/diagnostic/formatter_test.cc
index 6d77367..320b6b4 100644
--- a/src/tint/utils/diagnostic/formatter_test.cc
+++ b/src/tint/utils/diagnostic/formatter_test.cc
@@ -74,14 +74,6 @@
Source{Source::Range{{3, 16}, {3, 21}}, &ascii_file},
"hiss",
System::Test);
- Diagnostic ascii_diag_ice = Diag(Severity::InternalCompilerError,
- Source{Source::Range{{4, 16}, {4, 19}}, &ascii_file},
- "unreachable",
- System::Test);
- Diagnostic ascii_diag_fatal = Diag(Severity::Fatal,
- Source{Source::Range{{4, 16}, {4, 19}}, &ascii_file},
- "nothing",
- System::Test);
Diagnostic utf8_diag_note = Diag(Severity::Note,
Source{Source::Range{Source::Location{1, 15}}, &utf8_file},
@@ -95,14 +87,6 @@
Source{Source::Range{{3, 15}, {3, 20}}, &utf8_file},
"hiss",
System::Test);
- Diagnostic utf8_diag_ice = Diag(Severity::InternalCompilerError,
- Source{Source::Range{{4, 15}, {4, 18}}, &utf8_file},
- "unreachable",
- System::Test);
- Diagnostic utf8_diag_fatal = Diag(Severity::Fatal,
- Source{Source::Range{{4, 15}, {4, 18}}, &utf8_file},
- "nothing",
- System::Test);
};
TEST_F(DiagFormatterTest, Simple) {
@@ -264,28 +248,6 @@
ASSERT_EQ(expect, got);
}
-TEST_F(DiagFormatterTest, ICE) {
- Formatter fmt{{}};
- auto got = fmt.Format(List{ascii_diag_ice}).Plain();
- auto* expect = R"(file.name:4:16 internal compiler error: unreachable
-the snail says ???
- ^^^
-
-)";
- ASSERT_EQ(expect, got);
-}
-
-TEST_F(DiagFormatterTest, Fatal) {
- Formatter fmt{{}};
- auto got = fmt.Format(List{ascii_diag_fatal}).Plain();
- auto* expect = R"(file.name:4:16 fatal: nothing
-the snail says ???
- ^^^
-
-)";
- ASSERT_EQ(expect, got);
-}
-
TEST_F(DiagFormatterTest, RangeOOB) {
Formatter fmt{{true, true, true, true}};
diag::List list;