[tint][utils] PascalCase tint::diag functions
Fixes a longstanding annoyance.
Change-Id: I39a9ba09e4efc8ed9570fa496b6dfcd66e8c830b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/173040
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/dawn/native/CompilationMessages.cpp b/src/dawn/native/CompilationMessages.cpp
index f3eb260..8dc0a3b 100644
--- a/src/dawn/native/CompilationMessages.cpp
+++ b/src/dawn/native/CompilationMessages.cpp
@@ -241,16 +241,16 @@
case (tint::diag::Severity::Error):
case (tint::diag::Severity::InternalCompilerError): {
errorCount++;
- messageList.add(tint::diag::Diagnostic(diag));
+ messageList.Add(diag);
break;
}
case (tint::diag::Severity::Warning): {
warningCount++;
- messageList.add(tint::diag::Diagnostic(diag));
+ messageList.Add(diag);
break;
}
case (tint::diag::Severity::Note): {
- messageList.add(tint::diag::Diagnostic(diag));
+ messageList.Add(diag);
break;
}
default:
@@ -273,7 +273,7 @@
t << warningCount << " warning(s) ";
}
t << "generated while compiling the shader:" << std::endl
- << tint::diag::Formatter{style}.format(messageList);
+ << tint::diag::Formatter{style}.Format(messageList);
mFormattedTintMessages.push_back(t.str());
}
diff --git a/src/dawn/native/ShaderModule.cpp b/src/dawn/native/ShaderModule.cpp
index 8629822..2a9cc28 100644
--- a/src/dawn/native/ShaderModule.cpp
+++ b/src/dawn/native/ShaderModule.cpp
@@ -347,7 +347,7 @@
DAWN_TRY(outMessages->AddMessages(program.Diagnostics()));
}
if (!program.IsValid()) {
- return DAWN_VALIDATION_ERROR("Error while parsing WGSL: %s\n", program.Diagnostics().str());
+ return DAWN_VALIDATION_ERROR("Error while parsing WGSL: %s\n", program.Diagnostics().Str());
}
return std::move(program);
@@ -369,7 +369,7 @@
}
if (!program.IsValid()) {
return DAWN_VALIDATION_ERROR("Error while parsing SPIR-V: %s\n",
- program.Diagnostics().str());
+ program.Diagnostics().Str());
}
return std::move(program);
@@ -1132,7 +1132,7 @@
if (outMessages != nullptr) {
DAWN_TRY(outMessages->AddMessages(result.Diagnostics()));
}
- DAWN_INVALID_IF(!result.IsValid(), "Tint program failure: %s\n", result.Diagnostics().str());
+ DAWN_INVALID_IF(!result.IsValid(), "Tint program failure: %s\n", result.Diagnostics().Str());
if (outputs != nullptr) {
*outputs = std::move(transform_outputs);
}
diff --git a/src/dawn/native/d3d/ShaderUtils.cpp b/src/dawn/native/d3d/ShaderUtils.cpp
index c0aeea4..e1937ca 100644
--- a/src/dawn/native/d3d/ShaderUtils.cpp
+++ b/src/dawn/native/d3d/ShaderUtils.cpp
@@ -268,7 +268,7 @@
TRACE_EVENT0(tracePlatform.UnsafeGetValue(), General, "tint::hlsl::writer::Generate");
auto result = tint::hlsl::writer::Generate(transformedProgram, r.tintOptions);
DAWN_INVALID_IF(result != tint::Success, "An error occurred while generating HLSL:\n%s",
- result.Failure().reason.str());
+ result.Failure().reason.Str());
compiledShader->usesVertexIndex = usesVertexIndex;
compiledShader->usesInstanceIndex = usesInstanceIndex;
diff --git a/src/dawn/native/metal/ShaderModuleMTL.mm b/src/dawn/native/metal/ShaderModuleMTL.mm
index 52d818f..1ec3209 100644
--- a/src/dawn/native/metal/ShaderModuleMTL.mm
+++ b/src/dawn/native/metal/ShaderModuleMTL.mm
@@ -348,7 +348,7 @@
TRACE_EVENT0(r.platform.UnsafeGetValue(), General, "tint::msl::writer::Generate");
auto result = tint::msl::writer::Generate(program, r.tintOptions);
DAWN_INVALID_IF(result != tint::Success, "An error occurred while generating MSL:\n%s",
- result.Failure().reason.str());
+ result.Failure().reason.Str());
// Metal uses Clang to compile the shader as C++14. Disable everything in the -Wall
// category. -Wunused-variable in particular comes up a lot in generated code, and some
diff --git a/src/dawn/native/opengl/ShaderModuleGL.cpp b/src/dawn/native/opengl/ShaderModuleGL.cpp
index 9c39077..77ad5ed 100644
--- a/src/dawn/native/opengl/ShaderModuleGL.cpp
+++ b/src/dawn/native/opengl/ShaderModuleGL.cpp
@@ -423,7 +423,7 @@
auto result = tint::glsl::writer::Generate(program, r.tintOptions, remappedEntryPoint);
DAWN_INVALID_IF(result != tint::Success, "An error occurred while generating GLSL:\n%s",
- result.Failure().reason.str());
+ result.Failure().reason.Str());
return GLSLCompilation{{std::move(result->glsl)}};
},
diff --git a/src/dawn/native/vulkan/ShaderModuleVk.cpp b/src/dawn/native/vulkan/ShaderModuleVk.cpp
index 0796340..1938cbc 100644
--- a/src/dawn/native/vulkan/ShaderModuleVk.cpp
+++ b/src/dawn/native/vulkan/ShaderModuleVk.cpp
@@ -428,7 +428,7 @@
auto ir = tint::wgsl::reader::ProgramToLoweredIR(program);
DAWN_INVALID_IF(ir != tint::Success,
"An error occurred while generating Tint IR\n%s",
- ir.Failure().reason.str());
+ ir.Failure().reason.Str());
tintResult = tint::spirv::writer::Generate(ir.Get(), r.tintOptions);
} else {
@@ -436,7 +436,7 @@
}
DAWN_INVALID_IF(tintResult != tint::Success,
"An error occurred while generating SPIR-V\n%s",
- tintResult.Failure().reason.str());
+ tintResult.Failure().reason.Str());
CompiledSpirv result;
result.spirv = std::move(tintResult.Get().spirv);
diff --git a/src/tint/api/tint.cc b/src/tint/api/tint.cc
index 8a48cea..3337b23 100644
--- a/src/tint/api/tint.cc
+++ b/src/tint/api/tint.cc
@@ -71,7 +71,7 @@
tint::Program::printer = [](const tint::Program& program) {
auto result = wgsl::writer::Generate(program, {});
if (result != Success) {
- return result.Failure().reason.str();
+ return result.Failure().reason.Str();
}
return result->wgsl;
};
diff --git a/src/tint/cmd/common/helper.cc b/src/tint/cmd/common/helper.cc
index 3e54e9f..4dd0ea1 100644
--- a/src/tint/cmd/common/helper.cc
+++ b/src/tint/cmd/common/helper.cc
@@ -127,7 +127,7 @@
opts.spirv_reader_options.allow_non_uniform_derivatives;
options.allowed_features = opts.spirv_reader_options.allowed_features;
auto ast = tint::wgsl::writer::IRToProgram(result.Get(), options);
- if (!ast.IsValid() || ast.Diagnostics().contains_errors()) {
+ if (!ast.IsValid() || ast.Diagnostics().ContainsErrors()) {
std::cerr << "Failed to convert IR to AST:\n\n" << ast.Diagnostics() << "\n";
exit(1);
}
@@ -145,9 +145,9 @@
} // namespace
[[noreturn]] void TintInternalCompilerErrorReporter(const InternalCompilerError& err) {
- auto printer = diag::Printer::create(stderr, true);
+ auto printer = diag::Printer::Create(stderr, true);
diag::Style bold_red{diag::Color::kRed, true};
- printer->write(err.Error(), bold_red);
+ printer->Write(err.Error(), bold_red);
constexpr const char* please_file_bug = R"(
********************************************************************
* The tint shader compiler has encountered an unexpected error. *
@@ -156,7 +156,7 @@
* crbug.com/tint with the source program that triggered the bug. *
********************************************************************
)";
- printer->write(please_file_bug, bold_red);
+ printer->Write(please_file_bug, bold_red);
exit(1);
}
@@ -260,16 +260,16 @@
ProgramInfo info = load();
- if (info.program.Diagnostics().count() > 0) {
+ if (info.program.Diagnostics().Count() > 0) {
if (!info.program.IsValid() && input_format != InputFormat::kWgsl) {
// Invalid program from a non-wgsl source.
// Print the WGSL, to help understand the diagnostics.
PrintWGSL(std::cout, info.program);
}
- auto diag_printer = tint::diag::Printer::create(stderr, true);
+ auto diag_printer = tint::diag::Printer::Create(stderr, true);
tint::diag::Formatter diag_formatter;
- diag_formatter.format(info.program.Diagnostics(), diag_printer.get());
+ diag_formatter.Format(info.program.Diagnostics(), diag_printer.get());
}
if (!info.program.IsValid()) {
diff --git a/src/tint/cmd/tint/main.cc b/src/tint/cmd/tint/main.cc
index 22add27..7b04c72 100644
--- a/src/tint/cmd/tint/main.cc
+++ b/src/tint/cmd/tint/main.cc
@@ -776,9 +776,9 @@
auto source = std::make_unique<tint::Source::File>(options.input_filename, result->wgsl);
auto reparsed_program = tint::wgsl::reader::Parse(source.get(), parser_options);
if (!reparsed_program.IsValid()) {
- auto diag_printer = tint::diag::Printer::create(stderr, true);
+ auto diag_printer = tint::diag::Printer::Create(stderr, true);
tint::diag::Formatter diag_formatter;
- diag_formatter.format(reparsed_program.Diagnostics(), diag_printer.get());
+ diag_formatter.Format(reparsed_program.Diagnostics(), diag_printer.get());
return false;
}
}
diff --git a/src/tint/fuzzers/tint_common_fuzzer.cc b/src/tint/fuzzers/tint_common_fuzzer.cc
index 99f50c9..be477d3 100644
--- a/src/tint/fuzzers/tint_common_fuzzer.cc
+++ b/src/tint/fuzzers/tint_common_fuzzer.cc
@@ -73,11 +73,11 @@
#define FATAL_ERROR(diags, msg_string) \
do { \
std::string msg = msg_string; \
- auto printer = tint::diag::Printer::create(stderr, true); \
+ auto printer = tint::diag::Printer::Create(stderr, true); \
if (!msg.empty()) { \
- printer->write(msg + "\n", {diag::Color::kRed, true}); \
+ printer->Write(msg + "\n", {diag::Color::kRed, true}); \
} \
- tint::diag::Formatter().format(diags, printer.get()); \
+ tint::diag::Formatter().Format(diags, printer.get()); \
__builtin_trap(); \
} while (false)
@@ -117,9 +117,9 @@
out << "Unexpected spirv-val error:\n"
<< (pos.line + 1) << ":" << (pos.column + 1) << ": " << msg << std::endl;
- auto printer = tint::diag::Printer::create(stderr, true);
- printer->write(out.str(), {diag::Color::kYellow, false});
- tint::diag::Formatter().format(diags, printer.get());
+ auto printer = tint::diag::Printer::Create(stderr, true);
+ printer->Write(out.str(), {diag::Color::kYellow, false});
+ tint::diag::Formatter().Format(diags, printer.get());
});
return tools.Validate(spirv.data(), spirv.size(), spvtools::ValidatorOptions());
diff --git a/src/tint/fuzzers/tint_common_fuzzer.h b/src/tint/fuzzers/tint_common_fuzzer.h
index cad2527..9593fea 100644
--- a/src/tint/fuzzers/tint_common_fuzzer.h
+++ b/src/tint/fuzzers/tint_common_fuzzer.h
@@ -104,7 +104,7 @@
const tint::diag::List& Diagnostics() const { return diagnostics_; }
/// @returns if there are any errors in the diagnostic messages
- bool HasErrors() const { return diagnostics_.contains_errors(); }
+ bool HasErrors() const { return diagnostics_.ContainsErrors(); }
/// @returns generated SPIR-V binary, if SPIR-V was emitted.
const std::vector<uint32_t>& GetGeneratedSpirv() const { return generated_spirv_; }
diff --git a/src/tint/lang/core/constant/eval.cc b/src/tint/lang/core/constant/eval.cc
index 91fd4f0..7f090cd 100644
--- a/src/tint/lang/core/constant/eval.cc
+++ b/src/tint/lang/core/constant/eval.cc
@@ -281,7 +281,7 @@
// [abstract-numeric -> x] - materialization failure
auto msg = OverflowErrorMessage(scalar->value, target_ty->FriendlyName());
if (ctx.use_runtime_semantics) {
- ctx.diags.add_warning(tint::diag::System::Resolver, msg, ctx.source);
+ ctx.diags.AddWarning(tint::diag::System::Resolver, msg, ctx.source);
switch (conv.Failure()) {
case ConversionFailure::kExceedsNegativeLimit:
return ctx.mgr.Get<Scalar<TO>>(target_ty, TO::Lowest());
@@ -289,7 +289,7 @@
return ctx.mgr.Get<Scalar<TO>>(target_ty, TO::Highest());
}
} else {
- ctx.diags.add_error(tint::diag::System::Resolver, msg, ctx.source);
+ ctx.diags.AddError(tint::diag::System::Resolver, msg, ctx.source);
return nullptr;
}
} else if constexpr (IsFloatingPoint<TO>) {
@@ -297,7 +297,7 @@
// https://www.w3.org/TR/WGSL/#floating-point-conversion
auto msg = OverflowErrorMessage(scalar->value, target_ty->FriendlyName());
if (ctx.use_runtime_semantics) {
- ctx.diags.add_warning(tint::diag::System::Resolver, msg, ctx.source);
+ ctx.diags.AddWarning(tint::diag::System::Resolver, msg, ctx.source);
switch (conv.Failure()) {
case ConversionFailure::kExceedsNegativeLimit:
return ctx.mgr.Get<Scalar<TO>>(target_ty, TO::Lowest());
@@ -305,7 +305,7 @@
return ctx.mgr.Get<Scalar<TO>>(target_ty, TO::Highest());
}
} else {
- ctx.diags.add_error(tint::diag::System::Resolver, msg, ctx.source);
+ ctx.diags.AddError(tint::diag::System::Resolver, msg, ctx.source);
return nullptr;
}
} else if constexpr (IsFloatingPoint<FROM>) {
@@ -3990,18 +3990,18 @@
void Eval::AddError(const std::string& msg, const Source& source) const {
if (use_runtime_semantics_) {
- diags.add_warning(diag::System::Constant, msg, source);
+ diags.AddWarning(diag::System::Constant, msg, source);
} else {
- diags.add_error(diag::System::Constant, msg, source);
+ diags.AddError(diag::System::Constant, msg, source);
}
}
void Eval::AddWarning(const std::string& msg, const Source& source) const {
- diags.add_warning(diag::System::Constant, msg, source);
+ diags.AddWarning(diag::System::Constant, msg, source);
}
void Eval::AddNote(const std::string& msg, const Source& source) const {
- diags.add_note(diag::System::Constant, msg, source);
+ diags.AddNote(diag::System::Constant, msg, source);
}
} // namespace tint::core::constant
diff --git a/src/tint/lang/core/constant/eval_binary_op_test.cc b/src/tint/lang/core/constant/eval_binary_op_test.cc
index 36ea805..f846ee1 100644
--- a/src/tint/lang/core/constant/eval_binary_op_test.cc
+++ b/src/tint/lang/core/constant/eval_binary_op_test.cc
@@ -2215,7 +2215,7 @@
auto program = wgsl::reader::Parse(file.get());
EXPECT_FALSE(program.IsValid());
- auto error = program.Diagnostics().str();
+ auto error = program.Diagnostics().Str();
EXPECT_EQ(error, R"(test:3:31 error: value cannot be represented as 'i32'
const result = (one == 0) && (1111111111111111111111111111111i == 0);
^
@@ -2234,7 +2234,7 @@
auto program = wgsl::reader::Parse(file.get());
EXPECT_FALSE(program.IsValid());
- auto error = program.Diagnostics().str();
+ auto error = program.Diagnostics().Str();
EXPECT_EQ(error, R"(test:3:31 error: value cannot be represented as 'i32'
const result = (one == 1) || (1111111111111111111111111111111i == 0);
^
@@ -2442,7 +2442,7 @@
auto program = wgsl::reader::Parse(file.get());
if (should_pass) {
- auto error = program.Diagnostics().str();
+ auto error = program.Diagnostics().Str();
EXPECT_TRUE(program.IsValid()) << error;
} else {
diff --git a/src/tint/lang/core/constant/eval_runtime_semantics_test.cc b/src/tint/lang/core/constant/eval_runtime_semantics_test.cc
index d48c8c9..1aec87e 100644
--- a/src/tint/lang/core/constant/eval_runtime_semantics_test.cc
+++ b/src/tint/lang/core/constant/eval_runtime_semantics_test.cc
@@ -44,7 +44,7 @@
Eval eval;
/// @returns the contents of the diagnostics list as a string
- std::string error() { return Diagnostics().str(); }
+ std::string error() { return Diagnostics().Str(); }
};
TEST_F(ConstEvalRuntimeSemanticsTest, Add_AInt_Overflow) {
diff --git a/src/tint/lang/core/ir/binary/roundtrip_test.cc b/src/tint/lang/core/ir/binary/roundtrip_test.cc
index 94e2f5b..19344f1 100644
--- a/src/tint/lang/core/ir/binary/roundtrip_test.cc
+++ b/src/tint/lang/core/ir/binary/roundtrip_test.cc
@@ -50,11 +50,11 @@
auto pre = Disassemble(this->mod);
auto encoded = Encode(this->mod);
if (encoded != Success) {
- return {pre, encoded.Failure().reason.str()};
+ return {pre, encoded.Failure().reason.Str()};
}
auto decoded = Decode(encoded->Slice());
if (decoded != Success) {
- return {pre, decoded.Failure().reason.str()};
+ return {pre, decoded.Failure().reason.Str()};
}
auto post = Disassemble(decoded.Get());
return {pre, post};
diff --git a/src/tint/lang/core/ir/transform/direct_variable_access_wgsl_test.cc b/src/tint/lang/core/ir/transform/direct_variable_access_wgsl_test.cc
index 77b799c..1270cf7 100644
--- a/src/tint/lang/core/ir/transform/direct_variable_access_wgsl_test.cc
+++ b/src/tint/lang/core/ir/transform/direct_variable_access_wgsl_test.cc
@@ -67,28 +67,28 @@
Source::File file{"test", in};
auto program_in = wgsl::reader::Parse(&file, parser_options);
if (!program_in.IsValid()) {
- return "wgsl::reader::Parse() failed: \n" + program_in.Diagnostics().str();
+ return "wgsl::reader::Parse() failed: \n" + program_in.Diagnostics().Str();
}
auto module = wgsl::reader::ProgramToIR(program_in);
if (module != Success) {
- return "ProgramToIR() failed:\n" + module.Failure().reason.str();
+ return "ProgramToIR() failed:\n" + module.Failure().reason.Str();
}
auto res = DirectVariableAccess(module.Get(), transform_options);
if (res != Success) {
- return "DirectVariableAccess failed:\n" + res.Failure().reason.str();
+ return "DirectVariableAccess failed:\n" + res.Failure().reason.Str();
}
auto pre_raise = ir::Disassemble(module.Get());
if (auto raise = wgsl::writer::Raise(module.Get()); raise != Success) {
- return "wgsl::writer::Raise failed:\n" + res.Failure().reason.str();
+ return "wgsl::writer::Raise failed:\n" + res.Failure().reason.Str();
}
auto program_out = wgsl::writer::IRToProgram(module.Get(), program_options);
if (!program_out.IsValid()) {
- return "wgsl::writer::IRToProgram() failed: \n" + program_out.Diagnostics().str() +
+ return "wgsl::writer::IRToProgram() failed: \n" + program_out.Diagnostics().Str() +
"\n\nIR (pre):\n" + pre_raise + //
"\n\nIR (post):\n" + ir::Disassemble(module.Get()) + //
"\n\nAST:\n" + Program::printer(program_out);
@@ -96,7 +96,7 @@
auto output = wgsl::writer::Generate(program_out, wgsl::writer::Options{});
if (output != Success) {
- return "wgsl::writer::IRToProgram() failed: \n" + output.Failure().reason.str() +
+ return "wgsl::writer::IRToProgram() failed: \n" + output.Failure().reason.Str() +
"\n\nIR:\n" + ir::Disassemble(module.Get());
}
diff --git a/src/tint/lang/core/ir/validator.cc b/src/tint/lang/core/ir/validator.cc
index 65c952a..59e2fdd 100644
--- a/src/tint/lang/core/ir/validator.cc
+++ b/src/tint/lang/core/ir/validator.cc
@@ -324,7 +324,7 @@
CheckFunction(func);
}
- if (!diagnostics_.contains_errors()) {
+ if (!diagnostics_.ContainsErrors()) {
// Check for orphaned instructions.
for (auto* inst : mod_.instructions.Objects()) {
if (inst->Alive() && !visited_instructions_.Contains(inst)) {
@@ -333,10 +333,10 @@
}
}
- if (diagnostics_.contains_errors()) {
+ if (diagnostics_.ContainsErrors()) {
DisassembleIfNeeded();
- diagnostics_.add_note(tint::diag::System::IR,
- "# Disassembly\n" + disassembly_file->content.data, {});
+ diagnostics_.AddNote(tint::diag::System::IR,
+ "# Disassembly\n" + disassembly_file->content.data, {});
return Failure{std::move(diagnostics_)};
}
return Success;
@@ -401,7 +401,7 @@
}
void Validator::AddError(std::string err, Source src) {
- auto& diag = diagnostics_.add_error(tint::diag::System::IR, std::move(err), src);
+ auto& diag = diagnostics_.AddError(tint::diag::System::IR, std::move(err), src);
if (src.range != Source::Range{{}}) {
diag.source.file = disassembly_file.get();
diag.owned_file = disassembly_file;
@@ -409,7 +409,7 @@
}
void Validator::AddNote(std::string note, Source src) {
- auto& diag = diagnostics_.add_note(tint::diag::System::IR, std::move(note), src);
+ auto& diag = diagnostics_.AddNote(tint::diag::System::IR, std::move(note), src);
if (src.range != Source::Range{{}}) {
diag.source.file = disassembly_file.get();
diag.owned_file = disassembly_file;
diff --git a/src/tint/lang/core/ir/validator_test.cc b/src/tint/lang/core/ir/validator_test.cc
index 0c2bef9..cd5faeb 100644
--- a/src/tint/lang/core/ir/validator_test.cc
+++ b/src/tint/lang/core/ir/validator_test.cc
@@ -59,7 +59,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:2:3 error: root block: invalid instruction: tint::core::ir::Loop
loop [b: %b2] { # loop_1
^^^^^^^^^^^^^
@@ -90,7 +90,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:2:38 error: var: instruction in root block does not have root block as parent
%1:ptr<private, i32, read_write> = var
^^^
@@ -131,7 +131,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(error: function 'my_func' added to module multiple times
note: # Disassembly
%my_func = func(%2:i32, %3:f32):void -> %b1 {
@@ -160,7 +160,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:3:20 error: call: call target is not part of the module
%2:void = call %g
^^
@@ -191,7 +191,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:3:20 error: call: call target must not have a pipeline stage
%2:void = call %g
^^
@@ -228,7 +228,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:8:20 error: call: function has 2 parameters, but call provides 1 arguments
%5:void = call %g, 42i
^^
@@ -265,7 +265,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:8:20 error: call: function has 2 parameters, but call provides 3 arguments
%5:void = call %g, 1i, 2i, 3i
^^
@@ -302,7 +302,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:8:28 error: call: function parameter 1 is of type i32, but argument is of type f32
%6:void = call %g, 1i, 2.0f, 3i
^^^^
@@ -331,7 +331,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:2:3 error: block: does not end in a terminator instruction
%b1 = block {
^^^^^^^^^^^
@@ -358,7 +358,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:3:41 error: var: block instruction does not have same block as parent
%2:ptr<function, i32, read_write> = var
^^^
@@ -398,7 +398,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:3:25 error: access: constant index must be positive, got -1
%3:f32 = access %2, -1i
^^^
@@ -429,7 +429,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:3:29 error: access: index out of bounds for type vec2<f32>
%3:f32 = access %2, 1u, 3u
^^
@@ -465,7 +465,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
EXPECT_EQ(
- res.Failure().reason.str(),
+ res.Failure().reason.Str(),
R"(:3:55 error: access: index out of bounds for type ptr<private, array<f32, 2>, read_write>
%3:ptr<private, f32, read_write> = access %2, 1u, 3u
^^
@@ -500,7 +500,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:25 error: access: type f32 cannot be indexed
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:25 error: access: type f32 cannot be indexed
%3:f32 = access %2, 1u
^^
@@ -530,7 +530,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:3:51 error: access: type ptr<private, f32, read_write> cannot be indexed
%3:ptr<private, f32, read_write> = access %2, 1u
^^
@@ -567,7 +567,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:8:25 error: access: type MyStruct cannot be dynamically indexed
%4:i32 = access %2, %3
^^
@@ -610,7 +610,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
EXPECT_EQ(
- res.Failure().reason.str(),
+ res.Failure().reason.Str(),
R"(:8:25 error: access: type ptr<private, MyStruct, read_write> cannot be dynamically indexed
%4:i32 = access %2, %3
^^
@@ -646,7 +646,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:3:14 error: access: result of access chain is type f32 but instruction type is i32
%3:i32 = access %2, 1u, 1u
^^^^^^
@@ -678,7 +678,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
EXPECT_EQ(
- res.Failure().reason.str(),
+ res.Failure().reason.Str(),
R"(:3:40 error: access: result of access chain is type ptr<private, f32, read_write> but instruction type is ptr<private, i32, read_write>
%3:ptr<private, i32, read_write> = access %2, 1u, 1u
^^^^^^
@@ -710,7 +710,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
EXPECT_EQ(
- res.Failure().reason.str(),
+ res.Failure().reason.Str(),
R"(:3:14 error: access: result of access chain is type ptr<private, f32, read_write> but instruction type is f32
%3:f32 = access %2, 1u, 1u
^^^^^^
@@ -741,7 +741,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:3:25 error: access: cannot obtain address of vector element
%3:f32 = access %2, 1u
^^
@@ -786,7 +786,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:3:29 error: access: cannot obtain address of vector element
%3:f32 = access %2, 1u, 1u
^^
@@ -832,7 +832,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
EXPECT_EQ(
- res.Failure().reason.str(),
+ res.Failure().reason.Str(),
R"(:3:34 error: access: result of access chain is type ptr<storage, f32, read> but instruction type is ptr<uniform, f32, read>
%3:ptr<uniform, f32, read> = access %2, 1u
^^^^^^
@@ -864,7 +864,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
EXPECT_EQ(
- res.Failure().reason.str(),
+ res.Failure().reason.Str(),
R"(:3:40 error: access: result of access chain is type ptr<storage, f32, read> but instruction type is ptr<storage, f32, read_write>
%3:ptr<storage, f32, read_write> = access %2, 1u
^^^^^^
@@ -921,7 +921,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:3:5 error: block: terminator which isn't the final instruction
ret
^^^
@@ -963,7 +963,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:4:7 error: block: does not end in a terminator instruction
%b2 = block { # true
^^^^^^^^^^^
@@ -996,7 +996,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:8 error: if: condition must be a `bool` type
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:8 error: if: condition must be a `bool` type
if 1i [t: %b2, f: %b3] { # if_1
^^
@@ -1033,7 +1033,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:8 error: if: operand is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:8 error: if: operand is undefined
if undef [t: %b2, f: %b3] { # if_1
^^^^^
@@ -1072,7 +1072,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:5 error: if: result is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:5 error: if: result is undefined
undef = if true [t: %b2, f: %b3] { # if_1
^^^^^
@@ -1119,7 +1119,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:4:7 error: block: does not end in a terminator instruction
%b2 = block { # body
^^^^^^^^^^^
@@ -1143,7 +1143,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:2:3 error: var: result is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:2:3 error: var: result is undefined
undef = var
^^^^^
@@ -1170,7 +1170,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:5 error: var: result is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:5 error: var: result is undefined
undef = var
^^^^^
@@ -1200,7 +1200,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:41 error: var: initializer has incorrect type
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:41 error: var: initializer has incorrect type
%2:ptr<function, f32, read_write> = var, %3
^^^
@@ -1229,7 +1229,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:5 error: let: result is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:5 error: let: result is undefined
undef = let 1i
^^^^^
@@ -1258,7 +1258,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:18 error: let: operand is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:18 error: let: operand is undefined
%2:f32 = let undef
^^^^^
@@ -1287,7 +1287,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:14 error: let: result type does not match value type
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:14 error: let: result type does not match value type
%2:f32 = let 1i
^^^
@@ -1340,7 +1340,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), expected);
+ EXPECT_EQ(res.Failure().reason.Str(), expected);
}
TEST_F(IR_ValidatorTest, Instruction_NullInstruction) {
@@ -1354,7 +1354,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:3:5 error: var: instruction of result is undefined
%2:ptr<function, f32, read_write> = var
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1386,7 +1386,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:46 error: var: operand is not alive
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:46 error: var: operand is not alive
%2:ptr<function, f32, read_write> = var, %3
^^
@@ -1417,7 +1417,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:46 error: var: operand missing usage
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:46 error: var: operand missing usage
%2:ptr<function, f32, read_write> = var, %3
^^
@@ -1447,7 +1447,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(error: orphaned instruction: load
+ EXPECT_EQ(res.Failure().reason.Str(), R"(error: orphaned instruction: load
note: # Disassembly
%my_func = func():void -> %b1 {
%b1 = block {
@@ -1467,7 +1467,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:18 error: binary: operand is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:18 error: binary: operand is undefined
%2:i32 = add undef, 2i
^^^^^
@@ -1494,7 +1494,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:22 error: binary: operand is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:22 error: binary: operand is undefined
%2:i32 = add 2i, undef
^^^^^
@@ -1524,7 +1524,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:5 error: binary: result is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:5 error: binary: result is undefined
undef = add 3i, 2i
^^^^^
@@ -1551,7 +1551,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:23 error: unary: operand is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:23 error: unary: operand is undefined
%2:i32 = negation undef
^^^^^
@@ -1581,7 +1581,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:5 error: unary: result is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:5 error: unary: result is undefined
undef = negation 2i
^^^^^
@@ -1611,7 +1611,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
EXPECT_EQ(
- res.Failure().reason.str(),
+ res.Failure().reason.Str(),
R"(:3:5 error: unary: unary instruction result type (f32) does not match overload result type (i32)
%2:f32 = complement 2i
^^^^^^^^^^^^^^^^^^^^^^
@@ -1653,7 +1653,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:5:9 error: exit_if: has no parent control instruction
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:5:9 error: exit_if: has no parent control instruction
exit_if # undef
^^^^^^^
@@ -1691,7 +1691,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
EXPECT_EQ(
- res.Failure().reason.str(),
+ res.Failure().reason.Str(),
R"(:5:9 error: exit_if: args count (1) does not match control instruction result count (2)
exit_if 1i # if_1
^^^^^^^^^^
@@ -1735,7 +1735,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
EXPECT_EQ(
- res.Failure().reason.str(),
+ res.Failure().reason.Str(),
R"(:5:9 error: exit_if: args count (3) does not match control instruction result count (2)
exit_if 1i, 2.0f, 3i # if_1
^^^^^^^^^^^^^^^^^^^^
@@ -1796,7 +1796,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
EXPECT_EQ(
- res.Failure().reason.str(),
+ res.Failure().reason.Str(),
R"(:5:21 error: exit_if: argument type (f32) does not match control instruction type (i32)
exit_if 1i, 2i # if_1
^^
@@ -1836,7 +1836,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:8:5 error: exit_if: found outside all control instructions
exit_if # if_1
^^^^^^^
@@ -1879,7 +1879,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:7:13 error: exit_if: if target jumps over other control instructions
exit_if # if_1
^^^^^^^
@@ -1932,7 +1932,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:7:13 error: exit_if: if target jumps over other control instructions
exit_if # if_1
^^^^^^^
@@ -1984,7 +1984,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:7:13 error: exit_if: if target jumps over other control instructions
exit_if # if_1
^^^^^^^
@@ -2043,7 +2043,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:5:9 error: exit_switch: has no parent control instruction
exit_switch # undef
^^^^^^^^^^^
@@ -2084,7 +2084,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
EXPECT_EQ(
- res.Failure().reason.str(),
+ res.Failure().reason.Str(),
R"(:5:9 error: exit_switch: args count (1) does not match control instruction result count (2)
exit_switch 1i # switch_1
^^^^^^^^^^^^^^
@@ -2128,7 +2128,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
EXPECT_EQ(
- res.Failure().reason.str(),
+ res.Failure().reason.Str(),
R"(:5:9 error: exit_switch: args count (3) does not match control instruction result count (2)
exit_switch 1i, 2.0f, 3i # switch_1
^^^^^^^^^^^^^^^^^^^^^^^^
@@ -2190,7 +2190,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
EXPECT_EQ(
- res.Failure().reason.str(),
+ res.Failure().reason.Str(),
R"(:5:25 error: exit_switch: argument type (f32) does not match control instruction type (i32)
exit_switch 1i, 2i # switch_1
^^
@@ -2234,7 +2234,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:10:9 error: exit_switch: switch not found in parent control instructions
exit_switch # switch_1
^^^^^^^^^^^
@@ -2315,7 +2315,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:7:13 error: exit_switch: switch target jumps over other control instructions
exit_switch # switch_1
^^^^^^^^^^^
@@ -2366,7 +2366,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:7:13 error: exit_switch: switch target jumps over other control instructions
exit_switch # switch_1
^^^^^^^^^^^
@@ -2423,7 +2423,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:5:9 error: exit_loop: has no parent control instruction
exit_loop # undef
^^^^^^^^^
@@ -2466,7 +2466,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
EXPECT_EQ(
- res.Failure().reason.str(),
+ res.Failure().reason.Str(),
R"(:5:9 error: exit_loop: args count (1) does not match control instruction result count (2)
exit_loop 1i # loop_1
^^^^^^^^^^^^
@@ -2513,7 +2513,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
EXPECT_EQ(
- res.Failure().reason.str(),
+ res.Failure().reason.Str(),
R"(:5:9 error: exit_loop: args count (3) does not match control instruction result count (2)
exit_loop 1i, 2.0f, 3i # loop_1
^^^^^^^^^^^^^^^^^^^^^^
@@ -2578,7 +2578,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
EXPECT_EQ(
- res.Failure().reason.str(),
+ res.Failure().reason.Str(),
R"(:5:23 error: exit_loop: argument type (f32) does not match control instruction type (i32)
exit_loop 1i, 2i # loop_1
^^
@@ -2624,7 +2624,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:13:9 error: exit_loop: loop not found in parent control instructions
exit_loop # loop_1
^^^^^^^^^
@@ -2707,7 +2707,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:7:13 error: exit_loop: loop target jumps over other control instructions
exit_loop # loop_1
^^^^^^^^^
@@ -2762,7 +2762,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:7:13 error: exit_loop: loop target jumps over other control instructions
exit_loop # loop_1
^^^^^^^^^
@@ -2812,7 +2812,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:8:9 error: exit_loop: loop exit jumps out of continuing block
exit_loop # loop_1
^^^^^^^^^
@@ -2858,7 +2858,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:10:13 error: exit_loop: loop exit jumps out of continuing block
exit_loop # loop_1
^^^^^^^^^
@@ -2910,7 +2910,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:5:9 error: exit_loop: loop exit not permitted in loop initializer
exit_loop # loop_1
^^^^^^^^^
@@ -2960,7 +2960,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:7:13 error: exit_loop: loop exit not permitted in loop initializer
exit_loop # loop_1
^^^^^^^^^
@@ -3024,7 +3024,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:5 error: return: undefined function
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:5 error: return: undefined function
ret
^^^
@@ -3049,7 +3049,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:5 error: return: unexpected return value
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:5 error: return: unexpected return value
ret 42i
^^^^^^^
@@ -3074,7 +3074,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:5 error: return: expected return value
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:5 error: return: expected return value
ret
^^^
@@ -3099,7 +3099,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:3:5 error: return: return value type does not match function return type
ret 42.0f
^^^^^^^^^
@@ -3127,7 +3127,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:19 error: load: operand is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:19 error: load: operand is undefined
%2:i32 = load undef
^^^^^
@@ -3156,7 +3156,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:4:19 error: load source operand is not a memory view
%3:f32 = load %l
^^
@@ -3187,7 +3187,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:4:19 error: result type does not match source store type
%3:f32 = load %2
^^
@@ -3217,7 +3217,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:11 error: store: operand is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:11 error: store: operand is undefined
store undef, 42i
^^^^^
@@ -3246,7 +3246,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:4:15 error: store: operand is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:4:15 error: store: operand is undefined
store %2, undef
^^^^^
@@ -3276,7 +3276,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:4:15 error: store target operand is not a memory view
store %l, 42u
^^^
@@ -3307,7 +3307,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:4:15 error: value type does not match store type
store %2, 42u
^^^
@@ -3339,7 +3339,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(),
+ EXPECT_EQ(res.Failure().reason.Str(),
R"(:4:5 error: load_vector_element: result is undefined
undef = load_vector_element %2, 1i
^^^^^
@@ -3370,7 +3370,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:34 error: load_vector_element: operand is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:34 error: load_vector_element: operand is undefined
%2:f32 = load_vector_element undef, 1i
^^^^^
@@ -3400,7 +3400,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:4:38 error: load_vector_element: operand is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:4:38 error: load_vector_element: operand is undefined
%3:f32 = load_vector_element %2, undef
^^^^^
@@ -3430,7 +3430,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:3:26 error: store_vector_element: operand is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:3:26 error: store_vector_element: operand is undefined
store_vector_element undef, 1i, 2i
^^^^^
@@ -3460,7 +3460,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:4:30 error: store_vector_element: operand is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:4:30 error: store_vector_element: operand is undefined
store_vector_element %2, undef, 2i
^^^^^
@@ -3499,7 +3499,7 @@
auto res = ir::Validate(mod);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(:4:34 error: store_vector_element: operand is undefined
+ EXPECT_EQ(res.Failure().reason.Str(), R"(:4:34 error: store_vector_element: operand is undefined
store_vector_element %2, 1i, undef
^^^^^
diff --git a/src/tint/lang/glsl/writer/ast_printer/ast_printer.cc b/src/tint/lang/glsl/writer/ast_printer/ast_printer.cc
index 77a8fbe..a9c8c31 100644
--- a/src/tint/lang/glsl/writer/ast_printer/ast_printer.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/ast_printer.cc
@@ -355,7 +355,7 @@
helpers_insertion_point += helpers_.lines.size();
}
- return !diagnostics_.contains_errors();
+ return !diagnostics_.ContainsErrors();
}
void ASTPrinter::RecordExtension(const ast::Enable* enable) {
@@ -382,8 +382,8 @@
auto* dst_type = TypeOf(expr)->UnwrapRef();
if (!dst_type->is_integer_scalar_or_vector() && !dst_type->is_float_scalar_or_vector()) {
- diagnostics_.add_error(diag::System::Writer,
- "Unable to do bitcast to type " + dst_type->FriendlyName());
+ diagnostics_.AddError(diag::System::Writer,
+ "Unable to do bitcast to type " + dst_type->FriendlyName());
return;
}
@@ -1504,9 +1504,9 @@
out << "imageStore";
break;
default:
- diagnostics_.add_error(diag::System::Writer,
- "Internal compiler error: Unhandled texture builtin '" +
- std::string(builtin->str()) + "'");
+ diagnostics_.AddError(diag::System::Writer,
+ "Internal compiler error: Unhandled texture builtin '" +
+ std::string(builtin->str()) + "'");
return;
}
@@ -1729,8 +1729,8 @@
case wgsl::BuiltinFn::kUnpack4X8Unorm:
return "unpackUnorm4x8";
default:
- diagnostics_.add_error(diag::System::Writer,
- "Unknown builtin method: " + std::string(builtin->str()));
+ diagnostics_.AddError(diag::System::Writer,
+ "Unknown builtin method: " + std::string(builtin->str()));
}
return "";
@@ -1909,9 +1909,9 @@
[&](const ast::Let* let) { EmitProgramConstVariable(let); },
[&](const ast::Override*) {
// Override is removed with SubstituteOverride
- diagnostics_.add_error(diag::System::Writer,
- "override-expressions should have been removed with the "
- "SubstituteOverride transform");
+ diagnostics_.AddError(diag::System::Writer,
+ "override-expressions should have been removed with the "
+ "SubstituteOverride transform");
},
[&](const ast::Const*) {
// Constants are embedded at their use
@@ -2175,7 +2175,7 @@
out << "local_size_" << (i == 0 ? "x" : i == 1 ? "y" : "z") << " = ";
if (!wgsize[i].has_value()) {
- diagnostics_.add_error(
+ diagnostics_.AddError(
diag::System::Writer,
"override-expressions should have been removed with the SubstituteOverride "
"transform");
@@ -2279,8 +2279,8 @@
auto count = a->ConstantCount();
if (!count) {
- diagnostics_.add_error(diag::System::Writer,
- core::type::Array::kErrExpectedConstantCount);
+ diagnostics_.AddError(diag::System::Writer,
+ core::type::Array::kErrExpectedConstantCount);
return;
}
@@ -2331,7 +2331,7 @@
return;
}
}
- diagnostics_.add_error(diag::System::Writer, "unknown integer literal suffix type");
+ diagnostics_.AddError(diag::System::Writer, "unknown integer literal suffix type");
}, //
TINT_ICE_ON_NO_MATCH);
}
@@ -2383,8 +2383,8 @@
auto count = arr->ConstantCount();
if (!count) {
- diagnostics_.add_error(diag::System::Writer,
- core::type::Array::kErrExpectedConstantCount);
+ diagnostics_.AddError(diag::System::Writer,
+ core::type::Array::kErrExpectedConstantCount);
return;
}
@@ -2395,8 +2395,8 @@
EmitZeroValue(out, arr->ElemType());
}
} else {
- diagnostics_.add_error(diag::System::Writer,
- "Invalid type for zero emission: " + type->FriendlyName());
+ diagnostics_.AddError(diag::System::Writer,
+ "Invalid type for zero emission: " + type->FriendlyName());
}
}
@@ -2671,8 +2671,8 @@
} else {
auto count = arr->ConstantCount();
if (!count) {
- diagnostics_.add_error(diag::System::Writer,
- core::type::Array::kErrExpectedConstantCount);
+ diagnostics_.AddError(diag::System::Writer,
+ core::type::Array::kErrExpectedConstantCount);
return;
}
sizes.push_back(count.value());
@@ -2827,7 +2827,7 @@
} else if (type->Is<core::type::Void>()) {
out << "void";
} else {
- diagnostics_.add_error(diag::System::Writer, "unknown type in EmitType");
+ diagnostics_.AddError(diag::System::Writer, "unknown type in EmitType");
}
}
diff --git a/src/tint/lang/glsl/writer/ast_printer/ast_printer_test.cc b/src/tint/lang/glsl/writer/ast_printer/ast_printer_test.cc
index 19aac5b..475f00a 100644
--- a/src/tint/lang/glsl/writer/ast_printer/ast_printer_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/ast_printer_test.cc
@@ -35,13 +35,13 @@
using GlslASTPrinterTest = TestHelper;
TEST_F(GlslASTPrinterTest, InvalidProgram) {
- Diagnostics().add_error(diag::System::Writer, "make the program invalid");
+ Diagnostics().AddError(diag::System::Writer, "make the program invalid");
ASSERT_FALSE(IsValid());
auto program = resolver::Resolve(*this);
ASSERT_FALSE(program.IsValid());
auto result = Generate(program, Options{}, "");
EXPECT_NE(result, Success);
- EXPECT_EQ(result.Failure().reason.str(), "error: make the program invalid");
+ EXPECT_EQ(result.Failure().reason.Str(), "error: make the program invalid");
}
TEST_F(GlslASTPrinterTest, Generate) {
@@ -128,7 +128,7 @@
ASSERT_FALSE(gen.Generate());
EXPECT_EQ(
- gen.Diagnostics().str(),
+ gen.Diagnostics().Str(),
R"(12:34 error: GLSL backend does not support extension 'chromium_internal_relaxed_uniform_layout')");
}
diff --git a/src/tint/lang/glsl/writer/ast_printer/function_test.cc b/src/tint/lang/glsl/writer/ast_printer/function_test.cc
index c113c83..32a8b0f 100644
--- a/src/tint/lang/glsl/writer/ast_printer/function_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/function_test.cc
@@ -829,7 +829,7 @@
ASTPrinter& gen = Build();
gen.Generate();
EXPECT_EQ(
- gen.Diagnostics().str(),
+ gen.Diagnostics().Str(),
R"(error: override-expressions should have been removed with the SubstituteOverride transform
error: override-expressions should have been removed with the SubstituteOverride transform
error: override-expressions should have been removed with the SubstituteOverride transform
diff --git a/src/tint/lang/glsl/writer/ast_raise/combine_samplers.cc b/src/tint/lang/glsl/writer/ast_raise/combine_samplers.cc
index 6762ee6..25cc723d 100644
--- a/src/tint/lang/glsl/writer/ast_raise/combine_samplers.cc
+++ b/src/tint/lang/glsl/writer/ast_raise/combine_samplers.cc
@@ -441,8 +441,8 @@
auto* binding_info = inputs.Get<BindingInfo>();
if (!binding_info) {
ProgramBuilder b;
- b.Diagnostics().add_error(diag::System::Transform,
- "missing transform data for " + std::string(TypeInfo().name));
+ b.Diagnostics().AddError(diag::System::Transform,
+ "missing transform data for " + std::string(TypeInfo().name));
return resolver::Resolve(b);
}
diff --git a/src/tint/lang/glsl/writer/ast_raise/texture_builtins_from_uniform.cc b/src/tint/lang/glsl/writer/ast_raise/texture_builtins_from_uniform.cc
index 2b31e07..7d3a4ab 100644
--- a/src/tint/lang/glsl/writer/ast_raise/texture_builtins_from_uniform.cc
+++ b/src/tint/lang/glsl/writer/ast_raise/texture_builtins_from_uniform.cc
@@ -74,7 +74,7 @@
ApplyResult Run() {
auto* cfg = inputs.Get<Config>();
if (cfg == nullptr) {
- b.Diagnostics().add_error(
+ b.Diagnostics().AddError(
diag::System::Transform,
"missing transform data for " +
std::string(tint::TypeInfo::Of<TextureBuiltinsFromUniform>().name));
diff --git a/src/tint/lang/glsl/writer/printer/helper_test.h b/src/tint/lang/glsl/writer/printer/helper_test.h
index a720241..7550ecb 100644
--- a/src/tint/lang/glsl/writer/printer/helper_test.h
+++ b/src/tint/lang/glsl/writer/printer/helper_test.h
@@ -63,13 +63,13 @@
/// @returns true if generation and validation succeeded
bool Generate() {
if (auto raised = Raise(mod); raised != Success) {
- err_ = raised.Failure().reason.str();
+ err_ = raised.Failure().reason.Str();
return false;
}
auto result = Print(mod, version);
if (result != Success) {
- err_ = result.Failure().reason.str();
+ err_ = result.Failure().reason.Str();
return false;
}
output_ = result.Get();
diff --git a/src/tint/lang/glsl/writer/writer_bench.cc b/src/tint/lang/glsl/writer/writer_bench.cc
index 162e5b0..8505dac 100644
--- a/src/tint/lang/glsl/writer/writer_bench.cc
+++ b/src/tint/lang/glsl/writer/writer_bench.cc
@@ -38,7 +38,7 @@
void GenerateGLSL(benchmark::State& state, std::string input_name) {
auto res = bench::LoadProgram(input_name);
if (res != Success) {
- state.SkipWithError(res.Failure().reason.str());
+ state.SkipWithError(res.Failure().reason.Str());
return;
}
auto& program = res->program;
@@ -53,7 +53,7 @@
for (auto& ep : entry_points) {
auto gen_res = Generate(program, {}, ep);
if (gen_res != Success) {
- state.SkipWithError(gen_res.Failure().reason.str());
+ state.SkipWithError(gen_res.Failure().reason.Str());
}
}
}
diff --git a/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc b/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc
index f2a8f82..cc97b5e 100644
--- a/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc
+++ b/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc
@@ -698,8 +698,8 @@
auto* dst_el_type = dst_type->DeepestElement();
if (!dst_el_type->is_integer_scalar() && !dst_el_type->is_float_scalar()) {
- diagnostics_.add_error(diag::System::Writer,
- "Unable to do bitcast to type " + dst_el_type->FriendlyName());
+ diagnostics_.AddError(diag::System::Writer,
+ "Unable to do bitcast to type " + dst_el_type->FriendlyName());
return false;
}
@@ -2443,8 +2443,8 @@
break;
}
default:
- diagnostics_.add_error(diag::System::Writer,
- "Internal error: unhandled data packing builtin");
+ diagnostics_.AddError(diag::System::Writer,
+ "Internal error: unhandled data packing builtin");
return false;
}
@@ -2510,8 +2510,8 @@
Line(b) << "return f16tof32(uint2(i & 0xffff, i >> 16));";
break;
default:
- diagnostics_.add_error(diag::System::Writer,
- "Internal error: unhandled data packing builtin");
+ diagnostics_.AddError(diag::System::Writer,
+ "Internal error: unhandled data packing builtin");
return false;
}
@@ -2585,8 +2585,8 @@
functionName = "dot4add_u8packed";
break;
default:
- diagnostics_.add_error(diag::System::Writer,
- "Internal error: unhandled DP4a builtin");
+ diagnostics_.AddError(diag::System::Writer,
+ "Internal error: unhandled DP4a builtin");
return false;
}
Line(b) << "return " << functionName << "(" << params[0] << ", " << params[1]
@@ -2925,9 +2925,9 @@
out << "[";
break;
default:
- diagnostics_.add_error(diag::System::Writer,
- "Internal compiler error: Unhandled texture builtin '" +
- std::string(builtin->str()) + "'");
+ diagnostics_.AddError(diag::System::Writer,
+ "Internal compiler error: Unhandled texture builtin '" +
+ std::string(builtin->str()) + "'");
return false;
}
@@ -3113,8 +3113,8 @@
case wgsl::BuiltinFn::kSubgroupBroadcast:
return "WaveReadLaneAt";
default:
- diagnostics_.add_error(diag::System::Writer,
- "Unknown builtin method: " + std::string(builtin->str()));
+ diagnostics_.AddError(diag::System::Writer,
+ "Unknown builtin method: " + std::string(builtin->str()));
}
return "";
@@ -3386,7 +3386,7 @@
case core::AddressSpace::kWorkgroup:
return EmitWorkgroupVariable(sem);
case core::AddressSpace::kPushConstant:
- diagnostics_.add_error(
+ diagnostics_.AddError(
diag::System::Writer,
"unhandled address space " + tint::ToString(sem->AddressSpace()));
return false;
@@ -3398,9 +3398,9 @@
},
[&](const ast::Override*) {
// Override is removed with SubstituteOverride
- diagnostics_.add_error(diag::System::Writer,
- "override-expressions should have been removed with the "
- "SubstituteOverride transform");
+ diagnostics_.AddError(diag::System::Writer,
+ "override-expressions should have been removed with the "
+ "SubstituteOverride transform");
return false;
},
[&](const ast::Const*) {
@@ -3623,7 +3623,7 @@
out << ", ";
}
if (!wgsize[i].has_value()) {
- diagnostics_.add_error(
+ diagnostics_.AddError(
diag::System::Writer,
"override-expressions should have been removed with the SubstituteOverride "
"transform");
@@ -3778,8 +3778,8 @@
auto count = a->ConstantCount();
if (!count) {
- diagnostics_.add_error(diag::System::Writer,
- core::type::Array::kErrExpectedConstantCount);
+ diagnostics_.AddError(diag::System::Writer,
+ core::type::Array::kErrExpectedConstantCount);
return false;
}
@@ -3874,7 +3874,7 @@
out << "u";
return true;
}
- diagnostics_.add_error(diag::System::Writer, "unknown integer literal suffix type");
+ diagnostics_.AddError(diag::System::Writer, "unknown integer literal suffix type");
return false;
}, //
TINT_ICE_ON_NO_MATCH);
@@ -4341,8 +4341,8 @@
}
const auto count = arr->ConstantCount();
if (!count) {
- diagnostics_.add_error(diag::System::Writer,
- core::type::Array::kErrExpectedConstantCount);
+ diagnostics_.AddError(diag::System::Writer,
+ core::type::Array::kErrExpectedConstantCount);
return false;
}
@@ -4581,7 +4581,7 @@
if (auto builtin = attributes.builtin) {
auto name = builtin_to_attribute(builtin.value());
if (name.empty()) {
- diagnostics_.add_error(diag::System::Writer, "unsupported builtin");
+ diagnostics_.AddError(diag::System::Writer, "unsupported builtin");
return false;
}
post += " : " + name;
@@ -4589,7 +4589,7 @@
if (auto interpolation = attributes.interpolation) {
auto mod = interpolation_to_modifiers(interpolation->type, interpolation->sampling);
if (mod.empty()) {
- diagnostics_.add_error(diag::System::Writer, "unsupported interpolation");
+ diagnostics_.AddError(diag::System::Writer, "unsupported interpolation");
return false;
}
pre += mod;
diff --git a/src/tint/lang/hlsl/writer/ast_printer/ast_printer_test.cc b/src/tint/lang/hlsl/writer/ast_printer/ast_printer_test.cc
index 0d68b42..88db758 100644
--- a/src/tint/lang/hlsl/writer/ast_printer/ast_printer_test.cc
+++ b/src/tint/lang/hlsl/writer/ast_printer/ast_printer_test.cc
@@ -35,13 +35,13 @@
using HlslASTPrinterTest = TestHelper;
TEST_F(HlslASTPrinterTest, InvalidProgram) {
- Diagnostics().add_error(diag::System::Writer, "make the program invalid");
+ Diagnostics().AddError(diag::System::Writer, "make the program invalid");
ASSERT_FALSE(IsValid());
auto program = resolver::Resolve(*this);
ASSERT_FALSE(program.IsValid());
auto result = Generate(program, Options{});
EXPECT_NE(result, Success);
- EXPECT_EQ(result.Failure().reason.str(), "error: make the program invalid");
+ EXPECT_EQ(result.Failure().reason.Str(), "error: make the program invalid");
}
TEST_F(HlslASTPrinterTest, UnsupportedExtension) {
@@ -51,7 +51,7 @@
ASSERT_FALSE(gen.Generate());
EXPECT_EQ(
- gen.Diagnostics().str(),
+ gen.Diagnostics().Str(),
R"(12:34 error: HLSL backend does not support extension 'chromium_internal_relaxed_uniform_layout')");
}
diff --git a/src/tint/lang/hlsl/writer/ast_printer/function_test.cc b/src/tint/lang/hlsl/writer/ast_printer/function_test.cc
index 2f6822c..2575346 100644
--- a/src/tint/lang/hlsl/writer/ast_printer/function_test.cc
+++ b/src/tint/lang/hlsl/writer/ast_printer/function_test.cc
@@ -737,7 +737,7 @@
EXPECT_FALSE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(
- gen.Diagnostics().str(),
+ gen.Diagnostics().Str(),
R"(error: override-expressions should have been removed with the SubstituteOverride transform)");
}
diff --git a/src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.cc b/src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.cc
index 22a8ff3..610fc4b 100644
--- a/src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.cc
+++ b/src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.cc
@@ -90,8 +90,8 @@
auto* cfg = inputs.Get<Config>();
if (cfg == nullptr) {
- b.Diagnostics().add_error(diag::System::Transform,
- "missing transform data for " + std::string(TypeInfo().name));
+ b.Diagnostics().AddError(diag::System::Transform,
+ "missing transform data for " + std::string(TypeInfo().name));
return resolver::Resolve(b);
}
diff --git a/src/tint/lang/hlsl/writer/ast_raise/pixel_local.cc b/src/tint/lang/hlsl/writer/ast_raise/pixel_local.cc
index de4f17d..b3fa496 100644
--- a/src/tint/lang/hlsl/writer/ast_raise/pixel_local.cc
+++ b/src/tint/lang/hlsl/writer/ast_raise/pixel_local.cc
@@ -453,9 +453,9 @@
uint32_t ROVRegisterIndex(uint32_t field_index) {
auto idx = cfg.pls_member_to_rov_reg.Get(field_index);
if (TINT_UNLIKELY(!idx)) {
- b.Diagnostics().add_error(diag::System::Transform,
- "PixelLocal::Config::attachments missing entry for field " +
- std::to_string(field_index));
+ b.Diagnostics().AddError(diag::System::Transform,
+ "PixelLocal::Config::attachments missing entry for field " +
+ std::to_string(field_index));
return 0;
}
return *idx;
@@ -466,9 +466,9 @@
core::TexelFormat ROVTexelFormat(uint32_t field_index) {
auto format = cfg.pls_member_to_rov_format.Get(field_index);
if (TINT_UNLIKELY(!format)) {
- b.Diagnostics().add_error(diag::System::Transform,
- "PixelLocal::Config::attachments missing entry for field " +
- std::to_string(field_index));
+ b.Diagnostics().AddError(diag::System::Transform,
+ "PixelLocal::Config::attachments missing entry for field " +
+ std::to_string(field_index));
return core::TexelFormat::kUndefined;
}
return *format;
@@ -485,8 +485,8 @@
auto* cfg = inputs.Get<Config>();
if (!cfg) {
ProgramBuilder b;
- b.Diagnostics().add_error(diag::System::Transform,
- "missing transform data for " + std::string(TypeInfo().name));
+ b.Diagnostics().AddError(diag::System::Transform,
+ "missing transform data for " + std::string(TypeInfo().name));
return resolver::Resolve(b);
}
diff --git a/src/tint/lang/hlsl/writer/ast_raise/truncate_interstage_variables.cc b/src/tint/lang/hlsl/writer/ast_raise/truncate_interstage_variables.cc
index 5d38ff8..d6c1b25 100644
--- a/src/tint/lang/hlsl/writer/ast_raise/truncate_interstage_variables.cc
+++ b/src/tint/lang/hlsl/writer/ast_raise/truncate_interstage_variables.cc
@@ -70,7 +70,7 @@
const auto* data = config.Get<Config>();
if (data == nullptr) {
- b.Diagnostics().add_error(
+ b.Diagnostics().AddError(
diag::System::Transform,
"missing transform data for " +
std::string(tint::TypeInfo::Of<TruncateInterstageVariables>().name));
diff --git a/src/tint/lang/hlsl/writer/writer_bench.cc b/src/tint/lang/hlsl/writer/writer_bench.cc
index 4e9a856..55939cf 100644
--- a/src/tint/lang/hlsl/writer/writer_bench.cc
+++ b/src/tint/lang/hlsl/writer/writer_bench.cc
@@ -36,13 +36,13 @@
void GenerateHLSL(benchmark::State& state, std::string input_name) {
auto res = bench::LoadProgram(input_name);
if (res != Success) {
- state.SkipWithError(res.Failure().reason.str());
+ state.SkipWithError(res.Failure().reason.Str());
return;
}
for (auto _ : state) {
auto gen_res = Generate(res->program, {});
if (gen_res != Success) {
- state.SkipWithError(gen_res.Failure().reason.str());
+ state.SkipWithError(gen_res.Failure().reason.Str());
}
}
}
diff --git a/src/tint/lang/msl/writer/ast_printer/ast_printer.cc b/src/tint/lang/msl/writer/ast_printer/ast_printer.cc
index 4c987c9..746afae 100644
--- a/src/tint/lang/msl/writer/ast_printer/ast_printer.cc
+++ b/src/tint/lang/msl/writer/ast_printer/ast_printer.cc
@@ -309,9 +309,9 @@
},
[&](const ast::Override*) {
// Override is removed with SubstituteOverride
- diagnostics_.add_error(diag::System::Writer,
- "override-expressions should have been removed with the "
- "SubstituteOverride transform.");
+ diagnostics_.AddError(diag::System::Writer,
+ "override-expressions should have been removed with the "
+ "SubstituteOverride transform.");
return false;
},
[&](const ast::Function* func) {
@@ -368,7 +368,7 @@
return false;
}
} else {
- diagnostics_.add_error(diag::System::Writer, "unknown alias type: " + ty->FriendlyName());
+ diagnostics_.AddError(diag::System::Writer, "unknown alias type: " + ty->FriendlyName());
return false;
}
@@ -1062,7 +1062,7 @@
std::vector<const char*> dims;
switch (texture_type->dim()) {
case core::type::TextureDimension::kNone:
- diagnostics_.add_error(diag::System::Writer, "texture dimension is kNone");
+ diagnostics_.AddError(diag::System::Writer, "texture dimension is kNone");
return false;
case core::type::TextureDimension::k1d:
dims = {"width"};
@@ -1263,7 +1263,7 @@
default: {
StringStream err;
err << "MSL does not support gradients for " << dim << " textures";
- diagnostics_.add_error(diag::System::Writer, err.str());
+ diagnostics_.AddError(diag::System::Writer, err.str());
return false;
}
}
@@ -1619,15 +1619,15 @@
out += "unpack_unorm2x16_to_float";
break;
case wgsl::BuiltinFn::kArrayLength:
- diagnostics_.add_error(
+ diagnostics_.AddError(
diag::System::Writer,
"Unable to translate builtin: " + std::string(builtin->str()) +
"\nDid you forget to pass array_length_from_uniform generator "
"options?");
return "";
default:
- diagnostics_.add_error(diag::System::Writer,
- "Unknown import method: " + std::string(builtin->str()));
+ diagnostics_.AddError(diag::System::Writer,
+ "Unknown import method: " + std::string(builtin->str()));
return "";
}
return out;
@@ -1802,8 +1802,8 @@
auto count = a->ConstantCount();
if (!count) {
- diagnostics_.add_error(diag::System::Writer,
- core::type::Array::kErrExpectedConstantCount);
+ diagnostics_.AddError(diag::System::Writer,
+ core::type::Array::kErrExpectedConstantCount);
return false;
}
@@ -1873,7 +1873,7 @@
return true;
}
}
- diagnostics_.add_error(diag::System::Writer, "unknown integer literal suffix type");
+ diagnostics_.AddError(diag::System::Writer, "unknown integer literal suffix type");
return false;
}, //
TINT_ICE_ON_NO_MATCH);
@@ -2069,7 +2069,7 @@
auto name = BuiltinToAttribute(builtin);
if (name.empty()) {
- diagnostics_.add_error(diag::System::Writer, "unknown builtin");
+ diagnostics_.AddError(diag::System::Writer, "unknown builtin");
return false;
}
out << " [[" << name << "]]";
@@ -2526,8 +2526,8 @@
} else {
auto count = arr->ConstantCount();
if (!count) {
- diagnostics_.add_error(diag::System::Writer,
- core::type::Array::kErrExpectedConstantCount);
+ diagnostics_.AddError(diag::System::Writer,
+ core::type::Array::kErrExpectedConstantCount);
return false;
}
@@ -2615,7 +2615,7 @@
out << "cube_array";
break;
default:
- diagnostics_.add_error(diag::System::Writer, "Invalid texture dimensions");
+ diagnostics_.AddError(diag::System::Writer, "Invalid texture dimensions");
return false;
}
if (tex->IsAnyOf<core::type::MultisampledTexture,
@@ -2648,8 +2648,8 @@
} else if (storage->access() == core::Access::kWrite) {
out << ", access::write";
} else {
- diagnostics_.add_error(diag::System::Writer,
- "Invalid access control for storage texture");
+ diagnostics_.AddError(diag::System::Writer,
+ "Invalid access control for storage texture");
return false;
}
return true;
@@ -2790,7 +2790,7 @@
if (auto builtin = attributes.builtin) {
auto name = BuiltinToAttribute(builtin.value());
if (name.empty()) {
- diagnostics_.add_error(diag::System::Writer, "unknown builtin");
+ diagnostics_.AddError(diag::System::Writer, "unknown builtin");
return false;
}
out << " [[" << name << "]]";
@@ -2832,7 +2832,7 @@
if (auto interpolation = attributes.interpolation) {
auto name = InterpolationToAttribute(interpolation->type, interpolation->sampling);
if (name.empty()) {
- diagnostics_.add_error(diag::System::Writer, "unknown interpolation attribute");
+ diagnostics_.AddError(diag::System::Writer, "unknown interpolation attribute");
return false;
}
out << " [[" << name << "]]";
diff --git a/src/tint/lang/msl/writer/ast_printer/ast_printer_test.cc b/src/tint/lang/msl/writer/ast_printer/ast_printer_test.cc
index 28a2d3e..1a219e0 100644
--- a/src/tint/lang/msl/writer/ast_printer/ast_printer_test.cc
+++ b/src/tint/lang/msl/writer/ast_printer/ast_printer_test.cc
@@ -39,13 +39,13 @@
using MslASTPrinterTest = TestHelper;
TEST_F(MslASTPrinterTest, InvalidProgram) {
- Diagnostics().add_error(diag::System::Writer, "make the program invalid");
+ Diagnostics().AddError(diag::System::Writer, "make the program invalid");
ASSERT_FALSE(IsValid());
auto program = resolver::Resolve(*this);
ASSERT_FALSE(program.IsValid());
auto result = Generate(program, Options{});
EXPECT_NE(result, Success);
- EXPECT_EQ(result.Failure().reason.str(), "error: make the program invalid");
+ EXPECT_EQ(result.Failure().reason.Str(), "error: make the program invalid");
}
TEST_F(MslASTPrinterTest, UnsupportedExtension) {
@@ -55,7 +55,7 @@
ASSERT_FALSE(gen.Generate());
EXPECT_EQ(
- gen.Diagnostics().str(),
+ gen.Diagnostics().Str(),
R"(12:34 error: MSL backend does not support extension 'chromium_experimental_push_constant')");
}
diff --git a/src/tint/lang/msl/writer/ast_printer/sanitizer_test.cc b/src/tint/lang/msl/writer/ast_printer/sanitizer_test.cc
index 57dc161..4745f0c 100644
--- a/src/tint/lang/msl/writer/ast_printer/sanitizer_test.cc
+++ b/src/tint/lang/msl/writer/ast_printer/sanitizer_test.cc
@@ -296,7 +296,7 @@
ASTPrinter& gen = SanitizeAndBuild(options);
ASSERT_FALSE(gen.Generate());
- EXPECT_THAT(gen.Diagnostics().str(), HasSubstr("Unable to translate builtin: arrayLength"));
+ EXPECT_THAT(gen.Diagnostics().Str(), HasSubstr("Unable to translate builtin: arrayLength"));
}
} // namespace
diff --git a/src/tint/lang/msl/writer/ast_raise/module_scope_var_to_entry_point_param.cc b/src/tint/lang/msl/writer/ast_raise/module_scope_var_to_entry_point_param.cc
index 8335eac..4fa5c4e 100644
--- a/src/tint/lang/msl/writer/ast_raise/module_scope_var_to_entry_point_param.cc
+++ b/src/tint/lang/msl/writer/ast_raise/module_scope_var_to_entry_point_param.cc
@@ -246,7 +246,7 @@
case core::AddressSpace::kWorkgroup:
break;
case core::AddressSpace::kPushConstant: {
- ctx.dst->Diagnostics().add_error(
+ ctx.dst->Diagnostics().AddError(
diag::System::Transform,
"unhandled module-scope address space (" + tint::ToString(sc) + ")");
break;
diff --git a/src/tint/lang/msl/writer/ast_raise/pixel_local.cc b/src/tint/lang/msl/writer/ast_raise/pixel_local.cc
index 1d6fb0a..2f2a216 100644
--- a/src/tint/lang/msl/writer/ast_raise/pixel_local.cc
+++ b/src/tint/lang/msl/writer/ast_raise/pixel_local.cc
@@ -257,9 +257,9 @@
uint32_t AttachmentIndex(uint32_t field_index) {
auto idx = cfg.attachments.Get(field_index);
if (TINT_UNLIKELY(!idx)) {
- b.Diagnostics().add_error(diag::System::Transform,
- "PixelLocal::Config::attachments missing entry for field " +
- std::to_string(field_index));
+ b.Diagnostics().AddError(diag::System::Transform,
+ "PixelLocal::Config::attachments missing entry for field " +
+ std::to_string(field_index));
return 0;
}
return *idx;
@@ -276,8 +276,8 @@
auto* cfg = inputs.Get<Config>();
if (!cfg) {
ProgramBuilder b;
- b.Diagnostics().add_error(diag::System::Transform,
- "missing transform data for " + std::string(TypeInfo().name));
+ b.Diagnostics().AddError(diag::System::Transform,
+ "missing transform data for " + std::string(TypeInfo().name));
return resolver::Resolve(b);
}
diff --git a/src/tint/lang/msl/writer/common/option_helpers.cc b/src/tint/lang/msl/writer/common/option_helpers.cc
index b655301..433f256 100644
--- a/src/tint/lang/msl/writer/common/option_helpers.cc
+++ b/src/tint/lang/msl/writer/common/option_helpers.cc
@@ -57,7 +57,7 @@
std::stringstream str;
str << "found duplicate WGSL binding point: " << src;
- diagnostics.add_error(diag::System::Writer, str.str());
+ diagnostics.AddError(diag::System::Writer, str.str());
return true;
}
}
@@ -71,7 +71,7 @@
if (*binding != dst) {
std::stringstream str;
str << "found duplicate MSL binding point: [binding: " << src.binding << "]";
- diagnostics.add_error(diag::System::Writer, str.str());
+ diagnostics.AddError(diag::System::Writer, str.str());
return true;
}
}
@@ -97,27 +97,27 @@
// Storage and uniform are both [[buffer()]]
if (!valid(seen_msl_buffer_bindings, options.bindings.uniform)) {
- diagnostics.add_note(diag::System::Writer, "when processing uniform", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing uniform", {});
return Failure{std::move(diagnostics)};
}
if (!valid(seen_msl_buffer_bindings, options.bindings.storage)) {
- diagnostics.add_note(diag::System::Writer, "when processing storage", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing storage", {});
return Failure{std::move(diagnostics)};
}
// Sampler is [[sampler()]]
if (!valid(seen_msl_sampler_bindings, options.bindings.sampler)) {
- diagnostics.add_note(diag::System::Writer, "when processing sampler", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing sampler", {});
return Failure{std::move(diagnostics)};
}
// Texture and storage texture are [[texture()]]
if (!valid(seen_msl_texture_bindings, options.bindings.texture)) {
- diagnostics.add_note(diag::System::Writer, "when processing texture", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing texture", {});
return Failure{std::move(diagnostics)};
}
if (!valid(seen_msl_texture_bindings, options.bindings.storage_texture)) {
- diagnostics.add_note(diag::System::Writer, "when processing storage_texture", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing storage_texture", {});
return Failure{std::move(diagnostics)};
}
@@ -129,22 +129,22 @@
// Validate with the actual source regardless of what the remapper will do
if (wgsl_seen(src_binding, plane0)) {
- diagnostics.add_note(diag::System::Writer, "when processing external_texture", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing external_texture", {});
return Failure{std::move(diagnostics)};
}
// Plane0 & Plane1 are [[texture()]]
if (msl_seen(seen_msl_texture_bindings, plane0, src_binding)) {
- diagnostics.add_note(diag::System::Writer, "when processing external_texture", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing external_texture", {});
return Failure{std::move(diagnostics)};
}
if (msl_seen(seen_msl_texture_bindings, plane1, src_binding)) {
- diagnostics.add_note(diag::System::Writer, "when processing external_texture", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing external_texture", {});
return Failure{std::move(diagnostics)};
}
// Metadata is [[buffer()]]
if (msl_seen(seen_msl_buffer_bindings, metadata, src_binding)) {
- diagnostics.add_note(diag::System::Writer, "when processing external_texture", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing external_texture", {});
return Failure{std::move(diagnostics)};
}
}
diff --git a/src/tint/lang/msl/writer/printer/helper_test.h b/src/tint/lang/msl/writer/printer/helper_test.h
index 410153b..2af6bb2 100644
--- a/src/tint/lang/msl/writer/printer/helper_test.h
+++ b/src/tint/lang/msl/writer/printer/helper_test.h
@@ -81,13 +81,13 @@
/// @returns true if generation and validation succeeded
bool Generate() {
if (auto raised = Raise(mod, {}); raised != Success) {
- err_ = raised.Failure().reason.str();
+ err_ = raised.Failure().reason.Str();
return false;
}
auto result = Print(mod);
if (result != Success) {
- err_ = result.Failure().reason.str();
+ err_ = result.Failure().reason.Str();
return false;
}
output_ = result.Get();
diff --git a/src/tint/lang/msl/writer/writer_bench.cc b/src/tint/lang/msl/writer/writer_bench.cc
index d597dbd..455b501 100644
--- a/src/tint/lang/msl/writer/writer_bench.cc
+++ b/src/tint/lang/msl/writer/writer_bench.cc
@@ -39,7 +39,7 @@
void GenerateMSL(benchmark::State& state, std::string input_name) {
auto res = bench::LoadProgram(input_name);
if (res != Success) {
- state.SkipWithError(res.Failure().reason.str());
+ state.SkipWithError(res.Failure().reason.Str());
return;
}
auto& program = res->program;
@@ -67,7 +67,7 @@
for (auto _ : state) {
auto gen_res = Generate(program, gen_options);
if (gen_res != Success) {
- state.SkipWithError(gen_res.Failure().reason.str());
+ state.SkipWithError(gen_res.Failure().reason.Str());
}
}
}
diff --git a/src/tint/lang/spirv/reader/ast_lower/atomics.cc b/src/tint/lang/spirv/reader/ast_lower/atomics.cc
index fa1f371..06e9d43 100644
--- a/src/tint/lang/spirv/reader/ast_lower/atomics.cc
+++ b/src/tint/lang/spirv/reader/ast_lower/atomics.cc
@@ -224,7 +224,7 @@
}
auto count = arr->ConstantCount();
if (!count) {
- ctx.dst->Diagnostics().add_error(
+ ctx.dst->Diagnostics().AddError(
diag::System::Transform,
"the Atomics transform does not currently support array counts that "
"use override values");
diff --git a/src/tint/lang/spirv/reader/ast_parser/barrier_test.cc b/src/tint/lang/spirv/reader/ast_parser/barrier_test.cc
index ad5c82f..d106222 100644
--- a/src/tint/lang/spirv/reader/ast_parser/barrier_test.cc
+++ b/src/tint/lang/spirv/reader/ast_parser/barrier_test.cc
@@ -51,7 +51,7 @@
auto p = std::make_unique<ASTParser>(test::Assemble(preamble + spirv));
if (!p->BuildAndParseInternalModule()) {
ProgramBuilder builder;
- builder.Diagnostics().add_error(diag::System::Reader, p->error());
+ builder.Diagnostics().AddError(diag::System::Reader, p->error());
return Program(std::move(builder));
}
return p->Program();
@@ -227,7 +227,7 @@
OpFunctionEnd
)");
EXPECT_FALSE(program.IsValid());
- EXPECT_THAT(program.Diagnostics().str(),
+ EXPECT_THAT(program.Diagnostics().Str(),
HasSubstr("unsupported control barrier execution scope"));
}
@@ -245,7 +245,7 @@
OpFunctionEnd
)");
EXPECT_FALSE(program.IsValid());
- EXPECT_THAT(program.Diagnostics().str(),
+ EXPECT_THAT(program.Diagnostics().Str(),
HasSubstr("control barrier semantics requires acquire and release"));
}
@@ -263,7 +263,7 @@
OpFunctionEnd
)");
EXPECT_FALSE(program.IsValid());
- EXPECT_THAT(program.Diagnostics().str(), HasSubstr("unsupported control barrier semantics"));
+ EXPECT_THAT(program.Diagnostics().Str(), HasSubstr("unsupported control barrier semantics"));
}
TEST_F(SpirvASTParserTest, ErrWorkgroupBarrierInvalidMemory) {
@@ -281,7 +281,7 @@
OpFunctionEnd
)");
EXPECT_FALSE(program.IsValid());
- EXPECT_THAT(program.Diagnostics().str(),
+ EXPECT_THAT(program.Diagnostics().Str(),
HasSubstr("workgroupBarrier requires workgroup memory scope"));
}
@@ -300,7 +300,7 @@
OpFunctionEnd
)");
EXPECT_FALSE(program.IsValid());
- EXPECT_THAT(program.Diagnostics().str(),
+ EXPECT_THAT(program.Diagnostics().Str(),
HasSubstr("storageBarrier requires workgroup memory scope"));
}
@@ -319,7 +319,7 @@
OpFunctionEnd
)");
EXPECT_FALSE(program.IsValid());
- EXPECT_THAT(program.Diagnostics().str(),
+ EXPECT_THAT(program.Diagnostics().Str(),
HasSubstr("textureBarrier requires workgroup memory scope"));
}
diff --git a/src/tint/lang/spirv/reader/ast_parser/helper_test.cc b/src/tint/lang/spirv/reader/ast_parser/helper_test.cc
index a417c51..5091bbe 100644
--- a/src/tint/lang/spirv/reader/ast_parser/helper_test.cc
+++ b/src/tint/lang/spirv/reader/ast_parser/helper_test.cc
@@ -53,7 +53,7 @@
writer.Generate();
if (!writer.Diagnostics().empty()) {
- return "WGSL writer error: " + writer.Diagnostics().str();
+ return "WGSL writer error: " + writer.Diagnostics().Str();
}
return writer.Result();
}
@@ -64,7 +64,7 @@
writer.EmitStatement(stmt);
}
if (!writer.Diagnostics().empty()) {
- return "WGSL writer error: " + writer.Diagnostics().str();
+ return "WGSL writer error: " + writer.Diagnostics().Str();
}
return writer.Result();
}
@@ -77,14 +77,14 @@
StringStream out;
writer.EmitExpression(out, expr);
if (!writer.Diagnostics().empty()) {
- return "WGSL writer error: " + writer.Diagnostics().str();
+ return "WGSL writer error: " + writer.Diagnostics().Str();
}
return out.str();
},
[&](const ast::Statement* stmt) {
writer.EmitStatement(stmt);
if (!writer.Diagnostics().empty()) {
- return "WGSL writer error: " + writer.Diagnostics().str();
+ return "WGSL writer error: " + writer.Diagnostics().Str();
}
return writer.Result();
},
diff --git a/src/tint/lang/spirv/reader/ast_parser/parse.cc b/src/tint/lang/spirv/reader/ast_parser/parse.cc
index c1b6af7..988fc08 100644
--- a/src/tint/lang/spirv/reader/ast_parser/parse.cc
+++ b/src/tint/lang/spirv/reader/ast_parser/parse.cc
@@ -83,7 +83,7 @@
ProgramBuilder& builder = parser.builder();
if (!parsed) {
// TODO(bclayton): Migrate ASTParser to using diagnostics.
- builder.Diagnostics().add_error(diag::System::Reader, parser.error());
+ builder.Diagnostics().AddError(diag::System::Reader, parser.error());
return Program(std::move(builder));
}
diff --git a/src/tint/lang/spirv/reader/ast_parser/parse.h b/src/tint/lang/spirv/reader/ast_parser/parse.h
index feb66e3..6c6e845 100644
--- a/src/tint/lang/spirv/reader/ast_parser/parse.h
+++ b/src/tint/lang/spirv/reader/ast_parser/parse.h
@@ -36,7 +36,7 @@
namespace tint::spirv::reader::ast_parser {
/// Parses the SPIR-V source data, returning the parsed program.
-/// If the source data fails to parse then the returned `program.Diagnostics.contains_errors()` will
+/// If the source data fails to parse then the returned `program.Diagnostics.ContainsErrors()` will
/// be true, and the `program.Diagnostics()` will describe the error.
/// @param input the source data
/// @param options the parser options
diff --git a/src/tint/lang/spirv/reader/ast_parser/parser_test.cc b/src/tint/lang/spirv/reader/ast_parser/parser_test.cc
index 5805440..a0fc6b1 100644
--- a/src/tint/lang/spirv/reader/ast_parser/parser_test.cc
+++ b/src/tint/lang/spirv/reader/ast_parser/parser_test.cc
@@ -39,7 +39,7 @@
TEST_F(ParserTest, DataEmpty) {
std::vector<uint32_t> data;
auto program = Parse(data, {});
- auto errs = program.Diagnostics().str();
+ auto errs = program.Diagnostics().Str();
ASSERT_FALSE(program.IsValid()) << errs;
EXPECT_EQ(errs, "error: line:0: Invalid SPIR-V magic number.");
}
@@ -76,7 +76,7 @@
Options options;
options.allow_non_uniform_derivatives = false;
auto program = Parse(spv, options);
- auto errs = program.Diagnostics().str();
+ auto errs = program.Diagnostics().Str();
EXPECT_FALSE(program.IsValid()) << errs;
EXPECT_THAT(errs, ::testing::HasSubstr("'dpdx' must only be called from uniform control flow"));
}
@@ -86,9 +86,9 @@
Options options;
options.allow_non_uniform_derivatives = true;
auto program = Parse(spv, options);
- auto errs = program.Diagnostics().str();
+ auto errs = program.Diagnostics().Str();
EXPECT_TRUE(program.IsValid()) << errs;
- EXPECT_EQ(program.Diagnostics().count(), 0u) << errs;
+ EXPECT_EQ(program.Diagnostics().Count(), 0u) << errs;
}
TEST_F(ParserTest, WorkgroupIdGuardingBarrier) {
@@ -123,9 +123,9 @@
OpFunctionEnd
)");
auto program = Parse(spv, {});
- auto errs = program.Diagnostics().str();
+ auto errs = program.Diagnostics().Str();
EXPECT_TRUE(program.IsValid()) << errs;
- EXPECT_EQ(program.Diagnostics().count(), 0u) << errs;
+ EXPECT_EQ(program.Diagnostics().Count(), 0u) << errs;
}
// TODO(dneto): uint32 vec, valid SPIR-V
diff --git a/src/tint/lang/spirv/reader/parser/helper_test.h b/src/tint/lang/spirv/reader/parser/helper_test.h
index c7fc02a..6842aee 100644
--- a/src/tint/lang/spirv/reader/parser/helper_test.h
+++ b/src/tint/lang/spirv/reader/parser/helper_test.h
@@ -47,7 +47,7 @@
#define EXPECT_IR(asm, ir) \
do { \
auto result = Run(asm); \
- ASSERT_EQ(result, Success) << result.Failure().reason.str(); \
+ ASSERT_EQ(result, Success) << result.Failure().reason.Str(); \
auto got = "\n" + result.Get(); \
ASSERT_THAT(got, testing::HasSubstr(ir)) << got; \
} while (false)
diff --git a/src/tint/lang/spirv/reader/reader.h b/src/tint/lang/spirv/reader/reader.h
index 9bcd99e..e67f6a7 100644
--- a/src/tint/lang/spirv/reader/reader.h
+++ b/src/tint/lang/spirv/reader/reader.h
@@ -49,7 +49,7 @@
/// Reads the SPIR-V source data, returning the parsed program.
/// If the source data fails to parse then the returned
-/// `program.Diagnostics.contains_errors()` will be true, and the
+/// `program.Diagnostics.ContainsErrors()` will be true, and the
/// `program.Diagnostics()` will describe the error.
/// @param input the source data
/// @param options the parser options
diff --git a/src/tint/lang/spirv/reader/reader_test.cc b/src/tint/lang/spirv/reader/reader_test.cc
index 5313aaf..40c07da 100644
--- a/src/tint/lang/spirv/reader/reader_test.cc
+++ b/src/tint/lang/spirv/reader/reader_test.cc
@@ -83,7 +83,7 @@
OpFunctionEnd
)");
ASSERT_NE(got, Success);
- EXPECT_EQ(got.Failure().reason.str(),
+ EXPECT_EQ(got.Failure().reason.Str(),
"error: SPIR-V extension 'SPV_KHR_variable_pointers' is not supported");
}
diff --git a/src/tint/lang/spirv/validate/validate_test.cc b/src/tint/lang/spirv/validate/validate_test.cc
index 270f065..70021b4 100644
--- a/src/tint/lang/spirv/validate/validate_test.cc
+++ b/src/tint/lang/spirv/validate/validate_test.cc
@@ -70,7 +70,7 @@
};
auto res = Validate(spirv, SPV_ENV_VULKAN_1_3);
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(spirv error: SPIR-V failed validation.
+ EXPECT_EQ(res.Failure().reason.Str(), R"(spirv error: SPIR-V failed validation.
Disassembly:
; SPIR-V
diff --git a/src/tint/lang/spirv/writer/ast_printer/ast_printer_test.cc b/src/tint/lang/spirv/writer/ast_printer/ast_printer_test.cc
index bf096b9..ad5f484 100644
--- a/src/tint/lang/spirv/writer/ast_printer/ast_printer_test.cc
+++ b/src/tint/lang/spirv/writer/ast_printer/ast_printer_test.cc
@@ -34,13 +34,13 @@
using SpirvASTPrinterTest = TestHelper;
TEST_F(SpirvASTPrinterTest, InvalidProgram) {
- Diagnostics().add_error(diag::System::Writer, "make the program invalid");
+ Diagnostics().AddError(diag::System::Writer, "make the program invalid");
ASSERT_FALSE(IsValid());
auto program = resolver::Resolve(*this);
ASSERT_FALSE(program.IsValid());
auto result = Generate(program, Options{});
EXPECT_NE(result, Success);
- EXPECT_EQ(result.Failure().reason.str(), "error: make the program invalid");
+ EXPECT_EQ(result.Failure().reason.Str(), "error: make the program invalid");
}
TEST_F(SpirvASTPrinterTest, UnsupportedExtension) {
@@ -50,7 +50,7 @@
auto result = Generate(program, Options{});
EXPECT_NE(result, Success);
EXPECT_EQ(
- result.Failure().reason.str(),
+ result.Failure().reason.Str(),
R"(12:34 error: SPIR-V backend does not support extension 'chromium_internal_relaxed_uniform_layout')");
}
diff --git a/src/tint/lang/spirv/writer/ast_printer/builder.h b/src/tint/lang/spirv/writer/ast_printer/builder.h
index 21df95e..bd74c08 100644
--- a/src/tint/lang/spirv/writer/ast_printer/builder.h
+++ b/src/tint/lang/spirv/writer/ast_printer/builder.h
@@ -111,7 +111,7 @@
const diag::List& Diagnostics() const { return builder_.Diagnostics(); }
/// @returns true if the builder encountered an error
- bool has_error() const { return Diagnostics().contains_errors(); }
+ bool has_error() const { return Diagnostics().ContainsErrors(); }
/// @returns the module that this builder has produced
writer::Module& Module() { return module_; }
diff --git a/src/tint/lang/spirv/writer/common/helper_test.h b/src/tint/lang/spirv/writer/common/helper_test.h
index 1c08ab9..553b173 100644
--- a/src/tint/lang/spirv/writer/common/helper_test.h
+++ b/src/tint/lang/spirv/writer/common/helper_test.h
@@ -117,13 +117,13 @@
bool Generate(Options options = {}, bool zero_init_workgroup_memory = false) {
auto raised = Raise(mod, options);
if (raised != Success) {
- err_ = raised.Failure().reason.str();
+ err_ = raised.Failure().reason.Str();
return false;
}
auto spirv = PrintModule(mod, zero_init_workgroup_memory);
if (spirv != Success) {
- err_ = spirv.Failure().reason.str();
+ err_ = spirv.Failure().reason.Str();
return false;
}
diff --git a/src/tint/lang/spirv/writer/common/option_helper.cc b/src/tint/lang/spirv/writer/common/option_helper.cc
index c1a9d10..93873c3 100644
--- a/src/tint/lang/spirv/writer/common/option_helper.cc
+++ b/src/tint/lang/spirv/writer/common/option_helper.cc
@@ -51,7 +51,7 @@
std::stringstream str;
str << "found duplicate WGSL binding point: " << src;
- diagnostics.add_error(diag::System::Writer, str.str());
+ diagnostics.AddError(diag::System::Writer, str.str());
return true;
}
}
@@ -66,7 +66,7 @@
std::stringstream str;
str << "found duplicate SPIR-V binding point: [group: " << src.group
<< ", binding: " << src.binding << "]";
- diagnostics.add_error(diag::System::Writer, str.str());
+ diagnostics.AddError(diag::System::Writer, str.str());
return true;
}
}
@@ -91,23 +91,23 @@
};
if (!valid(options.bindings.uniform)) {
- diagnostics.add_note(diag::System::Writer, "when processing uniform", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing uniform", {});
return Failure{std::move(diagnostics)};
}
if (!valid(options.bindings.storage)) {
- diagnostics.add_note(diag::System::Writer, "when processing storage", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing storage", {});
return Failure{std::move(diagnostics)};
}
if (!valid(options.bindings.texture)) {
- diagnostics.add_note(diag::System::Writer, "when processing texture", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing texture", {});
return Failure{std::move(diagnostics)};
}
if (!valid(options.bindings.storage_texture)) {
- diagnostics.add_note(diag::System::Writer, "when processing storage_texture", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing storage_texture", {});
return Failure{std::move(diagnostics)};
}
if (!valid(options.bindings.sampler)) {
- diagnostics.add_note(diag::System::Writer, "when processing sampler", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing sampler", {});
return Failure{std::move(diagnostics)};
}
@@ -119,20 +119,20 @@
// Validate with the actual source regardless of what the remapper will do
if (wgsl_seen(src_binding, plane0)) {
- diagnostics.add_note(diag::System::Writer, "when processing external_texture", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing external_texture", {});
return Failure{std::move(diagnostics)};
}
if (spirv_seen(plane0, src_binding)) {
- diagnostics.add_note(diag::System::Writer, "when processing external_texture", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing external_texture", {});
return Failure{std::move(diagnostics)};
}
if (spirv_seen(plane1, src_binding)) {
- diagnostics.add_note(diag::System::Writer, "when processing external_texture", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing external_texture", {});
return Failure{std::move(diagnostics)};
}
if (spirv_seen(metadata, src_binding)) {
- diagnostics.add_note(diag::System::Writer, "when processing external_texture", {});
+ diagnostics.AddNote(diag::System::Writer, "when processing external_texture", {});
return Failure{std::move(diagnostics)};
}
}
diff --git a/src/tint/lang/spirv/writer/writer_bench.cc b/src/tint/lang/spirv/writer/writer_bench.cc
index 84beb72..fca650a 100644
--- a/src/tint/lang/spirv/writer/writer_bench.cc
+++ b/src/tint/lang/spirv/writer/writer_bench.cc
@@ -40,13 +40,13 @@
void GenerateSPIRV(benchmark::State& state, std::string input_name) {
auto res = bench::LoadProgram(input_name);
if (res != Success) {
- state.SkipWithError(res.Failure().reason.str());
+ state.SkipWithError(res.Failure().reason.Str());
return;
}
for (auto _ : state) {
auto gen_res = Generate(res->program, {});
if (gen_res != Success) {
- state.SkipWithError(gen_res.Failure().reason.str());
+ state.SkipWithError(gen_res.Failure().reason.Str());
}
}
}
@@ -55,20 +55,20 @@
#if TINT_BUILD_WGSL_READER
auto res = bench::LoadProgram(input_name);
if (res != Success) {
- state.SkipWithError(res.Failure().reason.str());
+ state.SkipWithError(res.Failure().reason.Str());
return;
}
for (auto _ : state) {
// Convert the AST program to an IR module.
auto ir = tint::wgsl::reader::ProgramToLoweredIR(res->program);
if (ir != Success) {
- state.SkipWithError(ir.Failure().reason.str());
+ state.SkipWithError(ir.Failure().reason.Str());
return;
}
auto gen_res = Generate(ir.Get(), {});
if (gen_res != Success) {
- state.SkipWithError(gen_res.Failure().reason.str());
+ state.SkipWithError(gen_res.Failure().reason.Str());
}
}
#else
diff --git a/src/tint/lang/wgsl/ast/builder.cc b/src/tint/lang/wgsl/ast/builder.cc
index 9482ecc..f1640f1 100644
--- a/src/tint/lang/wgsl/ast/builder.cc
+++ b/src/tint/lang/wgsl/ast/builder.cc
@@ -66,7 +66,7 @@
}
bool Builder::IsValid() const {
- return !diagnostics_.contains_errors();
+ return !diagnostics_.ContainsErrors();
}
void Builder::MarkAsMoved() {
diff --git a/src/tint/lang/wgsl/ast/transform/array_length_from_uniform.cc b/src/tint/lang/wgsl/ast/transform/array_length_from_uniform.cc
index 27b354c..fa6bc9e 100644
--- a/src/tint/lang/wgsl/ast/transform/array_length_from_uniform.cc
+++ b/src/tint/lang/wgsl/ast/transform/array_length_from_uniform.cc
@@ -82,7 +82,7 @@
ApplyResult Run() {
auto* cfg = inputs.Get<Config>();
if (cfg == nullptr) {
- b.Diagnostics().add_error(
+ b.Diagnostics().AddError(
diag::System::Transform,
"missing transform data for " +
std::string(tint::TypeInfo::Of<ArrayLengthFromUniform>().name));
diff --git a/src/tint/lang/wgsl/ast/transform/binding_remapper.cc b/src/tint/lang/wgsl/ast/transform/binding_remapper.cc
index 842e9ce..c3c8cbe 100644
--- a/src/tint/lang/wgsl/ast/transform/binding_remapper.cc
+++ b/src/tint/lang/wgsl/ast/transform/binding_remapper.cc
@@ -66,8 +66,8 @@
auto* remappings = inputs.Get<Remappings>();
if (!remappings) {
- b.Diagnostics().add_error(diag::System::Transform,
- "missing transform data for " + std::string(TypeInfo().name));
+ b.Diagnostics().AddError(diag::System::Transform,
+ "missing transform data for " + std::string(TypeInfo().name));
return resolver::Resolve(b);
}
@@ -112,15 +112,15 @@
if (ac_it != remappings->access_controls.end()) {
core::Access access = ac_it->second;
if (access == core::Access::kUndefined) {
- b.Diagnostics().add_error(diag::System::Transform,
- "invalid access mode (" +
- std::to_string(static_cast<uint32_t>(access)) +
- ")");
+ b.Diagnostics().AddError(diag::System::Transform,
+ "invalid access mode (" +
+ std::to_string(static_cast<uint32_t>(access)) +
+ ")");
return resolver::Resolve(b);
}
auto* sem = src.Sem().Get(var);
if (sem->AddressSpace() != core::AddressSpace::kStorage) {
- b.Diagnostics().add_error(
+ b.Diagnostics().AddError(
diag::System::Transform,
"cannot apply access control to variable with address space " +
std::string(tint::ToString(sem->AddressSpace())));
diff --git a/src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io.cc b/src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io.cc
index dcea861..842e41b 100644
--- a/src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io.cc
+++ b/src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io.cc
@@ -950,8 +950,8 @@
auto* cfg = inputs.Get<Config>();
if (cfg == nullptr) {
- b.Diagnostics().add_error(diag::System::Transform,
- "missing transform data for " + std::string(TypeInfo().name));
+ b.Diagnostics().AddError(diag::System::Transform,
+ "missing transform data for " + std::string(TypeInfo().name));
return resolver::Resolve(b);
}
diff --git a/src/tint/lang/wgsl/ast/transform/helper_test.h b/src/tint/lang/wgsl/ast/transform/helper_test.h
index 495f822..15a1ef5 100644
--- a/src/tint/lang/wgsl/ast/transform/helper_test.h
+++ b/src/tint/lang/wgsl/ast/transform/helper_test.h
@@ -46,13 +46,13 @@
/// program is not valid.
inline std::string str(const Program& program) {
if (!program.IsValid()) {
- return program.Diagnostics().str();
+ return program.Diagnostics().Str();
}
wgsl::writer::Options options;
auto result = wgsl::writer::Generate(program, options);
if (result != Success) {
- return result.Failure().reason.str();
+ return result.Failure().reason.Str();
}
auto res = result->wgsl;
diff --git a/src/tint/lang/wgsl/ast/transform/multiplanar_external_texture.cc b/src/tint/lang/wgsl/ast/transform/multiplanar_external_texture.cc
index d32b3b7..815a3ed 100644
--- a/src/tint/lang/wgsl/ast/transform/multiplanar_external_texture.cc
+++ b/src/tint/lang/wgsl/ast/transform/multiplanar_external_texture.cc
@@ -135,7 +135,7 @@
BindingsMap::const_iterator it = new_binding_points->bindings_map.find(bp);
if (it == new_binding_points->bindings_map.end()) {
- b.Diagnostics().add_error(
+ b.Diagnostics().AddError(
diag::System::Transform,
"missing new binding points for texture_external at binding {" +
std::to_string(bp.group) + "," + std::to_string(bp.binding) + "}");
@@ -552,8 +552,8 @@
ProgramBuilder b;
program::CloneContext ctx{&b, &src, /* auto_clone_symbols */ true};
if (!new_binding_points) {
- b.Diagnostics().add_error(diag::System::Transform, "missing new binding point data for " +
- std::string(TypeInfo().name));
+ b.Diagnostics().AddError(diag::System::Transform, "missing new binding point data for " +
+ std::string(TypeInfo().name));
return resolver::Resolve(b);
}
diff --git a/src/tint/lang/wgsl/ast/transform/robustness.cc b/src/tint/lang/wgsl/ast/transform/robustness.cc
index 676a544..c3f9c57 100644
--- a/src/tint/lang/wgsl/ast/transform/robustness.cc
+++ b/src/tint/lang/wgsl/ast/transform/robustness.cc
@@ -272,8 +272,8 @@
}
// Note: Don't be tempted to use the array override variable as an expression here,
// the name might be shadowed!
- b.Diagnostics().add_error(diag::System::Transform,
- core::type::Array::kErrExpectedConstantCount);
+ b.Diagnostics().AddError(diag::System::Transform,
+ core::type::Array::kErrExpectedConstantCount);
return nullptr;
}, //
TINT_ICE_ON_NO_MATCH);
diff --git a/src/tint/lang/wgsl/ast/transform/single_entry_point.cc b/src/tint/lang/wgsl/ast/transform/single_entry_point.cc
index 53b00d0..78843cc 100644
--- a/src/tint/lang/wgsl/ast/transform/single_entry_point.cc
+++ b/src/tint/lang/wgsl/ast/transform/single_entry_point.cc
@@ -55,8 +55,8 @@
auto* cfg = inputs.Get<Config>();
if (cfg == nullptr) {
- b.Diagnostics().add_error(diag::System::Transform,
- "missing transform data for " + std::string(TypeInfo().name));
+ b.Diagnostics().AddError(diag::System::Transform,
+ "missing transform data for " + std::string(TypeInfo().name));
return resolver::Resolve(b);
}
@@ -72,8 +72,8 @@
}
}
if (entry_point == nullptr) {
- b.Diagnostics().add_error(diag::System::Transform,
- "entry point '" + cfg->entry_point_name + "' not found");
+ b.Diagnostics().AddError(diag::System::Transform,
+ "entry point '" + cfg->entry_point_name + "' not found");
return resolver::Resolve(b);
}
diff --git a/src/tint/lang/wgsl/ast/transform/substitute_override.cc b/src/tint/lang/wgsl/ast/transform/substitute_override.cc
index a36bc65..74d8b7b 100644
--- a/src/tint/lang/wgsl/ast/transform/substitute_override.cc
+++ b/src/tint/lang/wgsl/ast/transform/substitute_override.cc
@@ -71,7 +71,7 @@
const auto* data = config.Get<Config>();
if (!data) {
- b.Diagnostics().add_error(diag::System::Transform, "Missing override substitution data");
+ b.Diagnostics().AddError(diag::System::Transform, "Missing override substitution data");
return resolver::Resolve(b);
}
@@ -90,7 +90,7 @@
auto iter = data->map.find(sem->Attributes().override_id.value());
if (iter == data->map.end()) {
if (!w->initializer) {
- b.Diagnostics().add_error(
+ b.Diagnostics().AddError(
diag::System::Transform,
"Initializer not provided for override, and override not overridden.");
return nullptr;
@@ -108,8 +108,8 @@
[&](const core::type::F16*) { return b.Expr(f16(value)); });
if (!ctor) {
- b.Diagnostics().add_error(diag::System::Transform,
- "Failed to create override-expression");
+ b.Diagnostics().AddError(diag::System::Transform,
+ "Failed to create override-expression");
return nullptr;
}
diff --git a/src/tint/lang/wgsl/ast/transform/vertex_pulling.cc b/src/tint/lang/wgsl/ast/transform/vertex_pulling.cc
index 81ec237..623bab0 100644
--- a/src/tint/lang/wgsl/ast/transform/vertex_pulling.cc
+++ b/src/tint/lang/wgsl/ast/transform/vertex_pulling.cc
@@ -261,7 +261,7 @@
for (auto* fn : src.AST().Functions()) {
if (fn->PipelineStage() == PipelineStage::kVertex) {
if (func != nullptr) {
- b.Diagnostics().add_error(
+ b.Diagnostics().AddError(
diag::System::Transform,
"VertexPulling found more than one vertex entry point");
return resolver::Resolve(b);
@@ -270,8 +270,7 @@
}
}
if (func == nullptr) {
- b.Diagnostics().add_error(diag::System::Transform,
- "Vertex stage entry point not found");
+ b.Diagnostics().AddError(diag::System::Transform, "Vertex stage entry point not found");
return resolver::Resolve(b);
}
@@ -359,7 +358,7 @@
const VertexBufferLayoutDescriptor& buffer_layout = cfg.vertex_state[buffer_idx];
if ((buffer_layout.array_stride & 3) != 0) {
- b.Diagnostics().add_error(
+ b.Diagnostics().AddError(
diag::System::Transform,
"WebGPU requires that vertex stride must be a multiple of 4 bytes, "
"but VertexPulling array stride for buffer " +
@@ -404,7 +403,7 @@
<< std::to_string(attribute_desc.shader_location) << " has format "
<< attribute_desc.format << " but shader expects "
<< var.type->FriendlyName();
- b.Diagnostics().add_error(diag::System::Transform, err.str());
+ b.Diagnostics().AddError(diag::System::Transform, err.str());
return nullptr;
}
diff --git a/src/tint/lang/wgsl/ast/transform/zero_init_workgroup_memory.cc b/src/tint/lang/wgsl/ast/transform/zero_init_workgroup_memory.cc
index 235693e..e932b80 100644
--- a/src/tint/lang/wgsl/ast/transform/zero_init_workgroup_memory.cc
+++ b/src/tint/lang/wgsl/ast/transform/zero_init_workgroup_memory.cc
@@ -357,8 +357,8 @@
// `(idx % modulo) / division`
auto count = arr->ConstantCount();
if (!count) {
- ctx.dst->Diagnostics().add_error(diag::System::Transform,
- core::type::Array::kErrExpectedConstantCount);
+ ctx.dst->Diagnostics().AddError(diag::System::Transform,
+ core::type::Array::kErrExpectedConstantCount);
return Expression{}; // error
}
auto modulo = num_values * count.value();
diff --git a/src/tint/lang/wgsl/helpers/check_supported_extensions.cc b/src/tint/lang/wgsl/helpers/check_supported_extensions.cc
index 4ab0f84..bb35e15 100644
--- a/src/tint/lang/wgsl/helpers/check_supported_extensions.cc
+++ b/src/tint/lang/wgsl/helpers/check_supported_extensions.cc
@@ -48,10 +48,10 @@
for (auto* enable : module.Enables()) {
for (auto* ext : enable->extensions) {
if (!set.Contains(ext->name)) {
- diags.add_error(diag::System::Writer,
- std::string(writer_name) + " backend does not support extension '" +
- tint::ToString(ext->name) + "'",
- ext->source);
+ diags.AddError(diag::System::Writer,
+ std::string(writer_name) + " backend does not support extension '" +
+ tint::ToString(ext->name) + "'",
+ ext->source);
return false;
}
}
diff --git a/src/tint/lang/wgsl/helpers/check_supported_extensions_test.cc b/src/tint/lang/wgsl/helpers/check_supported_extensions_test.cc
index 415f32c..6d8252d 100644
--- a/src/tint/lang/wgsl/helpers/check_supported_extensions_test.cc
+++ b/src/tint/lang/wgsl/helpers/check_supported_extensions_test.cc
@@ -53,7 +53,7 @@
Vector{
wgsl::Extension::kChromiumExperimentalSubgroups,
}));
- EXPECT_EQ(Diagnostics().str(), "12:34 error: writer backend does not support extension 'f16'");
+ EXPECT_EQ(Diagnostics().Str(), "12:34 error: writer backend does not support extension 'f16'");
}
} // namespace
diff --git a/src/tint/lang/wgsl/inspector/inspector.cc b/src/tint/lang/wgsl/inspector/inspector.cc
index e6c2b44..a69fb67 100644
--- a/src/tint/lang/wgsl/inspector/inspector.cc
+++ b/src/tint/lang/wgsl/inspector/inspector.cc
@@ -569,12 +569,12 @@
const ast::Function* Inspector::FindEntryPointByName(const std::string& name) {
auto* func = program_.AST().Functions().Find(program_.Symbols().Get(name));
if (!func) {
- diagnostics_.add_error(diag::System::Inspector, name + " was not found!");
+ diagnostics_.AddError(diag::System::Inspector, name + " was not found!");
return nullptr;
}
if (!func->IsEntryPoint()) {
- diagnostics_.add_error(diag::System::Inspector, name + " is not an entry point!");
+ diagnostics_.AddError(diag::System::Inspector, name + " is not an entry point!");
return nullptr;
}
diff --git a/src/tint/lang/wgsl/inspector/inspector.h b/src/tint/lang/wgsl/inspector/inspector.h
index 6604832..af839df 100644
--- a/src/tint/lang/wgsl/inspector/inspector.h
+++ b/src/tint/lang/wgsl/inspector/inspector.h
@@ -62,9 +62,9 @@
~Inspector();
/// @returns error messages from the Inspector
- std::string error() { return diagnostics_.str(); }
+ std::string error() { return diagnostics_.Str(); }
/// @returns true if an error was encountered
- bool has_error() const { return diagnostics_.contains_errors(); }
+ bool has_error() const { return diagnostics_.ContainsErrors(); }
/// @returns vector of entry point information
std::vector<EntryPoint> GetEntryPoints();
diff --git a/src/tint/lang/wgsl/ir_roundtrip_test.cc b/src/tint/lang/wgsl/ir_roundtrip_test.cc
index 9b7b522..5cb3f99 100644
--- a/src/tint/lang/wgsl/ir_roundtrip_test.cc
+++ b/src/tint/lang/wgsl/ir_roundtrip_test.cc
@@ -76,7 +76,7 @@
result.ir_pre_raise = core::ir::Disassemble(ir_module.Get());
if (auto res = tint::wgsl::writer::Raise(ir_module.Get()); res != Success) {
- result.err = res.Failure().reason.str();
+ result.err = res.Failure().reason.Str();
return result;
}
@@ -86,7 +86,7 @@
program_options.allowed_features = AllowedFeatures::Everything();
auto output_program = wgsl::writer::IRToProgram(ir_module.Get(), program_options);
if (!output_program.IsValid()) {
- result.err = output_program.Diagnostics().str();
+ result.err = output_program.Diagnostics().Str();
result.ast = Program::printer(output_program);
return result;
}
diff --git a/src/tint/lang/wgsl/program/program.cc b/src/tint/lang/wgsl/program/program.cc
index 3f7735e..bcd8e93 100644
--- a/src/tint/lang/wgsl/program/program.cc
+++ b/src/tint/lang/wgsl/program/program.cc
@@ -74,14 +74,14 @@
ast_ = &builder.AST(); // ast::Module is actually a heap allocation.
sem_ = std::move(builder.Sem());
symbols_ = std::move(builder.Symbols());
- diagnostics_.add(std::move(builder.Diagnostics()));
+ diagnostics_.Add(std::move(builder.Diagnostics()));
builder.MarkAsMoved();
- if (!is_valid_ && !diagnostics_.contains_errors()) {
+ if (!is_valid_ && !diagnostics_.ContainsErrors()) {
// If the builder claims to be invalid, then we really should have an error
// message generated. If we find a situation where the program is not valid
// and there are no errors reported, add one here.
- diagnostics_.add_error(diag::System::Program, "invalid program generated");
+ diagnostics_.AddError(diag::System::Program, "invalid program generated");
}
}
diff --git a/src/tint/lang/wgsl/program/program_test.cc b/src/tint/lang/wgsl/program/program_test.cc
index c8f2656..1a59adb 100644
--- a/src/tint/lang/wgsl/program/program_test.cc
+++ b/src/tint/lang/wgsl/program/program_test.cc
@@ -93,18 +93,18 @@
}
TEST_F(ProgramTest, DiagnosticsMove) {
- Diagnostics().add_error(diag::System::Program, "an error message");
+ Diagnostics().AddError(diag::System::Program, "an error message");
Program program_a(std::move(*this));
EXPECT_FALSE(program_a.IsValid());
- EXPECT_EQ(program_a.Diagnostics().count(), 1u);
- EXPECT_EQ(program_a.Diagnostics().error_count(), 1u);
+ EXPECT_EQ(program_a.Diagnostics().Count(), 1u);
+ EXPECT_EQ(program_a.Diagnostics().NumErrors(), 1u);
EXPECT_EQ(program_a.Diagnostics().begin()->message, "an error message");
Program program_b(std::move(program_a));
EXPECT_FALSE(program_b.IsValid());
- EXPECT_EQ(program_b.Diagnostics().count(), 1u);
- EXPECT_EQ(program_b.Diagnostics().error_count(), 1u);
+ EXPECT_EQ(program_b.Diagnostics().Count(), 1u);
+ EXPECT_EQ(program_b.Diagnostics().NumErrors(), 1u);
EXPECT_EQ(program_b.Diagnostics().begin()->message, "an error message");
}
diff --git a/src/tint/lang/wgsl/reader/parser/error_msg_test.cc b/src/tint/lang/wgsl/reader/parser/error_msg_test.cc
index a0ff445..394a6f3 100644
--- a/src/tint/lang/wgsl/reader/parser/error_msg_test.cc
+++ b/src/tint/lang/wgsl/reader/parser/error_msg_test.cc
@@ -46,8 +46,8 @@
p->set_max_errors(5); \
EXPECT_EQ(false, p->Parse()); \
auto diagnostics = p->builder().Diagnostics(); \
- EXPECT_EQ(true, diagnostics.contains_errors()); \
- EXPECT_EQ(expected, diag::Formatter(formatter_style).format(diagnostics)); \
+ EXPECT_EQ(true, diagnostics.ContainsErrors()); \
+ EXPECT_EQ(expected, diag::Formatter(formatter_style).Format(diagnostics)); \
} while (false)
TEST_F(ParserImplErrorTest, AdditiveInvalidExpr) {
diff --git a/src/tint/lang/wgsl/reader/parser/error_resync_test.cc b/src/tint/lang/wgsl/reader/parser/error_resync_test.cc
index d818893..31a6dbc 100644
--- a/src/tint/lang/wgsl/reader/parser/error_resync_test.cc
+++ b/src/tint/lang/wgsl/reader/parser/error_resync_test.cc
@@ -43,8 +43,8 @@
auto p = parser(source); \
EXPECT_EQ(false, p->Parse()); \
auto diagnostics = p->builder().Diagnostics(); \
- EXPECT_EQ(true, diagnostics.contains_errors()); \
- EXPECT_EQ(expected, diag::Formatter(formatter_style).format(diagnostics)); \
+ EXPECT_EQ(true, diagnostics.ContainsErrors()); \
+ EXPECT_EQ(expected, diag::Formatter(formatter_style).Format(diagnostics)); \
} while (false)
TEST_F(ParserImplErrorResyncTest, BadFunctionDecls) {
diff --git a/src/tint/lang/wgsl/reader/parser/expression_test.cc b/src/tint/lang/wgsl/reader/parser/expression_test.cc
index 74d78df..16d0ba0 100644
--- a/src/tint/lang/wgsl/reader/parser/expression_test.cc
+++ b/src/tint/lang/wgsl/reader/parser/expression_test.cc
@@ -180,7 +180,7 @@
EXPECT_TRUE(e.errored);
EXPECT_EQ(e.value, nullptr);
EXPECT_TRUE(p->has_error());
- EXPECT_EQ(p->builder().Diagnostics().str(),
+ EXPECT_EQ(p->builder().Diagnostics().Str(),
R"(test.wgsl:1:3 error: mixing '&&' and '||' requires parenthesis
a && true || b
^^^^^^^^^^
@@ -194,7 +194,7 @@
EXPECT_TRUE(e.errored);
EXPECT_EQ(e.value, nullptr);
EXPECT_TRUE(p->has_error());
- EXPECT_EQ(p->builder().Diagnostics().str(),
+ EXPECT_EQ(p->builder().Diagnostics().Str(),
R"(test.wgsl:1:3 error: mixing '||' and '&&' requires parenthesis
a || true && b
^^^^^^^^^^
diff --git a/src/tint/lang/wgsl/reader/parser/parser.cc b/src/tint/lang/wgsl/reader/parser/parser.cc
index b00c274..3a05f2d 100644
--- a/src/tint/lang/wgsl/reader/parser/parser.cc
+++ b/src/tint/lang/wgsl/reader/parser/parser.cc
@@ -222,43 +222,43 @@
Parser::~Parser() = default;
-Parser::Failure::Errored Parser::add_error(const Source& source,
- std::string_view err,
- std::string_view use) {
+Parser::Failure::Errored Parser::AddError(const Source& source,
+ std::string_view err,
+ std::string_view use) {
if (silence_diags_ == 0) {
StringStream msg;
msg << err;
if (!use.empty()) {
msg << " for " << use;
}
- add_error(source, msg.str());
+ AddError(source, msg.str());
}
return Failure::kErrored;
}
-Parser::Failure::Errored Parser::add_error(const Token& t, std::string_view err) {
- add_error(t.source(), err);
+Parser::Failure::Errored Parser::AddError(const Token& t, std::string_view err) {
+ AddError(t.source(), err);
return Failure::kErrored;
}
-Parser::Failure::Errored Parser::add_error(const Source& source, std::string_view err) {
+Parser::Failure::Errored Parser::AddError(const Source& source, std::string_view err) {
if (silence_diags_ == 0) {
- builder_.Diagnostics().add_error(diag::System::Reader, err, source);
+ builder_.Diagnostics().AddError(diag::System::Reader, err, source);
}
return Failure::kErrored;
}
-void Parser::add_note(const Source& source, std::string_view err) {
+void Parser::AddNote(const Source& source, std::string_view err) {
if (silence_diags_ == 0) {
- builder_.Diagnostics().add_note(diag::System::Reader, err, source);
+ builder_.Diagnostics().AddNote(diag::System::Reader, err, source);
}
}
void Parser::deprecated(const Source& source, std::string_view msg) {
if (silence_diags_ == 0) {
- builder_.Diagnostics().add_warning(
- diag::System::Reader, "use of deprecated language feature: " + std::string(msg),
- source);
+ builder_.Diagnostics().AddWarning(diag::System::Reader,
+ "use of deprecated language feature: " + std::string(msg),
+ source);
}
}
@@ -349,13 +349,13 @@
}
if (!gd.matched && !gd.errored) {
- add_error(p, "unexpected token");
+ AddError(p, "unexpected token");
}
}
- if (builder_.Diagnostics().error_count() >= max_errors_) {
- add_error(Source{{}, p.source().file},
- "stopping after " + std::to_string(max_errors_) + " errors");
+ if (builder_.Diagnostics().NumErrors() >= max_errors_) {
+ AddError(Source{{}, p.source().file},
+ "stopping after " + std::to_string(max_errors_) + " errors");
break;
}
}
@@ -376,7 +376,7 @@
}
if (result.matched && have_parsed_decl) {
- return add_error(p, "directives must come before all global declarations");
+ return AddError(p, "directives must come before all global declarations");
}
return result;
}
@@ -423,7 +423,7 @@
if (peek_is(Token::Type::kParenLeft)) {
// A common error case is writing `enable(foo);` instead of `enable foo;`.
synchronized_ = false;
- return add_error(peek().source(), "enable directives don't take parenthesis");
+ return AddError(peek().source(), "enable directives don't take parenthesis");
}
Vector<const ast::Extension*, 4> extensions;
@@ -471,7 +471,7 @@
if (t.Is(Token::Type::kParenLeft)) {
// A common error case is writing `require(foo);` instead of `require foo;`.
synchronized_ = false;
- return add_error(t.source(), "requires directives don't take parenthesis");
+ return AddError(t.source(), "requires directives don't take parenthesis");
}
ast::Requires::LanguageFeatures features;
@@ -489,11 +489,11 @@
// Any identifier is a valid feature name, so we correctly handle new feature
// names getting added in the future, they just all get flagged as not
// supported.
- return add_error(t2.source(), "feature '" + t2.to_str() + "' is not supported");
+ return AddError(t2.source(), "feature '" + t2.to_str() + "' is not supported");
}
features.Add(feature);
} else {
- return add_error(t2.source(), "invalid feature name for requires");
+ return AddError(t2.source(), "invalid feature name for requires");
}
if (!match(Token::Type::kComma)) {
@@ -629,7 +629,7 @@
// We have attributes parsed, but nothing to consume them?
if (attrs.value.Length() > 0) {
- return add_error(next(), "expected declaration after attributes");
+ return AddError(next(), "expected declaration after attributes");
}
// We have a statement outside of a function?
@@ -639,7 +639,7 @@
// Attempt to jump to the next '}' - the function might have just been
// missing an opening line.
sync_to(Token::Type::kBraceRight, true);
- return add_error(t, "statement found outside of function body");
+ return AddError(t, "statement found outside of function body");
}
if (!stat.errored) {
// No match, no error - the parser might not have progressed.
@@ -676,7 +676,7 @@
return Failure::kErrored;
}
if (!expr.matched) {
- return add_error(peek(), "missing initializer for 'var' declaration");
+ return AddError(peek(), "missing initializer for 'var' declaration");
}
initializer = expr.value;
}
@@ -707,7 +707,7 @@
use = "'override' declaration";
is_overridable = true;
} else if (match(Token::Type::kLet, &source)) {
- return add_error(source, "module-scope 'let' is invalid, use 'const'");
+ return AddError(source, "module-scope 'let' is invalid, use 'const'");
} else {
return Failure::kNoMatch;
}
@@ -734,7 +734,7 @@
return Failure::kErrored;
}
if (!expr.matched) {
- return add_error(peek(), "missing initializer for " + std::string(use));
+ return AddError(peek(), "missing initializer for " + std::string(use));
}
initializer = std::move(expr.value);
}
@@ -804,7 +804,7 @@
return Failure::kErrored;
}
if (!type.matched) {
- return add_error(t.source(), "invalid type", use);
+ return AddError(t.source(), "invalid type", use);
}
return TypedIdentifier{type.value, ident.value};
@@ -877,7 +877,7 @@
return Failure::kErrored;
}
if (!type.matched) {
- return add_error(peek(), "invalid type alias");
+ return AddError(peek(), "invalid type alias");
}
return builder_.ty.alias(source(), name.value, type.value);
@@ -952,7 +952,7 @@
}
synchronized_ = false;
- return add_error(t.source(), err.str());
+ return AddError(t.source(), err.str());
}
Expect<ast::Type> Parser::expect_type(std::string_view use) {
@@ -961,7 +961,7 @@
return Failure::kErrored;
}
if (!type.matched) {
- return add_error(peek().source(), "invalid type", use);
+ return AddError(peek().source(), "invalid type", use);
}
return type.value;
}
@@ -1051,7 +1051,7 @@
return Failure::kErrored;
}
if (!condition.matched) {
- return add_error(peek(), "unable to parse condition expression");
+ return AddError(peek(), "unable to parse condition expression");
}
return create<ast::ConstAssert>(source(), condition.value);
@@ -1138,7 +1138,7 @@
if (type.errored) {
errored = true;
} else if (!type.matched) {
- return add_error(peek(), "unable to determine function return type");
+ return AddError(peek(), "unable to determine function return type");
} else {
return_type = type.value;
}
@@ -1230,7 +1230,7 @@
return Failure::kErrored;
}
if (!expr.matched) {
- return add_error(peek(), "unable to parse expression");
+ return AddError(peek(), "unable to parse expression");
}
return expr.value;
@@ -1468,7 +1468,7 @@
return Failure::kErrored;
}
if (!initializer.matched) {
- return add_error(peek(), "missing initializer for 'const' declaration");
+ return AddError(peek(), "missing initializer for 'const' declaration");
}
auto* const_ = builder_.Const(typed_ident->name->source, // source
@@ -1496,7 +1496,7 @@
return Failure::kErrored;
}
if (!initializer.matched) {
- return add_error(peek(), "missing initializer for 'let' declaration");
+ return AddError(peek(), "missing initializer for 'let' declaration");
}
auto* let = builder_.Let(typed_ident->name->source, // source
@@ -1524,7 +1524,7 @@
return Failure::kErrored;
}
if (!initializer_expr.matched) {
- return add_error(peek(), "missing initializer for 'var' declaration");
+ return AddError(peek(), "missing initializer for 'var' declaration");
}
initializer = initializer_expr.value;
@@ -1572,7 +1572,7 @@
return Failure::kErrored;
}
if (!condition.matched) {
- return add_error(peek(), "unable to parse condition expression");
+ return AddError(peek(), "unable to parse condition expression");
}
auto body = expect_compound_statement("if statement");
@@ -1642,7 +1642,7 @@
return Failure::kErrored;
}
if (!condition.matched) {
- return add_error(peek(), "unable to parse selector expression");
+ return AddError(peek(), "unable to parse selector expression");
}
auto body_attrs = attribute_list();
@@ -1735,7 +1735,7 @@
}
if (selectors.IsEmpty()) {
- return add_error(peek(), "expected case selector expression or `default`");
+ return AddError(peek(), "expected case selector expression or `default`");
}
return selectors;
@@ -1920,7 +1920,7 @@
return Failure::kErrored;
}
if (!condition.matched) {
- return add_error(peek(), "unable to parse while condition expression");
+ return AddError(peek(), "unable to parse while condition expression");
}
auto body = expect_compound_statement("while loop");
@@ -1993,7 +1993,7 @@
return Failure::kErrored;
}
if (!expr.matched) {
- return add_error(t1, "expected expression for `break-if`");
+ return AddError(t1, "expected expression for `break-if`");
}
if (!expect("`break-if` statement", Token::Type::kSemicolon)) {
return Failure::kErrored;
@@ -2146,7 +2146,7 @@
return Failure::kErrored;
}
if (!param.matched) {
- return add_error(peek(), "unable to parse expression inside []");
+ return AddError(peek(), "unable to parse expression inside []");
}
if (!expect("index accessor", Token::Type::kBracketRight)) {
@@ -2223,8 +2223,8 @@
return Failure::kErrored;
}
if (!rhs.matched) {
- return add_error(peek(), std::string("unable to parse right side of ") +
- std::string(t.to_name()) + " expression");
+ return AddError(peek(), std::string("unable to parse right side of ") +
+ std::string(t.to_name()) + " expression");
}
lhs = create<ast::BinaryExpression>(source(), *op, lhs, rhs.value);
@@ -2276,8 +2276,8 @@
return Failure::kErrored;
}
if (!rhs.matched) {
- return add_error(peek(), std::string("unable to parse right side of ") +
- std::string(t.to_name()) + " expression");
+ return AddError(peek(), std::string("unable to parse right side of ") +
+ std::string(t.to_name()) + " expression");
}
lhs = create<ast::BinaryExpression>(source(), op.value, lhs, rhs.value);
@@ -2334,8 +2334,8 @@
return Failure::kErrored;
}
if (!unary.matched) {
- return add_error(peek(), std::string("unable to parse right side of ") +
- std::string(t.to_name()) + " expression");
+ return AddError(peek(), std::string("unable to parse right side of ") +
+ std::string(t.to_name()) + " expression");
}
// The multiplicative binds tighter, so pass the unary into that and build that expression
@@ -2412,8 +2412,8 @@
return Failure::kErrored;
}
if (!rhs.matched) {
- return add_error(rhs_start,
- std::string("unable to parse right side of ") + name + " expression");
+ return AddError(rhs_start,
+ std::string("unable to parse right side of ") + name + " expression");
}
return create<ast::BinaryExpression>(source(), *op, lhs, rhs.value);
}
@@ -2490,8 +2490,8 @@
return Failure::kErrored;
}
if (!rhs.matched) {
- return add_error(tok_rhs, std::string("unable to parse right side of ") +
- std::string(tok_op.to_name()) + " expression");
+ return AddError(tok_rhs, std::string("unable to parse right side of ") +
+ std::string(tok_op.to_name()) + " expression");
}
return create<ast::BinaryExpression>(source(), *op, lhs, rhs.value);
@@ -2506,7 +2506,7 @@
if (expr.matched) {
return expr.value;
}
- return add_error(t, "expected expression for " + std::string(use));
+ return AddError(t, "expected expression for " + std::string(use));
}
Maybe<Parser::ExpressionList> Parser::expression_list(std::string_view use,
@@ -2616,8 +2616,8 @@
return Failure::kErrored;
}
if (!rhs.matched) {
- return add_error(peek(), std::string("unable to parse right side of ") +
- std::string(t.to_name()) + " expression");
+ return AddError(peek(), std::string("unable to parse right side of ") +
+ std::string(t.to_name()) + " expression");
}
ret = create<ast::BinaryExpression>(source(), op, ret, rhs.value);
@@ -2632,9 +2632,9 @@
// after this then it _must_ be a different one, and hence an error.
if (auto* lhs = expr->As<ast::BinaryExpression>()) {
if (auto& n = peek(); n.IsBinaryOperator()) {
- add_error(Source::Combine(first_op, n.source()),
- std::string("mixing '") + ast::Operator(lhs->op) + "' and '" +
- std::string(n.to_name()) + "' requires parenthesis");
+ AddError(Source::Combine(first_op, n.source()),
+ std::string("mixing '") + ast::Operator(lhs->op) + "' and '" +
+ std::string(n.to_name()) + "' requires parenthesis");
return Failure::kErrored;
}
}
@@ -2672,9 +2672,9 @@
auto& t = peek();
if (match(Token::Type::kPlusPlus) || match(Token::Type::kMinusMinus)) {
- add_error(source,
- "prefix increment and decrement operators are reserved for a "
- "future WGSL version");
+ AddError(source,
+ "prefix increment and decrement operators are reserved for a "
+ "future WGSL version");
return Failure::kErrored;
}
@@ -2697,7 +2697,7 @@
// We've hit a maximum parser recursive depth.
// We can't call into unary_expression() as we might stack overflow.
// Instead, report an error
- add_error(peek(), "maximum parser recursive depth reached");
+ AddError(peek(), "maximum parser recursive depth reached");
return Failure::kErrored;
}
@@ -2709,7 +2709,7 @@
return Failure::kErrored;
}
if (!expr.matched) {
- return add_error(
+ return AddError(
peek(), "unable to parse right side of " + std::string(t.to_name()) + " expression");
}
@@ -2775,7 +2775,7 @@
return Failure::kErrored;
}
if (!expr.matched) {
- return add_error(t, "invalid expression");
+ return AddError(t, "invalid expression");
}
return expr.value;
});
@@ -2832,7 +2832,7 @@
return Failure::kErrored;
}
if (!expr.matched) {
- return add_error(t, "missing expression");
+ return AddError(t, "missing expression");
}
const ast::Expression* ret = expr.value;
@@ -2858,7 +2858,7 @@
// special casing will error as "missing = for assignment", which is less
// helpful than this error message:
if (peek_is(Token::Type::kIdentifier) && peek_is(Token::Type::kColon, 1)) {
- return add_error(peek(0).source(), "expected 'var' for variable declaration");
+ return AddError(peek(0).source(), "expected 'var' for variable declaration");
}
Source source;
@@ -2912,7 +2912,7 @@
return Failure::kErrored;
}
if (!rhs.matched) {
- return add_error(peek(), "unable to parse right side of assignment");
+ return AddError(peek(), "unable to parse right side of assignment");
}
if (compound_op) {
@@ -3003,7 +3003,7 @@
if (attr.matched) {
return attr.value;
}
- return add_error(t, "expected attribute");
+ return AddError(t, "expected attribute");
}
// attribute
@@ -3014,7 +3014,7 @@
auto& t = peek();
if (match(Token::Type::kConst)) {
- return add_error(t.source(), "const attribute may not appear in shaders");
+ return AddError(t.source(), "const attribute may not appear in shaders");
}
if (match(Token::Type::kDiagnostic)) {
auto control = expect_diagnostic_control();
@@ -3056,7 +3056,7 @@
if (min == 0) {
auto& t2 = peek();
if (match(Token::Type::kParenLeft)) {
- return add_error(t2.source(), t.to_str() + " attribute doesn't take parenthesis");
+ return AddError(t2.source(), t.to_str() + " attribute doesn't take parenthesis");
}
} else {
auto res = expect_paren_block(t.to_str() + " attribute", [&]() -> Expect<bool> {
@@ -3082,15 +3082,15 @@
}
if (args.IsEmpty() || args.Length() < min) {
- return add_error(t.source(),
- t.to_str() + " expects" + (min != max ? " at least " : " ") +
- std::to_string(min) + " argument" + (min != 1 ? "s" : ""));
+ return AddError(t.source(),
+ t.to_str() + " expects" + (min != max ? " at least " : " ") +
+ std::to_string(min) + " argument" + (min != 1 ? "s" : ""));
}
if (args.Length() > max) {
- return add_error(t.source(),
- t.to_str() + " expects" + (min != max ? " at most " : " ") +
- std::to_string(max) + " argument" + (max != 1 ? "s" : "") +
- ", got " + std::to_string(args.Length()));
+ return AddError(t.source(), t.to_str() + " expects" + (min != max ? " at most " : " ") +
+ std::to_string(max) + " argument" +
+ (max != 1 ? "s" : "") + ", got " +
+ std::to_string(args.Length()));
}
}
@@ -3139,7 +3139,7 @@
if (in.IsEmpty()) {
return kSuccess;
}
- add_error(in[0]->source, "unexpected attributes");
+ AddError(in[0]->source, "unexpected attributes");
return Failure::kErrored;
}
@@ -3157,13 +3157,13 @@
}
Source template_source = lhs_source;
template_source.range.end = end.range.end;
- add_error(template_source, "parsed as template list");
+ AddError(template_source, "parsed as template list");
if (auto rhs = expression(); rhs.matched) {
Source lt_source = lhs_source;
lt_source.range.end = rhs->source.range.end;
- add_note(lt_source,
- "if this is intended to be a less-than expression then wrap in parentheses");
+ AddNote(lt_source,
+ "if this is intended to be a less-than expression then wrap in parentheses");
}
return Failure::kErrored;
}
@@ -3178,13 +3178,13 @@
return kSuccess;
}
- add_error(ident->source, "parsed as template list");
+ AddError(ident->source, "parsed as template list");
if (auto rhs = expression(); rhs.matched) {
Source gt_source = ident->arguments.Back()->source;
gt_source.range.end = rhs->source.range.end;
- add_note(gt_source,
- "if this is intended to be a greater-than expression then wrap in parentheses");
+ AddNote(gt_source,
+ "if this is intended to be a greater-than expression then wrap in parentheses");
}
return Failure::kErrored;
}
@@ -3300,7 +3300,7 @@
if (!use.empty()) {
err << " for " << use;
}
- add_error(t, err.str());
+ AddError(t, err.str());
return false;
}
@@ -3310,14 +3310,14 @@
*source = t.source();
}
if (!t.Is(Token::Type::kIntLiteral) && !t.Is(Token::Type::kIntLiteral_I)) {
- return add_error(t.source(), "expected signed integer literal", use);
+ return AddError(t.source(), "expected signed integer literal", use);
}
int64_t val = t.to_i64();
if ((val > std::numeric_limits<int32_t>::max()) ||
(val < std::numeric_limits<int32_t>::min())) {
// TODO(crbug.com/tint/1504): Test this when abstract int is implemented
- return add_error(t.source(), "value overflows i32", use);
+ return AddError(t.source(), "value overflows i32", use);
}
next();
@@ -3332,7 +3332,7 @@
}
if (sint.value < 0) {
- return add_error(source, std::string(use) + " must be positive");
+ return AddError(source, std::string(use) + " must be positive");
}
return static_cast<uint32_t>(sint.value);
@@ -3346,7 +3346,7 @@
}
if (sint.value <= 0) {
- return add_error(source, std::string(use) + " must be greater than 0");
+ return AddError(source, std::string(use) + " must be greater than 0");
}
return static_cast<uint32_t>(sint.value);
@@ -3360,7 +3360,7 @@
next();
if (is_reserved(t)) {
- return add_error(t.source(), "'" + t.to_str() + "' is a reserved keyword");
+ return AddError(t.source(), "'" + t.to_str() + "' is a reserved keyword");
}
return builder_.Ident(t.source(), t.to_str());
@@ -3369,7 +3369,7 @@
return Failure::kErrored;
}
synchronized_ = false;
- return add_error(t.source(), "expected " + std::string(kind), use);
+ return AddError(t.source(), "expected " + std::string(kind), use);
}
template <typename F, typename T>
@@ -3423,7 +3423,7 @@
// We've hit a maximum parser recursive depth.
// We can't call into body() as we might stack overflow.
// Instead, report an error...
- add_error(peek(), "maximum parser recursive depth reached");
+ AddError(peek(), "maximum parser recursive depth reached");
// ...and try to resynchronize. If we cannot resynchronize to `tok` then
// synchronized_ is set to false, and the parser knows that forward progress
// is not being made.
@@ -3499,7 +3499,7 @@
// The token might itself be an error.
if (t.IsError()) {
synchronized_ = false;
- add_error(t.source(), t.to_str());
+ AddError(t.source(), t.to_str());
return true;
}
return false;
diff --git a/src/tint/lang/wgsl/reader/parser/parser.h b/src/tint/lang/wgsl/reader/parser/parser.h
index 58f231e..9124e89 100644
--- a/src/tint/lang/wgsl/reader/parser/parser.h
+++ b/src/tint/lang/wgsl/reader/parser/parser.h
@@ -103,7 +103,7 @@
/// Expect is the return type of the parser methods that are expected to
/// return a parsed value of type T, unless there was an parse error.
/// In the case of a parse error the called method will have called
- /// add_error() and #errored will be set to true.
+ /// AddError() and #errored will be set to true.
template <typename T>
struct Expect {
/// An alias to the templated type T.
@@ -154,7 +154,7 @@
/// In the case of a successful grammar match, the Maybe will have #matched
/// set to true.
/// In the case of a parse error the called method will have called
- /// add_error() and the Maybe will have #errored set to true.
+ /// AddError() and the Maybe will have #errored set to true.
template <typename T>
struct Maybe {
inline Maybe(std::nullptr_t) = delete; // NOLINT
@@ -323,12 +323,12 @@
size_t get_max_errors() const { return max_errors_; }
/// @returns true if an error was encountered.
- bool has_error() const { return builder_.Diagnostics().contains_errors(); }
+ bool has_error() const { return builder_.Diagnostics().ContainsErrors(); }
/// @returns the parser error string
std::string error() const {
diag::Formatter formatter{{false, false, false, false}};
- return formatter.format(builder_.Diagnostics());
+ return formatter.Format(builder_.Diagnostics());
}
/// @returns the Program. The program builder in the parser will be reset
@@ -355,28 +355,28 @@
/// Appends an error at `t` with the message `msg`
/// @param t the token to associate the error with
/// @param msg the error message
- /// @return `Failure::Errored::kError` so that you can combine an add_error()
+ /// @return `Failure::Errored::kError` so that you can combine an AddError()
/// call and return on the same line.
- Failure::Errored add_error(const Token& t, std::string_view msg);
+ Failure::Errored AddError(const Token& t, std::string_view msg);
/// Appends an error raised when parsing `use` at `t` with the message
/// `msg`
/// @param source the source to associate the error with
/// @param msg the error message
/// @param use a description of what was being parsed when the error was
/// raised.
- /// @return `Failure::Errored::kError` so that you can combine an add_error()
+ /// @return `Failure::Errored::kError` so that you can combine an AddError()
/// call and return on the same line.
- Failure::Errored add_error(const Source& source, std::string_view msg, std::string_view use);
+ Failure::Errored AddError(const Source& source, std::string_view msg, std::string_view use);
/// Appends an error at `source` with the message `msg`
/// @param source the source to associate the error with
/// @param msg the error message
- /// @return `Failure::Errored::kError` so that you can combine an add_error()
+ /// @return `Failure::Errored::kError` so that you can combine an AddError()
/// call and return on the same line.
- Failure::Errored add_error(const Source& source, std::string_view msg);
+ Failure::Errored AddError(const Source& source, std::string_view msg);
/// Appends a note at `source` with the message `msg`
/// @param source the source to associate the error with
/// @param msg the note message
- void add_note(const Source& source, std::string_view msg);
+ void AddNote(const Source& source, std::string_view msg);
/// Appends a deprecated-language-feature warning at `source` with the message
/// `msg`
/// @param source the source to associate the error with
@@ -838,7 +838,7 @@
/// @returns true if #synchronized_ is true and the number of reported errors
/// is less than #max_errors_.
bool continue_parsing() {
- return synchronized_ && builder_.Diagnostics().error_count() < max_errors_;
+ return synchronized_ && builder_.Diagnostics().NumErrors() < max_errors_;
}
/// without_diag() calls the function `func` muting any diagnostics found while executing the
diff --git a/src/tint/lang/wgsl/reader/parser/struct_member_attribute_test.cc b/src/tint/lang/wgsl/reader/parser/struct_member_attribute_test.cc
index 2c93c6e..d0db0e5 100644
--- a/src/tint/lang/wgsl/reader/parser/struct_member_attribute_test.cc
+++ b/src/tint/lang/wgsl/reader/parser/struct_member_attribute_test.cc
@@ -233,7 +233,7 @@
EXPECT_EQ(attr.value, nullptr);
EXPECT_TRUE(p->has_error());
- EXPECT_EQ(p->builder().Diagnostics().str(),
+ EXPECT_EQ(p->builder().Diagnostics().Str(),
R"(test.wgsl:1:9 error: mixing '+' and '<<' requires parenthesis
align(4 + 5 << 6)
^^^^^^
diff --git a/src/tint/lang/wgsl/reader/program_to_ir/program_to_ir.cc b/src/tint/lang/wgsl/reader/program_to_ir/program_to_ir.cc
index cc5a137..05505d1 100644
--- a/src/tint/lang/wgsl/reader/program_to_ir/program_to_ir.cc
+++ b/src/tint/lang/wgsl/reader/program_to_ir/program_to_ir.cc
@@ -201,8 +201,8 @@
~ControlStackScope() { impl_->control_stack_.Pop(); }
};
- void add_error(const Source& s, const std::string& err) {
- diagnostics_.add_error(tint::diag::System::IR, err, s);
+ void AddError(const Source& s, const std::string& err) {
+ diagnostics_.AddError(tint::diag::System::IR, err, s);
}
bool NeedTerminator() { return current_block_ && !current_block_->Terminator(); }
@@ -266,7 +266,7 @@
TINT_ICE_ON_NO_MATCH);
}
- if (diagnostics_.contains_errors()) {
+ if (diagnostics_.ContainsErrors()) {
return Failure{std::move(diagnostics_)};
}
@@ -1005,8 +1005,8 @@
if (mat->ConstantValue()) {
auto* cv = mat->ConstantValue()->Clone(impl.clone_ctx_);
if (!cv) {
- impl.add_error(expr->source, "failed to get constant value for call " +
- std::string(expr->TypeInfo().name));
+ impl.AddError(expr->source, "failed to get constant value for call " +
+ std::string(expr->TypeInfo().name));
return;
}
Bind(expr, impl.builder_.Constant(cv));
@@ -1019,15 +1019,15 @@
for (const auto* arg : expr->args) {
auto value = GetValue(arg);
if (!value) {
- impl.add_error(arg->source, "failed to convert arguments");
+ impl.AddError(arg->source, "failed to convert arguments");
return;
}
args.Push(value);
}
auto* sem = impl.program_.Sem().Get<sem::Call>(expr);
if (!sem) {
- impl.add_error(expr->source, "failed to get semantic information for call " +
- std::string(expr->TypeInfo().name));
+ impl.AddError(expr->source, "failed to get semantic information for call " +
+ std::string(expr->TypeInfo().name));
return;
}
auto* ty = sem->Target()->ReturnType()->Clone(impl.clone_ctx_.type_ctx);
@@ -1061,8 +1061,8 @@
void EmitIdentifier(const ast::IdentifierExpression* i) {
auto* v = impl.scopes_.Get(i->identifier->symbol);
if (TINT_UNLIKELY(!v)) {
- impl.add_error(i->source,
- "unable to find identifier " + i->identifier->symbol.Name());
+ impl.AddError(i->source,
+ "unable to find identifier " + i->identifier->symbol.Name());
return;
}
Bind(i, v);
@@ -1071,14 +1071,14 @@
void EmitLiteral(const ast::LiteralExpression* lit) {
auto* sem = impl.program_.Sem().Get(lit);
if (!sem) {
- impl.add_error(lit->source, "failed to get semantic information for node " +
- std::string(lit->TypeInfo().name));
+ impl.AddError(lit->source, "failed to get semantic information for node " +
+ std::string(lit->TypeInfo().name));
return;
}
auto* cv = sem->ConstantValue()->Clone(impl.clone_ctx_);
if (!cv) {
- impl.add_error(lit->source, "failed to get constant value for node " +
- std::string(lit->TypeInfo().name));
+ impl.AddError(lit->source, "failed to get constant value for node " +
+ std::string(lit->TypeInfo().name));
return;
}
auto* val = impl.builder_.Constant(cv);
@@ -1272,9 +1272,9 @@
scopes_.Set(l->name->symbol, let->Result(0));
},
[&](const ast::Override*) {
- add_error(var->source,
- "found an `Override` variable. The SubstituteOverrides "
- "transform must be run before converting to IR");
+ AddError(var->source,
+ "found an `Override` variable. The SubstituteOverrides "
+ "transform must be run before converting to IR");
},
[&](const ast::Const*) {
// Skip. This should be handled by const-eval already, so the const will be a
@@ -1346,7 +1346,7 @@
auto r = b.Build();
if (r != Success) {
diag::List err = std::move(r.Failure().reason);
- err.add_note(diag::System::IR, "AST:\n" + Program::printer(program), Source{});
+ err.AddNote(diag::System::IR, "AST:\n" + Program::printer(program), Source{});
return Failure{err};
}
diff --git a/src/tint/lang/wgsl/reader/reader.cc b/src/tint/lang/wgsl/reader/reader.cc
index 77289d1..40c4f79 100644
--- a/src/tint/lang/wgsl/reader/reader.cc
+++ b/src/tint/lang/wgsl/reader/reader.cc
@@ -41,8 +41,8 @@
if (TINT_UNLIKELY(file->content.data.size() >
static_cast<size_t>(std::numeric_limits<uint32_t>::max()))) {
ProgramBuilder b;
- b.Diagnostics().add_error(tint::diag::System::Reader,
- "WGSL source must be 0xffffffff bytes or fewer");
+ b.Diagnostics().AddError(tint::diag::System::Reader,
+ "WGSL source must be 0xffffffff bytes or fewer");
return Program(std::move(b));
}
Parser parser(file);
diff --git a/src/tint/lang/wgsl/reader/reader.h b/src/tint/lang/wgsl/reader/reader.h
index 8594250..45edcd8 100644
--- a/src/tint/lang/wgsl/reader/reader.h
+++ b/src/tint/lang/wgsl/reader/reader.h
@@ -36,7 +36,7 @@
/// Parses the WGSL source, returning the parsed program.
/// If the source fails to parse then the returned
-/// `program.Diagnostics.contains_errors()` will be true, and the
+/// `program.Diagnostics.ContainsErrors()` will be true, and the
/// `program.Diagnostics()` will describe the error.
/// @param file the source file
/// @param options the configuration options to use when parsing WGSL
diff --git a/src/tint/lang/wgsl/reader/reader_bench.cc b/src/tint/lang/wgsl/reader/reader_bench.cc
index bc24e0d..ba260af 100644
--- a/src/tint/lang/wgsl/reader/reader_bench.cc
+++ b/src/tint/lang/wgsl/reader/reader_bench.cc
@@ -36,13 +36,13 @@
void ParseWGSL(benchmark::State& state, std::string input_name) {
auto res = bench::LoadInputFile(input_name);
if (res != Success) {
- state.SkipWithError(res.Failure().reason.str());
+ state.SkipWithError(res.Failure().reason.Str());
return;
}
for (auto _ : state) {
auto program = Parse(&res.Get());
- if (program.Diagnostics().contains_errors()) {
- state.SkipWithError(program.Diagnostics().str());
+ if (program.Diagnostics().ContainsErrors()) {
+ state.SkipWithError(program.Diagnostics().Str());
}
}
}
diff --git a/src/tint/lang/wgsl/resolver/dependency_graph.cc b/src/tint/lang/wgsl/resolver/dependency_graph.cc
index f8b5425..438acef 100644
--- a/src/tint/lang/wgsl/resolver/dependency_graph.cc
+++ b/src/tint/lang/wgsl/resolver/dependency_graph.cc
@@ -139,12 +139,12 @@
/// Raises an error diagnostic with the given message and source.
void AddError(diag::List& diagnostics, const std::string& msg, const Source& source) {
- diagnostics.add_error(diag::System::Resolver, msg, source);
+ diagnostics.AddError(diag::System::Resolver, msg, source);
}
/// Raises a note diagnostic with the given message and source.
void AddNote(diag::List& diagnostics, const std::string& msg, const Source& source) {
- diagnostics.add_note(diag::System::Resolver, msg, source);
+ diagnostics.AddNote(diag::System::Resolver, msg, source);
}
/// DependencyScanner is used to traverse a module to build the list of
@@ -600,7 +600,7 @@
graph_.ordered_globals = sorted_.Release();
- return !diagnostics_.contains_errors();
+ return !diagnostics_.ContainsErrors();
}
private:
@@ -714,7 +714,7 @@
/// SortGlobals sorts the globals into dependency order, erroring if cyclic
/// dependencies are found. The sorted dependencies are assigned to #sorted.
void SortGlobals() {
- if (diagnostics_.contains_errors()) {
+ if (diagnostics_.ContainsErrors()) {
return; // This code assumes there are no undeclared identifiers.
}
diff --git a/src/tint/lang/wgsl/resolver/dependency_graph_test.cc b/src/tint/lang/wgsl/resolver/dependency_graph_test.cc
index 5e79a3e..e435301 100644
--- a/src/tint/lang/wgsl/resolver/dependency_graph_test.cc
+++ b/src/tint/lang/wgsl/resolver/dependency_graph_test.cc
@@ -53,7 +53,7 @@
EXPECT_TRUE(result) << this->Diagnostics();
} else {
EXPECT_FALSE(result);
- EXPECT_EQ(expected_error, this->Diagnostics().str());
+ EXPECT_EQ(expected_error, this->Diagnostics().Str());
}
return graph;
}
diff --git a/src/tint/lang/wgsl/resolver/resolver.cc b/src/tint/lang/wgsl/resolver/resolver.cc
index 3e717d4..4595afa 100644
--- a/src/tint/lang/wgsl/resolver/resolver.cc
+++ b/src/tint/lang/wgsl/resolver/resolver.cc
@@ -141,7 +141,7 @@
Resolver::~Resolver() = default;
bool Resolver::Resolve() {
- if (diagnostics_.contains_errors()) {
+ if (diagnostics_.ContainsErrors()) {
return false;
}
@@ -156,7 +156,7 @@
bool result = ResolveInternal();
- if (TINT_UNLIKELY(!result && !diagnostics_.contains_errors())) {
+ if (TINT_UNLIKELY(!result && !diagnostics_.ContainsErrors())) {
AddICE("resolving failed, but no error was raised", {});
return false;
}
@@ -5063,19 +5063,19 @@
err.system = diag::System::Resolver;
err.source = source;
err.message = msg;
- diagnostics_.add(std::move(err));
+ diagnostics_.Add(std::move(err));
}
void Resolver::AddError(const std::string& msg, const Source& source) const {
- diagnostics_.add_error(diag::System::Resolver, msg, source);
+ diagnostics_.AddError(diag::System::Resolver, msg, source);
}
void Resolver::AddWarning(const std::string& msg, const Source& source) const {
- diagnostics_.add_warning(diag::System::Resolver, msg, source);
+ diagnostics_.AddWarning(diag::System::Resolver, msg, source);
}
void Resolver::AddNote(const std::string& msg, const Source& source) const {
- diagnostics_.add_note(diag::System::Resolver, msg, source);
+ diagnostics_.AddNote(diag::System::Resolver, msg, source);
}
} // namespace tint::resolver
diff --git a/src/tint/lang/wgsl/resolver/resolver.h b/src/tint/lang/wgsl/resolver/resolver.h
index d51923c..fe1e497 100644
--- a/src/tint/lang/wgsl/resolver/resolver.h
+++ b/src/tint/lang/wgsl/resolver/resolver.h
@@ -104,7 +104,7 @@
~Resolver();
/// @returns error messages from the resolver
- std::string error() const { return diagnostics_.str(); }
+ std::string error() const { return diagnostics_.Str(); }
/// @returns the list of diagnostics raised by the generator.
const diag::List& Diagnostics() const { return diagnostics_; }
diff --git a/src/tint/lang/wgsl/resolver/sem_helper.cc b/src/tint/lang/wgsl/resolver/sem_helper.cc
index d6e8b89..e364a91 100644
--- a/src/tint/lang/wgsl/resolver/sem_helper.cc
+++ b/src/tint/lang/wgsl/resolver/sem_helper.cc
@@ -214,14 +214,14 @@
}
void SemHelper::AddError(const std::string& msg, const Source& source) const {
- builder_->Diagnostics().add_error(diag::System::Resolver, msg, source);
+ builder_->Diagnostics().AddError(diag::System::Resolver, msg, source);
}
void SemHelper::AddWarning(const std::string& msg, const Source& source) const {
- builder_->Diagnostics().add_warning(diag::System::Resolver, msg, source);
+ builder_->Diagnostics().AddWarning(diag::System::Resolver, msg, source);
}
void SemHelper::AddNote(const std::string& msg, const Source& source) const {
- builder_->Diagnostics().add_note(diag::System::Resolver, msg, source);
+ builder_->Diagnostics().AddNote(diag::System::Resolver, msg, source);
}
} // namespace tint::resolver
diff --git a/src/tint/lang/wgsl/resolver/uniformity.cc b/src/tint/lang/wgsl/resolver/uniformity.cc
index cf03bc7..f3f2570 100644
--- a/src/tint/lang/wgsl/resolver/uniformity.cc
+++ b/src/tint/lang/wgsl/resolver/uniformity.cc
@@ -1831,9 +1831,9 @@
auto* control_flow = TraceBackAlongPathUntil(
non_uniform_source, [](Node* node) { return node->affects_control_flow; });
if (control_flow) {
- diagnostics_.add_note(diag::System::Resolver,
- "control flow depends on possibly non-uniform value",
- control_flow->ast->source);
+ diagnostics_.AddNote(diag::System::Resolver,
+ "control flow depends on possibly non-uniform value",
+ control_flow->ast->source);
// TODO(jrprice): There are cases where the function with uniformity requirements is not
// actually inside this control flow construct, for example:
// - A conditional interrupt (e.g. break), with a barrier elsewhere in the loop
@@ -1887,20 +1887,20 @@
ss << "reading from " << var_type(var) << "'" << NameFor(ident)
<< "' may result in a non-uniform value";
}
- diagnostics_.add_note(diag::System::Resolver, ss.str(), ident->source);
+ diagnostics_.AddNote(diag::System::Resolver, ss.str(), ident->source);
},
[&](const ast::Variable* v) {
auto* var = sem_.Get(v);
StringStream ss;
ss << "reading from " << var_type(var) << "'" << NameFor(v)
<< "' may result in a non-uniform value";
- diagnostics_.add_note(diag::System::Resolver, ss.str(), v->source);
+ diagnostics_.AddNote(diag::System::Resolver, ss.str(), v->source);
},
[&](const ast::CallExpression* c) {
auto target_name = NameFor(c->target);
switch (non_uniform_source->type) {
case Node::kFunctionCallReturnValue: {
- diagnostics_.add_note(
+ diagnostics_.AddNote(
diag::System::Resolver,
"return value of '" + target_name + "' may be non-uniform", c->source);
break;
@@ -1911,21 +1911,21 @@
StringStream ss;
ss << "reading from " << var_type(var) << "'" << NameFor(var)
<< "' may result in a non-uniform value";
- diagnostics_.add_note(diag::System::Resolver, ss.str(),
- var->Declaration()->source);
+ diagnostics_.AddNote(diag::System::Resolver, ss.str(),
+ var->Declaration()->source);
break;
}
case Node::kFunctionCallArgumentValue: {
auto* arg = c->args[non_uniform_source->arg_index];
// TODO(jrprice): Which output? (return value vs another pointer argument).
- diagnostics_.add_note(diag::System::Resolver,
- "passing non-uniform pointer to '" + target_name +
- "' may produce a non-uniform output",
- arg->source);
+ diagnostics_.AddNote(diag::System::Resolver,
+ "passing non-uniform pointer to '" + target_name +
+ "' may produce a non-uniform output",
+ arg->source);
break;
}
case Node::kFunctionCallPointerArgumentResult: {
- diagnostics_.add_note(
+ diagnostics_.AddNote(
diag::System::Resolver,
"contents of pointer may become non-uniform after calling '" +
target_name + "'",
@@ -1939,8 +1939,8 @@
}
},
[&](const ast::Expression* e) {
- diagnostics_.add_note(diag::System::Resolver,
- "result of expression may be non-uniform", e->source);
+ diagnostics_.AddNote(diag::System::Resolver,
+ "result of expression may be non-uniform", e->source);
}, //
TINT_ICE_ON_NO_MATCH);
}
@@ -1957,7 +1957,7 @@
error.system = diag::System::Resolver;
error.source = source;
error.message = msg;
- diagnostics_.add(std::move(error));
+ diagnostics_.Add(std::move(error));
};
// Traverse the graph to generate a path from RequiredToBeUniform to the source node.
diff --git a/src/tint/lang/wgsl/resolver/uniformity_test.cc b/src/tint/lang/wgsl/resolver/uniformity_test.cc
index 4674237..c4a5000 100644
--- a/src/tint/lang/wgsl/resolver/uniformity_test.cc
+++ b/src/tint/lang/wgsl/resolver/uniformity_test.cc
@@ -53,12 +53,12 @@
/// @param program the program
/// @param should_pass true if `builder` program should pass the analysis, otherwise false
void RunTest(Program&& program, bool should_pass) {
- error_ = program.Diagnostics().str();
+ error_ = program.Diagnostics().Str();
bool valid = program.IsValid();
if (should_pass) {
EXPECT_TRUE(valid) << error_;
- EXPECT_FALSE(program.Diagnostics().contains_errors());
+ EXPECT_FALSE(program.Diagnostics().ContainsErrors());
} else {
if (kUniformityFailuresAsError) {
EXPECT_FALSE(valid);
diff --git a/src/tint/lang/wgsl/resolver/validator.cc b/src/tint/lang/wgsl/resolver/validator.cc
index 6e0413c..8e54a74 100644
--- a/src/tint/lang/wgsl/resolver/validator.cc
+++ b/src/tint/lang/wgsl/resolver/validator.cc
@@ -182,15 +182,15 @@
Validator::~Validator() = default;
void Validator::AddError(const std::string& msg, const Source& source) const {
- diagnostics_.add_error(diag::System::Resolver, msg, source);
+ diagnostics_.AddError(diag::System::Resolver, msg, source);
}
void Validator::AddWarning(const std::string& msg, const Source& source) const {
- diagnostics_.add_warning(diag::System::Resolver, msg, source);
+ diagnostics_.AddWarning(diag::System::Resolver, msg, source);
}
void Validator::AddNote(const std::string& msg, const Source& source) const {
- diagnostics_.add_note(diag::System::Resolver, msg, source);
+ diagnostics_.AddNote(diag::System::Resolver, msg, source);
}
bool Validator::AddDiagnostic(wgsl::DiagnosticRule rule,
@@ -203,7 +203,7 @@
d.system = diag::System::Resolver;
d.source = source;
d.message = msg;
- diagnostics_.add(std::move(d));
+ diagnostics_.Add(std::move(d));
if (severity == wgsl::DiagnosticSeverity::kError) {
return false;
}
diff --git a/src/tint/lang/wgsl/writer/ast_printer/ast_printer.cc b/src/tint/lang/wgsl/writer/ast_printer/ast_printer.cc
index 517ea6d..05cce63 100644
--- a/src/tint/lang/wgsl/writer/ast_printer/ast_printer.cc
+++ b/src/tint/lang/wgsl/writer/ast_printer/ast_printer.cc
@@ -133,7 +133,7 @@
}
}
- return !diagnostics_.contains_errors();
+ return !diagnostics_.ContainsErrors();
}
void ASTPrinter::EmitDiagnosticControl(StringStream& out,
@@ -349,7 +349,7 @@
void ASTPrinter::EmitImageFormat(StringStream& out, const core::TexelFormat fmt) {
switch (fmt) {
case core::TexelFormat::kUndefined:
- diagnostics_.add_error(diag::System::Writer, "unknown image format");
+ diagnostics_.AddError(diag::System::Writer, "unknown image format");
break;
default:
out << fmt;
diff --git a/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program_test.cc b/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program_test.cc
index b3119c7..c2fff06 100644
--- a/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program_test.cc
+++ b/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program_test.cc
@@ -53,7 +53,7 @@
options.allowed_features = AllowedFeatures::Everything();
auto output_program = IRToProgram(mod, options);
if (!output_program.IsValid()) {
- result.err = output_program.Diagnostics().str();
+ result.err = output_program.Diagnostics().Str();
result.ast = Program::printer(output_program);
return result;
}
diff --git a/src/tint/lang/wgsl/writer/writer_bench.cc b/src/tint/lang/wgsl/writer/writer_bench.cc
index 68dc9a2..285710e 100644
--- a/src/tint/lang/wgsl/writer/writer_bench.cc
+++ b/src/tint/lang/wgsl/writer/writer_bench.cc
@@ -36,13 +36,13 @@
void GenerateWGSL(benchmark::State& state, std::string input_name) {
auto res = bench::LoadProgram(input_name);
if (res != Success) {
- state.SkipWithError(res.Failure().reason.str());
+ state.SkipWithError(res.Failure().reason.Str());
return;
}
for (auto _ : state) {
auto gen_res = Generate(res->program, {});
if (gen_res != Success) {
- state.SkipWithError(gen_res.Failure().reason.str());
+ state.SkipWithError(gen_res.Failure().reason.Str());
}
}
}
diff --git a/src/tint/utils/bytes/decoder.h b/src/tint/utils/bytes/decoder.h
index 6901f7c..a62d2e5 100644
--- a/src/tint/utils/bytes/decoder.h
+++ b/src/tint/utils/bytes/decoder.h
@@ -113,7 +113,7 @@
if (value == Success) {
field = value.Get();
} else {
- errs.add(value.Failure().reason);
+ errs.Add(value.Failure().reason);
}
});
if (errs.empty()) {
diff --git a/src/tint/utils/cli/cli_test.cc b/src/tint/utils/cli/cli_test.cc
index 273d972..470a3b7 100644
--- a/src/tint/utils/cli/cli_test.cc
+++ b/src/tint/utils/cli/cli_test.cc
@@ -165,7 +165,7 @@
auto res = opts.Parse(Split("--myoption false", " "));
ASSERT_NE(res, Success);
- EXPECT_EQ(res.Failure().reason.str(), R"(error: unknown flag: --myoption
+ EXPECT_EQ(res.Failure().reason.Str(), R"(error: unknown flag: --myoption
Did you mean '--my_option'?)");
}
diff --git a/src/tint/utils/diagnostic/diagnostic.cc b/src/tint/utils/diagnostic/diagnostic.cc
index ff0170c..404d9fa 100644
--- a/src/tint/utils/diagnostic/diagnostic.cc
+++ b/src/tint/utils/diagnostic/diagnostic.cc
@@ -66,10 +66,10 @@
List& List::operator=(List&& rhs) = default;
-std::string List::str() const {
+std::string List::Str() const {
diag::Formatter::Style style;
style.print_newline_at_end = false;
- return Formatter{style}.format(*this);
+ return Formatter{style}.Format(*this);
}
} // namespace tint::diag
diff --git a/src/tint/utils/diagnostic/diagnostic.h b/src/tint/utils/diagnostic/diagnostic.h
index a077f47..ac5c42a 100644
--- a/src/tint/utils/diagnostic/diagnostic.h
+++ b/src/tint/utils/diagnostic/diagnostic.h
@@ -137,11 +137,23 @@
/// @return this list.
List& operator=(List&& list);
- /// adds a diagnostic to the end of this list.
+ /// Adds a diagnostic to the end of this list.
/// @param diag the diagnostic to append to this list.
/// @returns a reference to the new diagnostic.
/// @note The returned reference must not be used after the list is mutated again.
- diag::Diagnostic& add(Diagnostic&& diag) {
+ diag::Diagnostic& Add(const Diagnostic& diag) {
+ if (diag.severity >= Severity::Error) {
+ error_count_++;
+ }
+ entries_.Push(diag);
+ return entries_.Back();
+ }
+
+ /// Adds a diagnostic to the end of this list.
+ /// @param diag the diagnostic to append to this list.
+ /// @returns a reference to the new diagnostic.
+ /// @note The returned reference must not be used after the list is mutated again.
+ diag::Diagnostic& Add(Diagnostic&& diag) {
if (diag.severity >= Severity::Error) {
error_count_++;
}
@@ -149,113 +161,119 @@
return entries_.Back();
}
- /// adds a list of diagnostics to the end of this list.
+ /// Adds a list of diagnostics to the end of this list.
/// @param list the diagnostic to append to this list.
- void add(const List& list) {
+ void Add(const List& list) {
for (auto diag : list) {
- add(std::move(diag));
+ Add(std::move(diag));
}
}
- /// adds the note message with the given Source to the end of this list.
+ /// Adds the note message with the given Source to the end of this list.
/// @param system the system raising the note message
/// @param note_msg the note message
/// @param source the source of the note diagnostic
/// @returns a reference to the new diagnostic.
/// @note The returned reference must not be used after the list is mutated again.
- diag::Diagnostic& add_note(System system, std::string_view note_msg, const Source& source) {
+ diag::Diagnostic& AddNote(System system, std::string_view note_msg, const Source& source) {
diag::Diagnostic note{};
note.severity = diag::Severity::Note;
note.system = system;
note.source = source;
note.message = note_msg;
- return add(std::move(note));
+ return Add(std::move(note));
}
- /// adds the warning message with the given Source to the end of this list.
+ /// Adds the warning message with the given Source to the end of this list.
/// @param system the system raising the warning message
/// @param warning_msg the warning message
/// @param source the source of the warning diagnostic
/// @returns a reference to the new diagnostic.
/// @note The returned reference must not be used after the list is mutated again.
- diag::Diagnostic& add_warning(System system,
- std::string_view warning_msg,
- const Source& source) {
+ diag::Diagnostic& AddWarning(System system,
+ std::string_view warning_msg,
+ const Source& source) {
diag::Diagnostic warning{};
warning.severity = diag::Severity::Warning;
warning.system = system;
warning.source = source;
warning.message = warning_msg;
- return add(std::move(warning));
+ return Add(std::move(warning));
}
- /// adds the error message without a source to the end of this list.
+ /// Adds the error message without a source to the end of this list.
/// @param system the system raising the error message
/// @param err_msg the error message
/// @returns a reference to the new diagnostic.
/// @note The returned reference must not be used after the list is mutated again.
- diag::Diagnostic& add_error(System system, std::string_view err_msg) {
+ diag::Diagnostic& AddError(System system, std::string_view err_msg) {
diag::Diagnostic error{};
error.severity = diag::Severity::Error;
error.system = system;
error.message = err_msg;
- return add(std::move(error));
+ return Add(std::move(error));
}
- /// adds the error message with the given Source to the end of this list.
+ /// Adds the error message with the given Source to the end of this list.
/// @param system the system raising the error message
/// @param err_msg the error message
/// @param source the source of the error diagnostic
/// @returns a reference to the new diagnostic.
/// @note The returned reference must not be used after the list is mutated again.
- diag::Diagnostic& add_error(System system, std::string_view err_msg, const Source& source) {
+ diag::Diagnostic& AddError(System system, std::string_view err_msg, const Source& source) {
diag::Diagnostic error{};
error.severity = diag::Severity::Error;
error.system = system;
error.source = source;
error.message = err_msg;
- return add(std::move(error));
+ return Add(std::move(error));
}
- /// adds an internal compiler error message to the end of this list.
+ /// Adds an internal compiler error message to the end of this list.
/// @param system the system raising the error message
/// @param err_msg 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& add_ice(System system,
- std::string_view err_msg,
- const Source& source,
- std::shared_ptr<Source::File> file) {
+ diag::Diagnostic& AddIce(System system,
+ std::string_view err_msg,
+ const Source& source,
+ std::shared_ptr<Source::File> file) {
diag::Diagnostic ice{};
ice.severity = diag::Severity::InternalCompilerError;
ice.system = system;
ice.source = source;
ice.message = err_msg;
ice.owned_file = std::move(file);
- return add(std::move(ice));
+ return Add(std::move(ice));
}
/// @returns true iff the diagnostic list contains errors diagnostics (or of
/// higher severity).
- bool contains_errors() const { return error_count_ > 0; }
+ bool ContainsErrors() const { return error_count_ > 0; }
/// @returns the number of error diagnostics (or of higher severity).
- size_t error_count() const { return error_count_; }
+ size_t NumErrors() const { return error_count_; }
/// @returns the number of entries in the list.
- size_t count() const { return entries_.Length(); }
+ size_t Count() const { return entries_.Length(); }
+ /// @returns true if the diagnostics list is empty
+ bool IsEmpty() const { return entries_.IsEmpty(); }
+
+ /// @returns a formatted string of all the diagnostics in this list.
+ std::string Str() const;
+
+ ////////////////////////////////////////////////////////////////////////////
+ /// STL-interface support
+ ////////////////////////////////////////////////////////////////////////////
/// @returns true if the diagnostics list is empty
bool empty() const { return entries_.IsEmpty(); }
- /// @returns the number of entrise in the diagnostics list
+ /// @returns the number of entries in the list.
size_t size() const { return entries_.Length(); }
/// @returns the first diagnostic in the list.
iterator begin() const { return entries_.begin(); }
/// @returns the last diagnostic in the list.
iterator end() const { return entries_.end(); }
- /// @returns a formatted string of all the diagnostics in this list.
- std::string str() const;
-
private:
Vector<Diagnostic, 0> entries_;
size_t error_count_ = 0;
@@ -267,7 +285,7 @@
/// @returns the output stream
template <typename STREAM, typename = traits::EnableIfIsOStream<STREAM>>
auto& operator<<(STREAM& out, const List& list) {
- return out << list.str();
+ return out << list.Str();
}
} // namespace tint::diag
diff --git a/src/tint/utils/diagnostic/diagnostic_test.cc b/src/tint/utils/diagnostic/diagnostic_test.cc
index f947b62..07c44fb 100644
--- a/src/tint/utils/diagnostic/diagnostic_test.cc
+++ b/src/tint/utils/diagnostic/diagnostic_test.cc
@@ -38,7 +38,7 @@
err_a.severity = Severity::Error;
err_b.severity = Severity::Fatal;
List list{err_a, err_b};
- EXPECT_EQ(list.count(), 2u);
+ EXPECT_EQ(list.Count(), 2u);
}
TEST(DiagListTest, CtorVectorRef) {
@@ -46,7 +46,7 @@
err_a.severity = Severity::Error;
err_b.severity = Severity::Fatal;
List list(Vector{err_a, err_b});
- EXPECT_EQ(list.count(), 2u);
+ EXPECT_EQ(list.Count(), 2u);
}
TEST(DiagListTest, OwnedFilesShared) {
@@ -56,12 +56,12 @@
{
Diagnostic diag{};
diag.source = Source{Source::Range{{0, 0}}, file.get()};
- list_a.add(std::move(diag));
+ list_a.Add(std::move(diag));
}
list_b = list_a;
- ASSERT_EQ(list_b.count(), list_a.count());
+ ASSERT_EQ(list_b.Count(), list_a.Count());
EXPECT_EQ(list_b.begin()->source.file, file.get());
}
diff --git a/src/tint/utils/diagnostic/formatter.cc b/src/tint/utils/diagnostic/formatter.cc
index 7b4ea24..a256a8a 100644
--- a/src/tint/utils/diagnostic/formatter.cc
+++ b/src/tint/utils/diagnostic/formatter.cc
@@ -75,10 +75,10 @@
explicit State(Printer* p) : printer(p) {}
~State() { flush(); }
- /// set_style() sets the current style to new_style, flushing any pending
- /// messages to the printer if the style changed.
+ /// SetStyle sets the current style to new_style, flushing any pending messages to the printer
+ /// if the style changed.
/// @param new_style the new style to apply for future written messages.
- void set_style(const diag::Style& new_style) {
+ void SetStyle(const diag::Style& new_style) {
if (style.color != new_style.color || style.bold != new_style.bold) {
flush();
style = new_style;
@@ -89,7 +89,7 @@
void flush() {
auto str = stream.str();
if (str.length() > 0) {
- printer->write(str, style);
+ printer->Write(str, style);
StringStream reset;
stream.swap(reset);
}
@@ -104,8 +104,8 @@
return *this;
}
- /// newline queues a newline to be written to the printer.
- void newline() { stream << std::endl; }
+ /// Newline queues a newline to be written to the printer.
+ void Newline() { stream << std::endl; }
/// repeat queues the character c to be written to the printer n times.
/// @param c the character to print `n` times
@@ -121,29 +121,29 @@
Formatter::Formatter() {}
Formatter::Formatter(const Style& style) : style_(style) {}
-void Formatter::format(const List& list, Printer* printer) const {
+void Formatter::Format(const List& list, Printer* printer) const {
State state{printer};
bool first = true;
for (auto diag : list) {
- state.set_style({});
+ state.SetStyle({});
if (!first) {
- state.newline();
+ state.Newline();
}
- format(diag, state);
+ Format(diag, state);
first = false;
}
if (style_.print_newline_at_end) {
- state.newline();
+ state.Newline();
}
}
-void Formatter::format(const Diagnostic& diag, State& state) const {
+void Formatter::Format(const Diagnostic& diag, State& state) const {
auto const& src = diag.source;
auto const& rng = src.range;
- state.set_style({Color::kDefault, true});
+ state.SetStyle({Color::kDefault, true});
struct TextAndColor {
std::string text;
@@ -187,19 +187,19 @@
if (i > 0) {
state << " ";
}
- state.set_style({prefix[i].color, prefix[i].bold});
+ state.SetStyle({prefix[i].color, prefix[i].bold});
state << prefix[i].text;
}
- state.set_style({Color::kDefault, true});
+ state.SetStyle({Color::kDefault, true});
if (!prefix.empty()) {
state << ": ";
}
state << diag.message;
if (style_.print_line && src.file && rng.begin.line > 0) {
- state.newline();
- state.set_style({Color::kDefault, false});
+ state.Newline();
+ state.SetStyle({Color::kDefault, false});
for (size_t line_num = rng.begin.line;
(line_num <= rng.end.line) && (line_num <= src.file->content.lines.size());
@@ -219,7 +219,7 @@
}
}
- state.newline();
+ state.Newline();
// If the line contains non-ascii characters, then we cannot assume that
// a single utf8 code unit represents a single glyph, so don't attempt to
@@ -228,7 +228,7 @@
continue;
}
- state.set_style({Color::kCyan, false});
+ state.SetStyle({Color::kCyan, false});
// Count the number of glyphs in the line span.
// start and end use 1-based indexing.
@@ -258,16 +258,16 @@
// Middle of multi-line
state.repeat('^', num_glyphs(1, line_len + 1));
}
- state.newline();
+ state.Newline();
}
- state.set_style({});
+ state.SetStyle({});
}
}
-std::string Formatter::format(const List& list) const {
+std::string Formatter::Format(const List& list) const {
StringPrinter printer;
- format(list, &printer);
+ Format(list, &printer);
return printer.str();
}
diff --git a/src/tint/utils/diagnostic/formatter.h b/src/tint/utils/diagnostic/formatter.h
index ad18793..63da5e2 100644
--- a/src/tint/utils/diagnostic/formatter.h
+++ b/src/tint/utils/diagnostic/formatter.h
@@ -64,16 +64,16 @@
/// @param list the list of diagnostic messages to format
/// @param printer the printer used to display the formatted diagnostics
- void format(const List& list, Printer* printer) const;
+ void Format(const List& list, Printer* printer) const;
/// @return the list of diagnostics `list` formatted to a string.
/// @param list the list of diagnostic messages to format
- std::string format(const List& list) const;
+ std::string Format(const List& list) const;
private:
struct State;
- void format(const Diagnostic& diag, State& state) const;
+ void Format(const Diagnostic& diag, State& state) const;
const Style style_;
};
diff --git a/src/tint/utils/diagnostic/formatter_test.cc b/src/tint/utils/diagnostic/formatter_test.cc
index cde6d83..44e63dc1 100644
--- a/src/tint/utils/diagnostic/formatter_test.cc
+++ b/src/tint/utils/diagnostic/formatter_test.cc
@@ -106,7 +106,7 @@
TEST_F(DiagFormatterTest, Simple) {
Formatter fmt{{false, false, false, false}};
- auto got = fmt.format(List{ascii_diag_note, ascii_diag_warn, ascii_diag_err});
+ auto got = fmt.Format(List{ascii_diag_note, ascii_diag_warn, ascii_diag_err});
auto* expect = R"(1:14: purr
2:14: grrr
3:16: hiss)";
@@ -115,7 +115,7 @@
TEST_F(DiagFormatterTest, SimpleNewlineAtEnd) {
Formatter fmt{{false, false, false, true}};
- auto got = fmt.format(List{ascii_diag_note, ascii_diag_warn, ascii_diag_err});
+ auto got = fmt.Format(List{ascii_diag_note, ascii_diag_warn, ascii_diag_err});
auto* expect = R"(1:14: purr
2:14: grrr
3:16: hiss
@@ -126,14 +126,14 @@
TEST_F(DiagFormatterTest, SimpleNoSource) {
Formatter fmt{{false, false, false, false}};
auto diag = Diag(Severity::Note, Source{}, "no source!", System::Test);
- auto got = fmt.format(List{diag});
+ auto got = fmt.Format(List{diag});
auto* expect = "no source!";
ASSERT_EQ(expect, got);
}
TEST_F(DiagFormatterTest, WithFile) {
Formatter fmt{{true, false, false, false}};
- auto got = fmt.format(List{ascii_diag_note, ascii_diag_warn, ascii_diag_err});
+ auto got = fmt.Format(List{ascii_diag_note, ascii_diag_warn, ascii_diag_err});
auto* expect = R"(file.name:1:14: purr
file.name:2:14: grrr
file.name:3:16: hiss)";
@@ -142,7 +142,7 @@
TEST_F(DiagFormatterTest, WithSeverity) {
Formatter fmt{{false, true, false, false}};
- auto got = fmt.format(List{ascii_diag_note, ascii_diag_warn, ascii_diag_err});
+ auto got = fmt.Format(List{ascii_diag_note, ascii_diag_warn, ascii_diag_err});
auto* expect = R"(1:14 note: purr
2:14 warning: grrr
3:16 error: hiss)";
@@ -151,7 +151,7 @@
TEST_F(DiagFormatterTest, WithLine) {
Formatter fmt{{false, false, true, false}};
- auto got = fmt.format(List{ascii_diag_note, ascii_diag_warn, ascii_diag_err});
+ auto got = fmt.Format(List{ascii_diag_note, ascii_diag_warn, ascii_diag_err});
auto* expect = R"(1:14: purr
the cat says meow
^
@@ -169,7 +169,7 @@
TEST_F(DiagFormatterTest, UnicodeWithLine) {
Formatter fmt{{false, false, true, false}};
- auto got = fmt.format(List{utf8_diag_note, utf8_diag_warn, utf8_diag_err});
+ auto got = fmt.Format(List{utf8_diag_note, utf8_diag_warn, utf8_diag_err});
auto* expect =
"1:15: purr\n"
"the \xf0\x9f\x90\xb1 says meow\n"
@@ -184,7 +184,7 @@
TEST_F(DiagFormatterTest, BasicWithFileSeverityLine) {
Formatter fmt{{true, true, true, false}};
- auto got = fmt.format(List{ascii_diag_note, ascii_diag_warn, ascii_diag_err});
+ auto got = fmt.Format(List{ascii_diag_note, ascii_diag_warn, ascii_diag_err});
auto* expect = R"(file.name:1:14 note: purr
the cat says meow
^
@@ -204,7 +204,7 @@
auto multiline = Diag(Severity::Warning, Source{Source::Range{{2, 9}, {4, 15}}, &ascii_file},
"multiline", System::Test);
Formatter fmt{{false, false, true, false}};
- auto got = fmt.format(List{multiline});
+ auto got = fmt.Format(List{multiline});
auto* expect = R"(2:9: multiline
the dog says woof
^^^^^^^^^^
@@ -220,7 +220,7 @@
auto multiline = Diag(Severity::Warning, Source{Source::Range{{2, 9}, {4, 15}}, &utf8_file},
"multiline", System::Test);
Formatter fmt{{false, false, true, false}};
- auto got = fmt.format(List{multiline});
+ auto got = fmt.Format(List{multiline});
auto* expect =
"2:9: multiline\n"
"the \xf0\x9f\x90\x95 says woof\n"
@@ -231,7 +231,7 @@
TEST_F(DiagFormatterTest, BasicWithFileSeverityLineTab4) {
Formatter fmt{{true, true, true, false, 4u}};
- auto got = fmt.format(List{ascii_diag_note, ascii_diag_warn, ascii_diag_err});
+ auto got = fmt.Format(List{ascii_diag_note, ascii_diag_warn, ascii_diag_err});
auto* expect = R"(file.name:1:14 note: purr
the cat says meow
^
@@ -251,7 +251,7 @@
auto multiline = Diag(Severity::Warning, Source{Source::Range{{2, 9}, {4, 15}}, &ascii_file},
"multiline", System::Test);
Formatter fmt{{false, false, true, false, 4u}};
- auto got = fmt.format(List{multiline});
+ auto got = fmt.Format(List{multiline});
auto* expect = R"(2:9: multiline
the dog says woof
^^^^^^^^^^^^
@@ -265,7 +265,7 @@
TEST_F(DiagFormatterTest, ICE) {
Formatter fmt{{}};
- auto got = fmt.format(List{ascii_diag_ice});
+ auto got = fmt.Format(List{ascii_diag_ice});
auto* expect = R"(file.name:4:16 internal compiler error: unreachable
the snail says ???
^^^
@@ -276,7 +276,7 @@
TEST_F(DiagFormatterTest, Fatal) {
Formatter fmt{{}};
- auto got = fmt.format(List{ascii_diag_fatal});
+ auto got = fmt.Format(List{ascii_diag_fatal});
auto* expect = R"(file.name:4:16 fatal: nothing
the snail says ???
^^^
@@ -288,8 +288,8 @@
TEST_F(DiagFormatterTest, RangeOOB) {
Formatter fmt{{true, true, true, true}};
diag::List list;
- list.add_error(System::Test, "oob", Source{{{10, 20}, {30, 20}}, &ascii_file});
- auto got = fmt.format(list);
+ list.AddError(System::Test, "oob", Source{{{10, 20}, {30, 20}}, &ascii_file});
+ auto got = fmt.Format(list);
auto* expect = R"(file.name:10:20 error: oob
)";
diff --git a/src/tint/utils/diagnostic/printer.cc b/src/tint/utils/diagnostic/printer.cc
index 5f91b1b..819dc58 100644
--- a/src/tint/utils/diagnostic/printer.cc
+++ b/src/tint/utils/diagnostic/printer.cc
@@ -40,7 +40,7 @@
return stream.str();
}
-void StringPrinter::write(const std::string& str, const Style&) {
+void StringPrinter::Write(const std::string& str, const Style&) {
stream << str;
}
diff --git a/src/tint/utils/diagnostic/printer.h b/src/tint/utils/diagnostic/printer.h
index 986d76d..2b361b8 100644
--- a/src/tint/utils/diagnostic/printer.h
+++ b/src/tint/utils/diagnostic/printer.h
@@ -57,21 +57,21 @@
bool bold = false;
};
-/// Printers are used to print formatted diagnostic messages to a terminal.
+/// Printers are used to print formatted diagnostic messages to a stream.
class Printer {
public:
/// @returns a diagnostic Printer
/// @param out the file to print to.
- /// @param use_colors if true, the printer will use colors if `out` is a
- /// terminal and supports them.
- static std::unique_ptr<Printer> create(FILE* out, bool use_colors);
+ /// @param use_colors if true, the printer will use colors if `out` is a terminal and supports
+ /// them.
+ static std::unique_ptr<Printer> Create(FILE* out, bool use_colors);
virtual ~Printer();
/// writes the string str to the printer with the given style.
/// @param str the string to write to the printer
/// @param style the style used to print `str`
- virtual void write(const std::string& str, const Style& style) = 0;
+ virtual void Write(const std::string& str, const Style& style) = 0;
};
/// StringPrinter is an implementation of Printer that writes to a std::string.
@@ -83,7 +83,7 @@
/// @returns the printed string.
std::string str() const;
- void write(const std::string& str, const Style&) override;
+ void Write(const std::string& str, const Style&) override;
private:
std::stringstream stream;
diff --git a/src/tint/utils/diagnostic/printer_other.cc b/src/tint/utils/diagnostic/printer_other.cc
index 2f93fa7..b311e5a 100644
--- a/src/tint/utils/diagnostic/printer_other.cc
+++ b/src/tint/utils/diagnostic/printer_other.cc
@@ -38,7 +38,7 @@
public:
explicit PrinterOther(FILE* f) : file(f) {}
- void write(const std::string& str, const Style&) override {
+ void Write(const std::string& str, const Style&) override {
fwrite(str.data(), 1, str.size(), file);
}
@@ -48,7 +48,7 @@
} // namespace
-std::unique_ptr<Printer> Printer::create(FILE* out, bool) {
+std::unique_ptr<Printer> Printer::Create(FILE* out, bool) {
return std::make_unique<PrinterOther>(out);
}
diff --git a/src/tint/utils/diagnostic/printer_posix.cc b/src/tint/utils/diagnostic/printer_posix.cc
index 3c7ba22..156c3ce 100644
--- a/src/tint/utils/diagnostic/printer_posix.cc
+++ b/src/tint/utils/diagnostic/printer_posix.cc
@@ -61,14 +61,14 @@
public:
PrinterPosix(FILE* f, bool colors) : file(f), use_colors(colors && supports_colors(f)) {}
- void write(const std::string& str, const Style& style) override {
- write_color(style.color, style.bold);
+ void Write(const std::string& str, const Style& style) override {
+ WriteColor(style.color, style.bold);
fwrite(str.data(), 1, str.size(), file);
- write_color(Color::kDefault, false);
+ WriteColor(Color::kDefault, false);
}
private:
- constexpr const char* color_code(Color color, bool bold) {
+ constexpr const char* ColorCode(Color color, bool bold) {
switch (color) {
case Color::kDefault:
return bold ? "\u001b[1m" : "\u001b[0m";
@@ -92,9 +92,9 @@
return ""; // unreachable
}
- void write_color(Color color, bool bold) {
+ void WriteColor(Color color, bool bold) {
if (use_colors) {
- auto* code = color_code(color, bold);
+ auto* code = ColorCode(color, bold);
fwrite(code, 1, strlen(code), file);
}
}
@@ -105,7 +105,7 @@
} // namespace
-std::unique_ptr<Printer> Printer::create(FILE* out, bool use_colors) {
+std::unique_ptr<Printer> Printer::Create(FILE* out, bool use_colors) {
return std::make_unique<PrinterPosix>(out, use_colors);
}
diff --git a/src/tint/utils/diagnostic/printer_test.cc b/src/tint/utils/diagnostic/printer_test.cc
index d847c91..aeb1fa2 100644
--- a/src/tint/utils/diagnostic/printer_test.cc
+++ b/src/tint/utils/diagnostic/printer_test.cc
@@ -49,58 +49,58 @@
using PrinterTest = testing::Test;
TEST_F(PrinterTest, WithColors) {
- auto printer = Printer::create(stdout, true);
- printer->write("Default", Style{Color::kDefault, false});
- printer->write("Black", Style{Color::kBlack, false});
- printer->write("Red", Style{Color::kRed, false});
- printer->write("Green", Style{Color::kGreen, false});
- printer->write("Yellow", Style{Color::kYellow, false});
- printer->write("Blue", Style{Color::kBlue, false});
- printer->write("Magenta", Style{Color::kMagenta, false});
- printer->write("Cyan", Style{Color::kCyan, false});
- printer->write("White", Style{Color::kWhite, false});
+ auto printer = Printer::Create(stdout, true);
+ printer->Write("Default", Style{Color::kDefault, false});
+ printer->Write("Black", Style{Color::kBlack, false});
+ printer->Write("Red", Style{Color::kRed, false});
+ printer->Write("Green", Style{Color::kGreen, false});
+ printer->Write("Yellow", Style{Color::kYellow, false});
+ printer->Write("Blue", Style{Color::kBlue, false});
+ printer->Write("Magenta", Style{Color::kMagenta, false});
+ printer->Write("Cyan", Style{Color::kCyan, false});
+ printer->Write("White", Style{Color::kWhite, false});
printf("\n");
}
TEST_F(PrinterTest, BoldWithColors) {
- auto printer = Printer::create(stdout, true);
- printer->write("Default", Style{Color::kDefault, true});
- printer->write("Black", Style{Color::kBlack, true});
- printer->write("Red", Style{Color::kRed, true});
- printer->write("Green", Style{Color::kGreen, true});
- printer->write("Yellow", Style{Color::kYellow, true});
- printer->write("Blue", Style{Color::kBlue, true});
- printer->write("Magenta", Style{Color::kMagenta, true});
- printer->write("Cyan", Style{Color::kCyan, true});
- printer->write("White", Style{Color::kWhite, true});
+ auto printer = Printer::Create(stdout, true);
+ printer->Write("Default", Style{Color::kDefault, true});
+ printer->Write("Black", Style{Color::kBlack, true});
+ printer->Write("Red", Style{Color::kRed, true});
+ printer->Write("Green", Style{Color::kGreen, true});
+ printer->Write("Yellow", Style{Color::kYellow, true});
+ printer->Write("Blue", Style{Color::kBlue, true});
+ printer->Write("Magenta", Style{Color::kMagenta, true});
+ printer->Write("Cyan", Style{Color::kCyan, true});
+ printer->Write("White", Style{Color::kWhite, true});
printf("\n");
}
TEST_F(PrinterTest, WithoutColors) {
- auto printer = Printer::create(stdout, false);
- printer->write("Default", Style{Color::kDefault, false});
- printer->write("Black", Style{Color::kBlack, false});
- printer->write("Red", Style{Color::kRed, false});
- printer->write("Green", Style{Color::kGreen, false});
- printer->write("Yellow", Style{Color::kYellow, false});
- printer->write("Blue", Style{Color::kBlue, false});
- printer->write("Magenta", Style{Color::kMagenta, false});
- printer->write("Cyan", Style{Color::kCyan, false});
- printer->write("White", Style{Color::kWhite, false});
+ auto printer = Printer::Create(stdout, false);
+ printer->Write("Default", Style{Color::kDefault, false});
+ printer->Write("Black", Style{Color::kBlack, false});
+ printer->Write("Red", Style{Color::kRed, false});
+ printer->Write("Green", Style{Color::kGreen, false});
+ printer->Write("Yellow", Style{Color::kYellow, false});
+ printer->Write("Blue", Style{Color::kBlue, false});
+ printer->Write("Magenta", Style{Color::kMagenta, false});
+ printer->Write("Cyan", Style{Color::kCyan, false});
+ printer->Write("White", Style{Color::kWhite, false});
printf("\n");
}
TEST_F(PrinterTest, BoldWithoutColors) {
- auto printer = Printer::create(stdout, false);
- printer->write("Default", Style{Color::kDefault, true});
- printer->write("Black", Style{Color::kBlack, true});
- printer->write("Red", Style{Color::kRed, true});
- printer->write("Green", Style{Color::kGreen, true});
- printer->write("Yellow", Style{Color::kYellow, true});
- printer->write("Blue", Style{Color::kBlue, true});
- printer->write("Magenta", Style{Color::kMagenta, true});
- printer->write("Cyan", Style{Color::kCyan, true});
- printer->write("White", Style{Color::kWhite, true});
+ auto printer = Printer::Create(stdout, false);
+ printer->Write("Default", Style{Color::kDefault, true});
+ printer->Write("Black", Style{Color::kBlack, true});
+ printer->Write("Red", Style{Color::kRed, true});
+ printer->Write("Green", Style{Color::kGreen, true});
+ printer->Write("Yellow", Style{Color::kYellow, true});
+ printer->Write("Blue", Style{Color::kBlue, true});
+ printer->Write("Magenta", Style{Color::kMagenta, true});
+ printer->Write("Cyan", Style{Color::kCyan, true});
+ printer->Write("White", Style{Color::kWhite, true});
printf("\n");
}
diff --git a/src/tint/utils/diagnostic/printer_windows.cc b/src/tint/utils/diagnostic/printer_windows.cc
index 52d3790..485e9a9 100644
--- a/src/tint/utils/diagnostic/printer_windows.cc
+++ b/src/tint/utils/diagnostic/printer_windows.cc
@@ -43,7 +43,7 @@
operator bool() const { return handle != INVALID_HANDLE_VALUE; }
};
-ConsoleInfo console_info(FILE* file) {
+ConsoleInfo ConsoleInfoFor(FILE* file) {
if (file == nullptr) {
return {};
}
@@ -69,16 +69,16 @@
class PrinterWindows : public Printer {
public:
PrinterWindows(FILE* f, bool use_colors)
- : file(f), console(console_info(use_colors ? f : nullptr)) {}
+ : file(f), console(ConsoleInfoFor(use_colors ? f : nullptr)) {}
- void write(const std::string& str, const Style& style) override {
- write_color(style.color, style.bold);
+ void Write(const std::string& str, const Style& style) override {
+ WriteColor(style.color, style.bold);
fwrite(str.data(), 1, str.size(), file);
- write_color(Color::kDefault, false);
+ WriteColor(Color::kDefault, false);
}
private:
- WORD attributes(Color color, bool bold) {
+ WORD Attributes(Color color, bool bold) {
switch (color) {
case Color::kDefault:
return console.default_attributes;
@@ -103,9 +103,9 @@
return 0; // unreachable
}
- void write_color(Color color, bool bold) {
+ void WriteColor(Color color, bool bold) {
if (console) {
- SetConsoleTextAttribute(console.handle, attributes(color, bold));
+ SetConsoleTextAttribute(console.handle, Attributes(color, bold));
fflush(file);
}
}
@@ -116,7 +116,7 @@
} // namespace
-std::unique_ptr<Printer> Printer::create(FILE* out, bool use_colors) {
+std::unique_ptr<Printer> Printer::Create(FILE* out, bool use_colors) {
return std::make_unique<PrinterWindows>(out, use_colors);
}
diff --git a/src/tint/utils/result/result.cc b/src/tint/utils/result/result.cc
index 2450bee..016e2fb 100644
--- a/src/tint/utils/result/result.cc
+++ b/src/tint/utils/result/result.cc
@@ -32,7 +32,7 @@
Failure::Failure() = default;
Failure::Failure(std::string_view err) {
- reason.add_error(diag::System::Unknown, err, Source{});
+ reason.AddError(diag::System::Unknown, err, Source{});
}
Failure::Failure(diag::Diagnostic diagnostic) : reason(diag::List{std::move(diagnostic)}) {}