tint: Fix Matrix::FriendlyName() for inferred type
The type field may be nullptr when a matrix constructor is used with an inferred element type. Change-Id: Ic11ba6a8efbed2a641c8a5ad3bbf0d074e4ca973 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87280 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: James Price <jrprice@google.com> Auto-Submit: James Price <jrprice@google.com>
This commit is contained in:
parent
13e9699b1c
commit
b6f4c59845
|
@ -39,8 +39,10 @@ Matrix::~Matrix() = default;
|
||||||
|
|
||||||
std::string Matrix::FriendlyName(const SymbolTable& symbols) const {
|
std::string Matrix::FriendlyName(const SymbolTable& symbols) const {
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << "mat" << columns << "x" << rows << "<" << type->FriendlyName(symbols)
|
out << "mat" << columns << "x" << rows;
|
||||||
<< ">";
|
if (type) {
|
||||||
|
out << "<" << type->FriendlyName(symbols) << ">";
|
||||||
|
}
|
||||||
return out.str();
|
return out.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,5 +46,10 @@ TEST_F(AstMatrixTest, FriendlyName) {
|
||||||
EXPECT_EQ(m->FriendlyName(Symbols()), "mat2x3<i32>");
|
EXPECT_EQ(m->FriendlyName(Symbols()), "mat2x3<i32>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(AstMatrixTest, FriendlyName_WithoutType) {
|
||||||
|
auto* m = create<Matrix>(nullptr, 3, 2);
|
||||||
|
EXPECT_EQ(m->FriendlyName(Symbols()), "mat2x3");
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace tint::ast
|
} // namespace tint::ast
|
||||||
|
|
Loading…
Reference in New Issue