Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: pkg/compiler/lib/src/ssa/builder_kernel.dart

Issue 3003283003: Handle missing break in last switch case (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/js_model/locals.dart ('k') | tests/compiler/dart2js/kernel/switch_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/builder_kernel.dart
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index 75547da496dc779ee7908395b4493269eeebee09..63693bb3778341f78248442f166532f75cdd2378 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -1869,6 +1869,14 @@ class KernelSsaGraphBuilder extends ir.Visitor
open(block);
localsHandler = new LocalsHandler.from(savedLocals);
buildSwitchCase(switchCase);
+ if (!isAborted() &&
+ switchCase == switchCases.last &&
+ !isDefaultCase(switchCase)) {
+ // If there is no default, we will add one later to avoid
+ // the critical edge. So we generate a break statement to make
+ // sure the last case does not fall through to the default case.
+ jumpHandler.generateBreak();
+ }
statements.add(
new HSubGraphBlockInformation(new SubGraph(block, lastOpenedBlock)));
}
« no previous file with comments | « pkg/compiler/lib/src/js_model/locals.dart ('k') | tests/compiler/dart2js/kernel/switch_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698