tint: show template param when printing initializer overloads with no params

Bug: tint:1732
Change-Id: Ide1d961730638a5c062cc0a8e072c5fb0f0fd9dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107500
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Antonio Maiorano 2022-10-28 02:39:35 +00:00 committed by Dawn LUCI CQ
parent 71111f8e0d
commit e366dcf747
2 changed files with 18 additions and 4 deletions

View File

@ -1653,7 +1653,21 @@ void Impl::PrintOverload(std::ostream& ss,
auto earliest_eval_stage = sem::EvaluationStage::kConstant;
ss << intrinsic_name;
if (overload->flags.Contains(OverloadFlag::kIsConverter) && overload->template_types) {
bool print_template_type = false;
if (overload->num_template_types > 0) {
if (overload->flags.Contains(OverloadFlag::kIsConverter)) {
// Print for conversions
// e.g. vec3<T>(vec3<U>) -> vec3<f32>
print_template_type = true;
} else if ((overload->num_parameters == 0) &&
overload->flags.Contains(OverloadFlag::kIsInitializer)) {
// Print for initializers with no params
// e.g. vec2<T>() -> vec2<T>
print_template_type = true;
}
}
if (print_template_type) {
ss << "<";
ss << overload->template_types[0].name;
ss << ">";

View File

@ -840,7 +840,7 @@ TEST_F(IntrinsicTableTest, MismatchTypeInitializerImplicit) {
vec3(x: T, yz: vec2<T>) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3(T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3(vec3<T>) -> vec3<T> where: T is f32, f16, i32, u32 or bool
vec3() -> vec3<T> where: T is f32, f16, i32, u32 or bool
vec3<T>() -> vec3<T> where: T is f32, f16, i32, u32 or bool
5 candidate conversions:
vec3<T>(vec3<U>) -> vec3<f32> where: T is f32, U is abstract-int, abstract-float, i32, f16, u32 or bool
@ -866,7 +866,7 @@ TEST_F(IntrinsicTableTest, MismatchTypeInitializerExplicit) {
vec3(T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3(xy: vec2<T>, z: T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3(vec3<T>) -> vec3<T> where: T is f32, f16, i32, u32 or bool
vec3() -> vec3<T> where: T is f32, f16, i32, u32 or bool
vec3<T>() -> vec3<T> where: T is f32, f16, i32, u32 or bool
5 candidate conversions:
vec3<T>(vec3<U>) -> vec3<f32> where: T is f32, U is abstract-int, abstract-float, i32, f16, u32 or bool
@ -953,7 +953,7 @@ TEST_F(IntrinsicTableTest, MismatchTypeConversion) {
6 candidate initializers:
vec3(vec3<T>) -> vec3<T> where: T is f32, f16, i32, u32 or bool
vec3(T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3() -> vec3<T> where: T is f32, f16, i32, u32 or bool
vec3<T>() -> vec3<T> where: T is f32, f16, i32, u32 or bool
vec3(xy: vec2<T>, z: T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3(x: T, yz: vec2<T>) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3(x: T, y: T, z: T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool