[tint][ast] Include WGSL dump in fuzzer ICE message

Change-Id: I1f6dfc57baaffacfe3fdf78446a58f3c34ce441f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/186903
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/lang/wgsl/ast/transform/add_block_attribute_fuzz.cc b/src/tint/lang/wgsl/ast/transform/add_block_attribute_fuzz.cc
index 7898243..b9a5389 100644
--- a/src/tint/lang/wgsl/ast/transform/add_block_attribute_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/add_block_attribute_fuzz.cc
@@ -35,7 +35,9 @@
     DataMap outputs;
     if (auto result = AddBlockAttribute{}.Apply(program, DataMap{}, outputs)) {
         if (!result->IsValid()) {
-            TINT_ICE() << "AddBlockAttribute returned invalid program:\n" << result->Diagnostics();
+            TINT_ICE() << "AddBlockAttribute returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
+                       << result->Diagnostics();
         }
     }
 }
diff --git a/src/tint/lang/wgsl/ast/transform/add_empty_entry_point_fuzz.cc b/src/tint/lang/wgsl/ast/transform/add_empty_entry_point_fuzz.cc
index cee5702..ff81441 100644
--- a/src/tint/lang/wgsl/ast/transform/add_empty_entry_point_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/add_empty_entry_point_fuzz.cc
@@ -35,7 +35,9 @@
     DataMap outputs;
     if (auto result = AddEmptyEntryPoint{}.Apply(program, DataMap{}, outputs)) {
         if (!result->IsValid()) {
-            TINT_ICE() << "AddEmptyEntryPoint returned invalid program:\n" << result->Diagnostics();
+            TINT_ICE() << "AddEmptyEntryPoint returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
+                       << result->Diagnostics();
         }
     }
 }
diff --git a/src/tint/lang/wgsl/ast/transform/array_length_from_uniform_fuzz.cc b/src/tint/lang/wgsl/ast/transform/array_length_from_uniform_fuzz.cc
index 525f57e..7b1f693 100644
--- a/src/tint/lang/wgsl/ast/transform/array_length_from_uniform_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/array_length_from_uniform_fuzz.cc
@@ -72,6 +72,7 @@
     if (auto result = ArrayLengthFromUniform{}.Apply(program, inputs, outputs)) {
         if (!result->IsValid()) {
             TINT_ICE() << "ArrayLengthFromUniform returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
                        << result->Diagnostics();
         }
     }
diff --git a/src/tint/lang/wgsl/ast/transform/binding_remapper_fuzz.cc b/src/tint/lang/wgsl/ast/transform/binding_remapper_fuzz.cc
index 2f27549..071e83d 100644
--- a/src/tint/lang/wgsl/ast/transform/binding_remapper_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/binding_remapper_fuzz.cc
@@ -78,7 +78,9 @@
     DataMap outputs;
     if (auto result = BindingRemapper{}.Apply(program, inputs, outputs)) {
         if (!result->IsValid()) {
-            TINT_ICE() << "BindingRemapper returned invalid program:\n" << result->Diagnostics();
+            TINT_ICE() << "BindingRemapper returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
+                       << result->Diagnostics();
         }
     }
 }
diff --git a/src/tint/lang/wgsl/ast/transform/builtin_polyfill_fuzz.cc b/src/tint/lang/wgsl/ast/transform/builtin_polyfill_fuzz.cc
index adce548..8694e3b 100644
--- a/src/tint/lang/wgsl/ast/transform/builtin_polyfill_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/builtin_polyfill_fuzz.cc
@@ -38,7 +38,9 @@
     DataMap outputs;
     if (auto result = BuiltinPolyfill{}.Apply(program, inputs, outputs)) {
         if (!result->IsValid()) {
-            TINT_ICE() << "BuiltinPolyfill returned invalid program:\n" << result->Diagnostics();
+            TINT_ICE() << "BuiltinPolyfill returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
+                       << result->Diagnostics();
         }
     }
 }
diff --git a/src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io_fuzz.cc b/src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io_fuzz.cc
index 136291a..671a35b 100644
--- a/src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io_fuzz.cc
@@ -40,6 +40,7 @@
     if (auto result = CanonicalizeEntryPointIO{}.Apply(program, inputs, outputs)) {
         if (!result->IsValid()) {
             TINT_ICE() << "CanonicalizeEntryPointIO returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
                        << result->Diagnostics();
         }
     }
diff --git a/src/tint/lang/wgsl/ast/transform/clamp_frag_depth_fuzz.cc b/src/tint/lang/wgsl/ast/transform/clamp_frag_depth_fuzz.cc
index 2854240..6de6553 100644
--- a/src/tint/lang/wgsl/ast/transform/clamp_frag_depth_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/clamp_frag_depth_fuzz.cc
@@ -27,6 +27,7 @@
 
 #include "src/tint/cmd/fuzz/wgsl/fuzz.h"
 #include "src/tint/lang/wgsl/ast/transform/clamp_frag_depth.h"
+#include "src/tint/lang/wgsl/program/program.h"
 
 namespace tint::ast::transform {
 namespace {
@@ -49,7 +50,9 @@
     DataMap outputs;
     if (auto result = ClampFragDepth{}.Apply(program, inputs, outputs)) {
         if (!result->IsValid()) {
-            TINT_ICE() << "ClampFragDepth returned invalid program:\n" << result->Diagnostics();
+            TINT_ICE() << "ClampFragDepth returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
+                       << result->Diagnostics();
         }
     }
 }
diff --git a/src/tint/lang/wgsl/ast/transform/demote_to_helper_fuzz.cc b/src/tint/lang/wgsl/ast/transform/demote_to_helper_fuzz.cc
index 180ab67..16e3833 100644
--- a/src/tint/lang/wgsl/ast/transform/demote_to_helper_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/demote_to_helper_fuzz.cc
@@ -35,7 +35,9 @@
     DataMap outputs;
     if (auto result = DemoteToHelper{}.Apply(program, DataMap{}, outputs)) {
         if (!result->IsValid()) {
-            TINT_ICE() << "DemoteToHelper returned invalid program:\n" << result->Diagnostics();
+            TINT_ICE() << "DemoteToHelper returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
+                       << result->Diagnostics();
         }
     }
 }
diff --git a/src/tint/lang/wgsl/ast/transform/direct_variable_access_fuzz.cc b/src/tint/lang/wgsl/ast/transform/direct_variable_access_fuzz.cc
index 5123798..e1d1893 100644
--- a/src/tint/lang/wgsl/ast/transform/direct_variable_access_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/direct_variable_access_fuzz.cc
@@ -40,6 +40,7 @@
     if (auto result = DirectVariableAccess{}.Apply(program, inputs, outputs)) {
         if (!result->IsValid()) {
             TINT_ICE() << "DirectVariableAccess returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
                        << result->Diagnostics();
         }
     }
diff --git a/src/tint/lang/wgsl/ast/transform/disable_uniformity_analysis_fuzz.cc b/src/tint/lang/wgsl/ast/transform/disable_uniformity_analysis_fuzz.cc
index 378eb5f..1f5e153 100644
--- a/src/tint/lang/wgsl/ast/transform/disable_uniformity_analysis_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/disable_uniformity_analysis_fuzz.cc
@@ -36,6 +36,7 @@
     if (auto result = DisableUniformityAnalysis{}.Apply(program, DataMap{}, outputs)) {
         if (!result->IsValid()) {
             TINT_ICE() << "DisableUniformityAnalysis returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
                        << result->Diagnostics();
         }
     }
diff --git a/src/tint/lang/wgsl/ast/transform/expand_compound_assignment_fuzz.cc b/src/tint/lang/wgsl/ast/transform/expand_compound_assignment_fuzz.cc
index d017dbb..7776590 100644
--- a/src/tint/lang/wgsl/ast/transform/expand_compound_assignment_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/expand_compound_assignment_fuzz.cc
@@ -36,6 +36,7 @@
     if (auto result = ExpandCompoundAssignment{}.Apply(program, DataMap{}, outputs)) {
         if (!result->IsValid()) {
             TINT_ICE() << "ExpandCompoundAssignment returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
                        << result->Diagnostics();
         }
     }
diff --git a/src/tint/lang/wgsl/ast/transform/first_index_offset_fuzz.cc b/src/tint/lang/wgsl/ast/transform/first_index_offset_fuzz.cc
index b7ed12e..2f3a607 100644
--- a/src/tint/lang/wgsl/ast/transform/first_index_offset_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/first_index_offset_fuzz.cc
@@ -59,7 +59,9 @@
     DataMap outputs;
     if (auto result = FirstIndexOffset{}.Apply(program, inputs, outputs)) {
         if (!result->IsValid()) {
-            TINT_ICE() << "FirstIndexOffset returned invalid program:\n" << result->Diagnostics();
+            TINT_ICE() << "FirstIndexOffset returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
+                       << result->Diagnostics();
         }
     }
 }
diff --git a/src/tint/lang/wgsl/ast/transform/fold_constants_fuzz.cc b/src/tint/lang/wgsl/ast/transform/fold_constants_fuzz.cc
index 4c48a90..668f7a5 100644
--- a/src/tint/lang/wgsl/ast/transform/fold_constants_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/fold_constants_fuzz.cc
@@ -35,7 +35,9 @@
     DataMap outputs;
     if (auto result = FoldConstants{}.Apply(program, DataMap{}, outputs)) {
         if (!result->IsValid()) {
-            TINT_ICE() << "FoldConstants returned invalid program:\n" << result->Diagnostics();
+            TINT_ICE() << "FoldConstants returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
+                       << result->Diagnostics();
         }
     }
 }
diff --git a/src/tint/lang/wgsl/ast/transform/multiplanar_external_texture_fuzz.cc b/src/tint/lang/wgsl/ast/transform/multiplanar_external_texture_fuzz.cc
index caddb35..4c6efeb 100644
--- a/src/tint/lang/wgsl/ast/transform/multiplanar_external_texture_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/multiplanar_external_texture_fuzz.cc
@@ -95,6 +95,7 @@
     if (auto result = MultiplanarExternalTexture{}.Apply(program, inputs, outputs)) {
         if (!result->IsValid()) {
             TINT_ICE() << "MultiplanarExternalTexture returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
                        << result->Diagnostics();
         }
     }
diff --git a/src/tint/lang/wgsl/ast/transform/offset_first_index_fuzz.cc b/src/tint/lang/wgsl/ast/transform/offset_first_index_fuzz.cc
index 04c13a2..f4c9faf 100644
--- a/src/tint/lang/wgsl/ast/transform/offset_first_index_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/offset_first_index_fuzz.cc
@@ -55,7 +55,9 @@
     DataMap outputs;
     if (auto result = OffsetFirstIndex{}.Apply(program, inputs, outputs)) {
         if (!result->IsValid()) {
-            TINT_ICE() << "OffsetFirstIndex returned invalid program:\n" << result->Diagnostics();
+            TINT_ICE() << "OffsetFirstIndex returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
+                       << result->Diagnostics();
         }
     }
 }
diff --git a/src/tint/lang/wgsl/ast/transform/preserve_padding_fuzz.cc b/src/tint/lang/wgsl/ast/transform/preserve_padding_fuzz.cc
index 486a65a..963da24 100644
--- a/src/tint/lang/wgsl/ast/transform/preserve_padding_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/preserve_padding_fuzz.cc
@@ -35,7 +35,9 @@
     DataMap outputs;
     if (auto result = PreservePadding{}.Apply(program, DataMap{}, outputs)) {
         if (!result->IsValid()) {
-            TINT_ICE() << "PreservePadding returned invalid program:\n" << result->Diagnostics();
+            TINT_ICE() << "PreservePadding returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
+                       << result->Diagnostics();
         }
     }
 }
diff --git a/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let_fuzz.cc b/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let_fuzz.cc
index bf928e6..ed3518f 100644
--- a/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let_fuzz.cc
@@ -36,6 +36,7 @@
     if (auto result = PromoteInitializersToLet{}.Apply(program, DataMap{}, outputs)) {
         if (!result->IsValid()) {
             TINT_ICE() << "PromoteInitializersToLet returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
                        << result->Diagnostics();
         }
     }
diff --git a/src/tint/lang/wgsl/ast/transform/promote_side_effects_to_decl_fuzz.cc b/src/tint/lang/wgsl/ast/transform/promote_side_effects_to_decl_fuzz.cc
index 57a15f8..423d3ed 100644
--- a/src/tint/lang/wgsl/ast/transform/promote_side_effects_to_decl_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/promote_side_effects_to_decl_fuzz.cc
@@ -54,6 +54,7 @@
     if (auto result = PromoteSideEffectsToDecl{}.Apply(program, DataMap{}, outputs)) {
         if (!result->IsValid()) {
             TINT_ICE() << "PromoteSideEffectsToDecl returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
                        << result->Diagnostics();
         }
     }
diff --git a/src/tint/lang/wgsl/ast/transform/remove_continue_in_switch_fuzz.cc b/src/tint/lang/wgsl/ast/transform/remove_continue_in_switch_fuzz.cc
index 049b57c..b49f1ed 100644
--- a/src/tint/lang/wgsl/ast/transform/remove_continue_in_switch_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/remove_continue_in_switch_fuzz.cc
@@ -36,6 +36,7 @@
     if (auto result = RemoveContinueInSwitch{}.Apply(program, DataMap{}, outputs)) {
         if (!result->IsValid()) {
             TINT_ICE() << "RemoveContinueInSwitch returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
                        << result->Diagnostics();
         }
     }
diff --git a/src/tint/lang/wgsl/ast/transform/remove_phonies_fuzz.cc b/src/tint/lang/wgsl/ast/transform/remove_phonies_fuzz.cc
index 92faf38..823fc6f 100644
--- a/src/tint/lang/wgsl/ast/transform/remove_phonies_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/remove_phonies_fuzz.cc
@@ -35,7 +35,9 @@
     DataMap outputs;
     if (auto result = RemovePhonies{}.Apply(program, DataMap{}, outputs)) {
         if (!result->IsValid()) {
-            TINT_ICE() << "RemovePhonies returned invalid program:\n" << result->Diagnostics();
+            TINT_ICE() << "RemovePhonies returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
+                       << result->Diagnostics();
         }
     }
 }
diff --git a/src/tint/lang/wgsl/ast/transform/remove_unreachable_statements_fuzz.cc b/src/tint/lang/wgsl/ast/transform/remove_unreachable_statements_fuzz.cc
index c61d8aa..c803823 100644
--- a/src/tint/lang/wgsl/ast/transform/remove_unreachable_statements_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/remove_unreachable_statements_fuzz.cc
@@ -52,6 +52,7 @@
     if (auto result = RemoveUnreachableStatements{}.Apply(program, DataMap{}, outputs)) {
         if (!result->IsValid()) {
             TINT_ICE() << "RemoveUnreachableStatements returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
                        << result->Diagnostics();
         }
     }
diff --git a/src/tint/lang/wgsl/ast/transform/single_entry_point_fuzz.cc b/src/tint/lang/wgsl/ast/transform/single_entry_point_fuzz.cc
index 5cec2bb..5df7964 100644
--- a/src/tint/lang/wgsl/ast/transform/single_entry_point_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/single_entry_point_fuzz.cc
@@ -56,7 +56,9 @@
     DataMap outputs;
     if (auto result = SingleEntryPoint{}.Apply(program, inputs, outputs)) {
         if (!result->IsValid()) {
-            TINT_ICE() << "SingleEntryPoint returned invalid program:\n" << result->Diagnostics();
+            TINT_ICE() << "SingleEntryPoint returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
+                       << result->Diagnostics();
         }
     }
 }
diff --git a/src/tint/lang/wgsl/ast/transform/std140_fuzz.cc b/src/tint/lang/wgsl/ast/transform/std140_fuzz.cc
index aedf74c..3606f96 100644
--- a/src/tint/lang/wgsl/ast/transform/std140_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/std140_fuzz.cc
@@ -57,7 +57,9 @@
     DataMap outputs;
     if (auto result = Std140{}.Apply(program, DataMap{}, outputs)) {
         if (!result->IsValid()) {
-            TINT_ICE() << "Std140 returned invalid program:\n" << result->Diagnostics();
+            TINT_ICE() << "Std140 returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
+                       << result->Diagnostics();
         }
     }
 }
diff --git a/src/tint/lang/wgsl/ast/transform/unshadow_fuzz.cc b/src/tint/lang/wgsl/ast/transform/unshadow_fuzz.cc
index 064ffaf..752a501 100644
--- a/src/tint/lang/wgsl/ast/transform/unshadow_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/unshadow_fuzz.cc
@@ -35,7 +35,9 @@
     DataMap outputs;
     if (auto result = Unshadow{}.Apply(program, DataMap{}, outputs)) {
         if (!result->IsValid()) {
-            TINT_ICE() << "Unshadow returned invalid program:\n" << result->Diagnostics();
+            TINT_ICE() << "Unshadow returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
+                       << result->Diagnostics();
         }
     }
 }
diff --git a/src/tint/lang/wgsl/ast/transform/vectorize_scalar_matrix_initializers_fuzz.cc b/src/tint/lang/wgsl/ast/transform/vectorize_scalar_matrix_initializers_fuzz.cc
index 407538c..f1c6e2d 100644
--- a/src/tint/lang/wgsl/ast/transform/vectorize_scalar_matrix_initializers_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/vectorize_scalar_matrix_initializers_fuzz.cc
@@ -36,6 +36,7 @@
     if (auto result = VectorizeScalarMatrixInitializers{}.Apply(program, DataMap{}, outputs)) {
         if (!result->IsValid()) {
             TINT_ICE() << "VectorizeScalarMatrixInitializers returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
                        << result->Diagnostics();
         }
     }
diff --git a/src/tint/lang/wgsl/ast/transform/zero_init_workgroup_memory_fuzz.cc b/src/tint/lang/wgsl/ast/transform/zero_init_workgroup_memory_fuzz.cc
index 2e3650d..b9c569d 100644
--- a/src/tint/lang/wgsl/ast/transform/zero_init_workgroup_memory_fuzz.cc
+++ b/src/tint/lang/wgsl/ast/transform/zero_init_workgroup_memory_fuzz.cc
@@ -41,6 +41,7 @@
     if (auto result = ZeroInitWorkgroupMemory{}.Apply(program, DataMap{}, outputs)) {
         if (!result->IsValid()) {
             TINT_ICE() << "ZeroInitWorkgroupMemory returned invalid program:\n"
+                       << Program::printer(*result) << "\n"
                        << result->Diagnostics();
         }
     }