[ir][validation] Update binary tests to mark undef operands Update the binary validation to emit the operand index for any undef operands so the highlighting works correctly. Bug: tint:1952 Change-Id: I793bfcd496b9ecc76269a614ec62d0073cfa81ab Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/139282 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/ir/disassembler.cc b/src/tint/ir/disassembler.cc index f8e301f..0a747ff 100644 --- a/src/tint/ir/disassembler.cc +++ b/src/tint/ir/disassembler.cc
@@ -738,9 +738,9 @@ break; } out_ << " "; - EmitValue(b->LHS()); + EmitOperand(b, b->LHS(), Binary::kLhsOperandOffset); out_ << ", "; - EmitValue(b->RHS()); + EmitOperand(b, b->RHS(), Binary::kRhsOperandOffset); sm.Store(b); EmitLine();
diff --git a/src/tint/ir/validate.cc b/src/tint/ir/validate.cc index d8871b9..3a11860 100644 --- a/src/tint/ir/validate.cc +++ b/src/tint/ir/validate.cc
@@ -314,10 +314,10 @@ void CheckBinary(ir::Binary* b) { if (b->LHS() == nullptr) { - AddError(b, "binary: left operand is undefined"); + AddError(b, Binary::kLhsOperandOffset, "binary: left operand is undefined"); } if (b->RHS() == nullptr) { - AddError(b, "binary: right operand is undefined"); + AddError(b, Binary::kRhsOperandOffset, "binary: right operand is undefined"); } if (b->Result() == nullptr) { AddError(b, "binary: result is undefined");
diff --git a/src/tint/ir/validate_test.cc b/src/tint/ir/validate_test.cc index 8d696e1..8a8b478 100644 --- a/src/tint/ir/validate_test.cc +++ b/src/tint/ir/validate_test.cc
@@ -767,9 +767,9 @@ auto res = ir::Validate(mod); ASSERT_FALSE(res); - EXPECT_EQ(res.Failure().str(), R"(:3:5 error: binary: left operand is undefined + EXPECT_EQ(res.Failure().str(), R"(:3:18 error: binary: left operand is undefined %2:i32 = add undef, 2i - ^^^^^^^^^^^^^^^^^^^^^^ + ^^^^^ :2:3 note: In block %b1 = block { @@ -795,9 +795,9 @@ auto res = ir::Validate(mod); ASSERT_FALSE(res); - EXPECT_EQ(res.Failure().str(), R"(:3:5 error: binary: right operand is undefined + EXPECT_EQ(res.Failure().str(), R"(:3:22 error: binary: right operand is undefined %2:i32 = add 2i, undef - ^^^^^^^^^^^^^^^^^^^^^^ + ^^^^^ :2:3 note: In block %b1 = block {