Change emitted name for `StageAttribute`.

There is no longer a specific `@stage` attribute in WGSL. Instead each
of the `@compute`, `@vertex` or `@fragment` attributes are used.
Internally they collapse into a `StageAttribute` object. Instead of
emitting `stage` as the name of the attribute, emit the specific name
for the pipeline stage used. This closer matches what was in the WGSL
file.

Bug: tint:1832
Change-Id: I6081f49c89fcfc9ee33bbb46ec85cedddeaf027d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/180120
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/lang/wgsl/ast/stage_attribute.cc b/src/tint/lang/wgsl/ast/stage_attribute.cc
index 8369fa6..f3d8da9 100644
--- a/src/tint/lang/wgsl/ast/stage_attribute.cc
+++ b/src/tint/lang/wgsl/ast/stage_attribute.cc
@@ -42,6 +42,16 @@
 StageAttribute::~StageAttribute() = default;
 
 std::string StageAttribute::Name() const {
+    switch (stage) {
+        case PipelineStage::kVertex:
+            return "vertex";
+        case PipelineStage::kFragment:
+            return "fragment";
+        case PipelineStage::kCompute:
+            return "compute";
+        case PipelineStage::kNone:
+            break;
+    }
     return "stage";
 }
 
diff --git a/src/tint/lang/wgsl/resolver/attribute_validation_test.cc b/src/tint/lang/wgsl/resolver/attribute_validation_test.cc
index a36e21f..0554f9a 100644
--- a/src/tint/lang/wgsl/resolver/attribute_validation_test.cc
+++ b/src/tint/lang/wgsl/resolver/attribute_validation_test.cc
@@ -106,7 +106,7 @@
         case AttributeKind::kSize:
             return o << "@size";
         case AttributeKind::kStageCompute:
-            return o << "@stage(compute)";
+            return o << "@compute";
         case AttributeKind::kStride:
             return o << "@stride";
         case AttributeKind::kWorkgroupSize:
@@ -192,7 +192,7 @@
             },
             TestParams{
                 {AttributeKind::kStageCompute},
-                "1:2 error: '@stage' is not valid for " + thing,
+                "1:2 error: '@compute' is not valid for " + thing,
             },
             TestParams{
                 {AttributeKind::kStride},
@@ -547,7 +547,7 @@
         },
         TestParams{
             {AttributeKind::kStageCompute},
-            R"(1:2 error: '@stage' is not valid for function parameters)",
+            R"(1:2 error: '@compute' is not valid for function parameters)",
         },
         TestParams{
             {AttributeKind::kStride},
@@ -632,7 +632,7 @@
         },
         TestParams{
             {AttributeKind::kStageCompute},
-            R"(1:2 error: '@stage' is not valid for non-entry point function return types)",
+            R"(1:2 error: '@compute' is not valid for non-entry point function return types)",
         },
         TestParams{
             {AttributeKind::kStride},
@@ -722,7 +722,7 @@
         },
         TestParams{
             {AttributeKind::kStageCompute},
-            R"(1:2 error: '@stage' is not valid for function parameters)",
+            R"(1:2 error: '@compute' is not valid for function parameters)",
         },
         TestParams{
             {AttributeKind::kStride},
@@ -823,7 +823,7 @@
         },
         TestParams{
             {AttributeKind::kStageCompute},
-            R"(1:2 error: '@stage' is not valid for function parameters)",
+            R"(1:2 error: '@compute' is not valid for function parameters)",
         },
         TestParams{
             {AttributeKind::kStride},
@@ -930,7 +930,7 @@
         },
         TestParams{
             {AttributeKind::kStageCompute},
-            R"(1:2 error: '@stage' is not valid for function parameters)",
+            R"(1:2 error: '@compute' is not valid for function parameters)",
         },
         TestParams{
             {AttributeKind::kStride},
@@ -1019,7 +1019,7 @@
         },
         TestParams{
             {AttributeKind::kStageCompute},
-            R"(1:2 error: '@stage' is not valid for entry point return types)",
+            R"(1:2 error: '@compute' is not valid for entry point return types)",
         },
         TestParams{
             {AttributeKind::kStride},
@@ -1117,7 +1117,7 @@
         },
         TestParams{
             {AttributeKind::kStageCompute},
-            R"(1:2 error: '@stage' is not valid for entry point return types)",
+            R"(1:2 error: '@compute' is not valid for entry point return types)",
         },
         TestParams{
             {AttributeKind::kStride},
@@ -1218,7 +1218,7 @@
         },
         TestParams{
             {AttributeKind::kStageCompute},
-            R"(1:2 error: '@stage' is not valid for entry point return types)",
+            R"(1:2 error: '@compute' is not valid for entry point return types)",
         },
         TestParams{
             {AttributeKind::kStride},
@@ -1342,7 +1342,7 @@
         },
         TestParams{
             {AttributeKind::kStageCompute},
-            R"(1:2 error: '@stage' is not valid for 'struct' declarations)",
+            R"(1:2 error: '@compute' is not valid for 'struct' declarations)",
         },
         TestParams{
             {AttributeKind::kStride},
@@ -1434,7 +1434,7 @@
         },
         TestParams{
             {AttributeKind::kStageCompute},
-            R"(1:2 error: '@stage' is not valid for 'struct' members)",
+            R"(1:2 error: '@compute' is not valid for 'struct' members)",
         },
         TestParams{
             {AttributeKind::kStride},
@@ -1694,7 +1694,7 @@
                              },
                              TestParams{
                                  {AttributeKind::kStageCompute},
-                                 R"(1:2 error: '@stage' is not valid for 'array' types)",
+                                 R"(1:2 error: '@compute' is not valid for 'array' types)",
                              },
                              TestParams{
                                  {AttributeKind::kStride},
@@ -1785,7 +1785,7 @@
         },
         TestParams{
             {AttributeKind::kStageCompute},
-            R"(1:2 error: '@stage' is not valid for module-scope 'var')",
+            R"(1:2 error: '@compute' is not valid for module-scope 'var')",
         },
         TestParams{
             {AttributeKind::kStride},
@@ -1889,7 +1889,7 @@
         },
         TestParams{
             {AttributeKind::kStageCompute},
-            R"(1:2 error: '@stage' is not valid for 'const' declaration)",
+            R"(1:2 error: '@compute' is not valid for 'const' declaration)",
         },
         TestParams{
             {AttributeKind::kStride},
@@ -1970,7 +1970,7 @@
         },
         TestParams{
             {AttributeKind::kStageCompute},
-            R"(1:2 error: '@stage' is not valid for 'override' declaration)",
+            R"(1:2 error: '@compute' is not valid for 'override' declaration)",
         },
         TestParams{
             {AttributeKind::kStride},
diff --git a/src/tint/lang/wgsl/resolver/function_validation_test.cc b/src/tint/lang/wgsl/resolver/function_validation_test.cc
index 3de0b09..764af82 100644
--- a/src/tint/lang/wgsl/resolver/function_validation_test.cc
+++ b/src/tint/lang/wgsl/resolver/function_validation_test.cc
@@ -456,7 +456,7 @@
 
     EXPECT_FALSE(r()->Resolve());
     EXPECT_EQ(r()->error(),
-              R"(56:78 error: duplicate stage attribute
+              R"(56:78 error: duplicate fragment attribute
 12:34 note: first attribute declared here)");
 }