Remove fallthrough from fuzzer AST mutation.

This CL removes the logic to handle fallthrough in the AST fuzzer.

Bug: tint:1644
Change-Id: Ie636e2377bed8acfd7a644d2af6827efaf37a60e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109000
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
diff --git a/src/tint/fuzzers/tint_ast_fuzzer/mutations/delete_statement.cc b/src/tint/fuzzers/tint_ast_fuzzer/mutations/delete_statement.cc
index 05435d0..1ec3ca4 100644
--- a/src/tint/fuzzers/tint_ast_fuzzer/mutations/delete_statement.cc
+++ b/src/tint/fuzzers/tint_ast_fuzzer/mutations/delete_statement.cc
@@ -19,7 +19,6 @@
 #include <vector>
 
 #include "src/tint/ast/block_statement.h"
-#include "src/tint/ast/fallthrough_statement.h"
 #include "src/tint/ast/for_loop_statement.h"
 #include "src/tint/ast/if_statement.h"
 #include "src/tint/ast/loop_statement.h"
@@ -151,24 +150,9 @@
     }
 
     if (auto* case_statement = statement_node.As<ast::CaseStatement>()) {
-        // It is not OK to delete the final case statement in a switch statement if the penultimate
-        // case statement falls through to the final case statement.
-        auto* switch_statement =
-            program.Sem().Get(case_statement)->Parent()->Declaration()->As<ast::SwitchStatement>();
-
-        if (switch_statement->body.Length() > 1 &&
-            switch_statement->body[switch_statement->body.Length() - 1] == case_statement) {
-            // There are at least two case statements, and this is the final case statement.
-            auto& penultimate_case_statement_body_statements =
-                switch_statement->body[switch_statement->body.Length() - 2]->body->statements;
-            if (penultimate_case_statement_body_statements.Length() > 0 &&
-                penultimate_case_statement_body_statements
-                    [penultimate_case_statement_body_statements.Length() - 1]
-                        ->Is<ast::FallthroughStatement>()) {
-                // The penultimate case statement falls through to the final case statement, thus
-                // the final case statement cannot be removed.
-                return false;
-            }
+        // It is not OK to delete the case statement which contains the default selector.
+        if (case_statement->ContainsDefault()) {
+            return false;
         }
     }
 
diff --git a/src/tint/fuzzers/tint_ast_fuzzer/mutations/delete_statement_test.cc b/src/tint/fuzzers/tint_ast_fuzzer/mutations/delete_statement_test.cc
index 925ee80..275a19e 100644
--- a/src/tint/fuzzers/tint_ast_fuzzer/mutations/delete_statement_test.cc
+++ b/src/tint/fuzzers/tint_ast_fuzzer/mutations/delete_statement_test.cc
@@ -22,7 +22,6 @@
 #include "src/tint/ast/assignment_statement.h"
 #include "src/tint/ast/block_statement.h"
 #include "src/tint/ast/case_statement.h"
-#include "src/tint/ast/fallthrough_statement.h"
 #include "src/tint/ast/for_loop_statement.h"
 #include "src/tint/ast/if_statement.h"
 #include "src/tint/ast/switch_statement.h"
@@ -151,10 +150,7 @@
   switch(1) {
     case 0, 1: {
     }
-    default: {
-      fallthrough;
-    }
-    case 2: {
+    case 2, default: {
     }
   }
 })";
@@ -171,20 +167,14 @@
   switch(1) {
     case 0, 1: {
     }
-    default: {
-      fallthrough;
-    }
-    case 2: {
+    case 2, default: {
     }
   }
 })";
     auto expected = R"(
 fn main() {
   switch(1) {
-    default: {
-      fallthrough;
-    }
-    case 2: {
+    case 2, default: {
     }
   }
 })";
@@ -199,43 +189,6 @@
     CheckStatementDeletionWorks(original, expected, statement_finder);
 }
 
-TEST(DeleteStatementTest, DeleteFallthroughStatement) {
-    auto original = R"(
-fn main() {
-  switch(1) {
-    case 0, 1: {
-    }
-    default: {
-      fallthrough;
-    }
-    case 2: {
-    }
-  }
-})";
-    auto expected = R"(
-fn main() {
-  switch(1) {
-    case 0, 1: {
-    }
-    default: {
-    }
-    case 2: {
-    }
-  }
-})";
-    auto statement_finder = [](const Program& program) -> const ast::Statement* {
-        return program.AST()
-            .Functions()[0]
-            ->body->statements[0]
-            ->As<ast::SwitchStatement>()
-            ->body[1]
-            ->As<ast::CaseStatement>()
-            ->body->statements[0]
-            ->As<ast::FallthroughStatement>();
-    };
-    CheckStatementDeletionWorks(original, expected, statement_finder);
-}
-
 TEST(DeleteStatementTest, DeleteElse) {
     auto original = R"(
 fn main() {
@@ -570,14 +523,11 @@
     CheckStatementDeletionNotAllowed(original, statement_finder);
 }
 
-TEST(DeleteStatementTest, DoNotDeleteCaseDueToFallthrough) {
+TEST(DeleteStatementTest, DoNotDeleteCaseDueToDefault) {
     auto original = R"(
 fn main() {
   switch(1) {
-    default: {
-      fallthrough;
-    }
-    case 2: {
+    case 2, default: {
     }
   }
 })";
@@ -586,7 +536,7 @@
             .Functions()[0]
             ->body->statements[0]
             ->As<ast::SwitchStatement>()
-            ->body[1]
+            ->body[0]
             ->As<ast::CaseStatement>();
     };
     CheckStatementDeletionNotAllowed(original, statement_finder);