Fixup IntLiteral names.

This CL fixes the IntLiteral name to contain the type of the literal.
This keeps i32 and u32 from fighting over a given name. Now, the name
ends up being __int__i32_0 instead of __int_0.

Change-Id: Ifb9f0516139d25f34312c75c77318eccbe076ef8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20941
Reviewed-by: David Neto <dneto@google.com>
diff --git a/src/ast/int_literal.cc b/src/ast/int_literal.cc
index 54f13d2..30a4676 100644
--- a/src/ast/int_literal.cc
+++ b/src/ast/int_literal.cc
@@ -31,7 +31,7 @@
 }
 
 std::string IntLiteral::name() const {
-  return "__int" + std::to_string(value_);
+  return "__int" + type()->type_name() + "_" + std::to_string(value_);
 }
 
 }  // namespace ast
diff --git a/src/ast/int_literal_test.cc b/src/ast/int_literal_test.cc
index 42ca665..f3f9f81 100644
--- a/src/ast/int_literal_test.cc
+++ b/src/ast/int_literal_test.cc
@@ -16,6 +16,7 @@
 
 #include "gtest/gtest.h"
 #include "src/ast/type/i32_type.h"
+#include "src/ast/type/u32_type.h"
 
 namespace tint {
 namespace ast {
@@ -46,6 +47,17 @@
   EXPECT_EQ(i.to_str(), "-42");
 }
 
+TEST_F(IntLiteralTest, Name_I32) {
+  ast::type::I32Type i32;
+  IntLiteral i{&i32, 2};
+  EXPECT_EQ("__int__i32_2", i.name());
+}
+
+TEST_F(IntLiteralTest, Name_U32) {
+  ast::type::U32Type u32;
+  IntLiteral i{&u32, 2};
+  EXPECT_EQ("__int__u32_2", i.name());
+}
 }  // namespace
 }  // namespace ast
 }  // namespace tint
diff --git a/src/writer/spirv/builder_accessor_expression_test.cc b/src/writer/spirv/builder_accessor_expression_test.cc
index 4d78d1d..182110f 100644
--- a/src/writer/spirv/builder_accessor_expression_test.cc
+++ b/src/writer/spirv/builder_accessor_expression_test.cc
@@ -897,7 +897,7 @@
   b.push_function(Function{});
   ASSERT_TRUE(b.GenerateFunctionVariable(&var)) << b.error();
 
-  EXPECT_EQ(b.GenerateAccessorExpression(&expr), 19u);
+  EXPECT_EQ(b.GenerateAccessorExpression(&expr), 21u);
 
   EXPECT_EQ(DumpInstructions(b.types()), R"(%9 = OpTypeFloat 32
 %8 = OpTypeVector %9 3
@@ -912,16 +912,18 @@
 %2 = OpTypePointer Function %3
 %13 = OpTypeInt 32 1
 %14 = OpConstant %13 0
-%15 = OpTypePointer Function %8
-%17 = OpTypeVector %9 2
+%15 = OpConstant %10 0
+%16 = OpConstant %13 2
+%17 = OpTypePointer Function %8
+%19 = OpTypeVector %9 2
 )");
   EXPECT_EQ(DumpInstructions(b.functions()[0].variables()),
             R"(%1 = OpVariable %2 Function
 )");
   EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
-            R"(%16 = OpAccessChain %15 %1 %14 %14 %12 %14 %14
-%18 = OpLoad %8 %16
-%19 = OpVectorShuffle %17 %18 %18 1 0
+            R"(%18 = OpAccessChain %17 %1 %14 %15 %16 %15 %15
+%20 = OpLoad %8 %18
+%21 = OpVectorShuffle %19 %20 %20 1 0
 )");
 }