Fix type conversions to make Clang 10 happy

Change-Id: I07f30e9bb19e3f7b0486c982bb3c4406a03dd615
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20161
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ryan Harrison 2020-04-22 17:46:36 +00:00
parent 20077b7b87
commit fd1526bd33
2 changed files with 13 additions and 7 deletions

View File

@ -54,8 +54,9 @@ uint32_t Operand::length() const {
break;
case Kind::kString:
// SPIR-V always nul-terminates strings. The length is rounded up to a
// multiple of 4 bytes with 0 bytes padding the end.
val = static_cast<uint32_t>(ceil((str_val_.length() + 1) / 4.0));
// multiple of 4 bytes with 0 bytes padding the end. Accounting for the
// nul terminator is why '+ 4u' is used here instead of '+ 3u'.
val = static_cast<uint32_t>((str_val_.length() + 4u) >> 2);
break;
}
return val;

View File

@ -165,8 +165,10 @@ TEST_F(GeneratorImplTest, EmitConstructor_Type_Mat) {
ast::ExpressionList mat_values;
for (size_t i = 0; i < 3; i++) {
auto lit1 = std::make_unique<ast::FloatLiteral>(&f32, 1.f + (i * 2));
auto lit2 = std::make_unique<ast::FloatLiteral>(&f32, 2.f + (i * 2));
auto lit1 = std::make_unique<ast::FloatLiteral>(
&f32, static_cast<float>(1 + (i * 2)));
auto lit2 = std::make_unique<ast::FloatLiteral>(
&f32, static_cast<float>(2 + (i * 2)));
ast::ExpressionList values;
values.push_back(
@ -196,9 +198,12 @@ TEST_F(GeneratorImplTest, EmitConstructor_Type_Array) {
ast::ExpressionList ary_values;
for (size_t i = 0; i < 3; i++) {
auto lit1 = std::make_unique<ast::FloatLiteral>(&f32, 1.f + (i * 3));
auto lit2 = std::make_unique<ast::FloatLiteral>(&f32, 2.f + (i * 3));
auto lit3 = std::make_unique<ast::FloatLiteral>(&f32, 3.f + (i * 3));
auto lit1 = std::make_unique<ast::FloatLiteral>(
&f32, static_cast<float>(1 + (i * 3)));
auto lit2 = std::make_unique<ast::FloatLiteral>(
&f32, static_cast<float>(2 + (i * 3)));
auto lit3 = std::make_unique<ast::FloatLiteral>(
&f32, static_cast<float>(3 + (i * 3)));
ast::ExpressionList values;
values.push_back(