Import Tint changes from Dawn

Changes:
  - d7d71889d82bb5073d420cc11d16fd29346cd9d7 tint: Add FriendlyName() to Program by Ben Clayton <bclayton@google.com>
  - 0cd830c5718ff942c817319e8b399722eb9d6be2 tint: Fix type is_signed_integer helpers which were ignor... by Ben Clayton <bclayton@google.com>
GitOrigin-RevId: d7d71889d82bb5073d420cc11d16fd29346cd9d7
Change-Id: Ib9fbe889105224eeb680d2eff647f28d83b9cb31
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/101360
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/program.cc b/src/tint/program.cc
index 6109c20..e4caca1 100644
--- a/src/tint/program.cc
+++ b/src/tint/program.cc
@@ -130,6 +130,19 @@
     return Sem().Get(type_decl);
 }
 
+std::string Program::FriendlyName(const ast::Type* type) const {
+    TINT_ASSERT_PROGRAM_IDS_EQUAL(Program, type, ID());
+    return type ? type->FriendlyName(Symbols()) : "<null>";
+}
+
+std::string Program::FriendlyName(const sem::Type* type) const {
+    return type ? type->FriendlyName(Symbols()) : "<null>";
+}
+
+std::string Program::FriendlyName(std::nullptr_t) const {
+    return "<null>";
+}
+
 void Program::AssertNotMoved() const {
     TINT_ASSERT(Program, !moved_);
 }
diff --git a/src/tint/program.h b/src/tint/program.h
index b482f90..3390920 100644
--- a/src/tint/program.h
+++ b/src/tint/program.h
@@ -151,6 +151,21 @@
     /// the type declaration has no resolved type.
     const sem::Type* TypeOf(const ast::TypeDecl* type_decl) const;
 
+    /// @param type a type
+    /// @returns the name for `type` that closely resembles how it would be
+    /// declared in WGSL.
+    std::string FriendlyName(const ast::Type* type) const;
+
+    /// @param type a type
+    /// @returns the name for `type` that closely resembles how it would be
+    /// declared in WGSL.
+    std::string FriendlyName(const sem::Type* type) const;
+
+    /// Overload of FriendlyName, which removes an ambiguity when passing nullptr.
+    /// Simplifies test code.
+    /// @returns "<null>"
+    std::string FriendlyName(std::nullptr_t) const;
+
     /// A function that can be used to print a program
     using Printer = std::string (*)(const Program*);
 
diff --git a/src/tint/program_builder.cc b/src/tint/program_builder.cc
index 443be11..a45d805 100644
--- a/src/tint/program_builder.cc
+++ b/src/tint/program_builder.cc
@@ -113,6 +113,19 @@
     return Sem().Get(type_decl);
 }
 
+std::string ProgramBuilder::FriendlyName(const ast::Type* type) const {
+    TINT_ASSERT_PROGRAM_IDS_EQUAL(ProgramBuilder, type, ID());
+    return type ? type->FriendlyName(Symbols()) : "<null>";
+}
+
+std::string ProgramBuilder::FriendlyName(const sem::Type* type) const {
+    return type ? type->FriendlyName(Symbols()) : "<null>";
+}
+
+std::string ProgramBuilder::FriendlyName(std::nullptr_t) const {
+    return "<null>";
+}
+
 const ast::TypeName* ProgramBuilder::TypesBuilder::Of(const ast::TypeDecl* decl) const {
     return type_name(decl->name);
 }
diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h
index 0af3a90..bdd2807 100644
--- a/src/tint/program_builder.h
+++ b/src/tint/program_builder.h
@@ -3110,21 +3110,17 @@
     /// @param type a type
     /// @returns the name for `type` that closely resembles how it would be
     /// declared in WGSL.
-    std::string FriendlyName(const ast::Type* type) {
-        return type ? type->FriendlyName(Symbols()) : "<null>";
-    }
+    std::string FriendlyName(const ast::Type* type) const;
 
     /// @param type a type
     /// @returns the name for `type` that closely resembles how it would be
     /// declared in WGSL.
-    std::string FriendlyName(const sem::Type* type) {
-        return type ? type->FriendlyName(Symbols()) : "<null>";
-    }
+    std::string FriendlyName(const sem::Type* type) const;
 
     /// Overload of FriendlyName, which removes an ambiguity when passing nullptr.
     /// Simplifies test code.
     /// @returns "<null>"
-    std::string FriendlyName(std::nullptr_t) { return "<null>"; }
+    std::string FriendlyName(std::nullptr_t) const;
 
     /// Wraps the ast::Expression in a statement. This is used by tests that
     /// construct a partial AST and require the Resolver to reach these
diff --git a/src/tint/sem/type.cc b/src/tint/sem/type.cc
index b4887dd..ccc4141 100644
--- a/src/tint/sem/type.cc
+++ b/src/tint/sem/type.cc
@@ -105,7 +105,7 @@
 }
 
 bool Type::is_signed_integer_scalar() const {
-    return Is<I32>();
+    return IsAnyOf<I32, AbstractInt>();
 }
 
 bool Type::is_unsigned_integer_scalar() const {
@@ -113,7 +113,7 @@
 }
 
 bool Type::is_signed_integer_vector() const {
-    return Is([](const Vector* v) { return v->type()->IsAnyOf<I32>(); });
+    return Is([](const Vector* v) { return v->type()->IsAnyOf<I32, AbstractInt>(); });
 }
 
 bool Type::is_unsigned_integer_vector() const {
@@ -125,7 +125,7 @@
 }
 
 bool Type::is_signed_scalar_or_vector() const {
-    return Is<I32>() || is_signed_integer_vector();
+    return IsAnyOf<I32, AbstractInt>() || is_signed_integer_vector();
 }
 
 bool Type::is_integer_scalar_or_vector() const {
diff --git a/src/tint/transform/std140.cc b/src/tint/transform/std140.cc
index 57da4da..92d3d8b 100644
--- a/src/tint/transform/std140.cc
+++ b/src/tint/transform/std140.cc
@@ -518,7 +518,7 @@
             },
             [&](Default) {
                 TINT_ICE(Transform, b.Diagnostics())
-                    << "unhandled type for conversion name: " << b.FriendlyName(ty);
+                    << "unhandled type for conversion name: " << ctx.src->FriendlyName(ty);
                 return "";
             });
     }
@@ -600,7 +600,7 @@
                 },
                 [&](Default) {
                     TINT_ICE(Transform, b.Diagnostics())
-                        << "unhandled type for conversion: " << b.FriendlyName(ty);
+                        << "unhandled type for conversion: " << ctx.src->FriendlyName(ty);
                 });
 
             // Generate the function
@@ -879,7 +879,7 @@
                 },  //
                 [&](Default) -> ExprTypeName {
                     TINT_ICE(Transform, b.Diagnostics())
-                        << "unhandled type for access chain: " << b.FriendlyName(ty);
+                        << "unhandled type for access chain: " << ctx.src->FriendlyName(ty);
                     return {};
                 });
         }
@@ -900,7 +900,7 @@
                 },  //
                 [&](Default) -> ExprTypeName {
                     TINT_ICE(Transform, b.Diagnostics())
-                        << "unhandled type for access chain: " << b.FriendlyName(ty);
+                        << "unhandled type for access chain: " << ctx.src->FriendlyName(ty);
                     return {};
                 });
         }
@@ -929,7 +929,7 @@
             },  //
             [&](Default) -> ExprTypeName {
                 TINT_ICE(Transform, b.Diagnostics())
-                    << "unhandled type for access chain: " << b.FriendlyName(ty);
+                    << "unhandled type for access chain: " << ctx.src->FriendlyName(ty);
                 return {};
             });
     }