Tweak liveness analysis for if-else chains

This commit is contained in:
Nigel Tao committed 2022-01-25 19:40:22 +11:00
1 parent 14f5859311
commit 97eb1290f5
3 files changed
+12 -13

No files matched your search

+7 -1
View File
@@ -349,7 +349,7 @@ func (h *livenessHelper) doIOManip(r livenesses, n *a.IOManip, depth uint32) err
func (h *livenessHelper) doIf(r livenesses, n *a.If, depth uint32) error {
scratch := make(livenesses, len(r))
result := make(livenesses, len(r))
for ; n != nil; n = n.ElseIf() {
for {
if err := h.doExpr(r, n.Condition()); err != nil {
return err
}
@@ -360,11 +360,17 @@ func (h *livenessHelper) doIf(r livenesses, n *a.If, depth uint32) error {
}
result.reconcile(scratch)
if ei := n.ElseIf(); ei != nil {
n = ei
continue
}
copy(scratch, r)
if err := h.doBlock(scratch, n.BodyIfFalse(), depth); err != nil {
return err
}
result.reconcile(scratch)
break
}
copy(r, result)
return nil
+5
View File
@@ -121,6 +121,11 @@ func (q *checker) tcheckStatement(n *a.Node) error {
}
case a.KIf:
for n := n.AsIf(); n != nil; n = n.ElseIf() {
if (n.ElseIf() != nil) && (len(n.BodyIfFalse()) > 0) {
return fmt.Errorf("check: if has an else-if and an else-not-if")
}
}
for n := n.AsIf(); n != nil; n = n.ElseIf() {
cond := n.Condition()
if cond.Effect() != 0 {
-12
View File
@@ -6634,7 +6634,6 @@ struct wuffs_bmp__decoder__struct {
uint64_t scratch;
} s_decode_image_config[1];
struct {
wuffs_base__status v_status;
uint64_t scratch;
} s_decode_frame[1];
struct {
@@ -8514,9 +8513,6 @@ struct wuffs_json__decoder__struct {
uint32_t v_expect;
uint32_t v_expect_after_value;
} s_decode_tokens[1];
struct {
uint32_t v_neg;
} s_decode_inf_nan[1];
} private_data;
#ifdef __cplusplus
@@ -23384,9 +23380,6 @@ wuffs_bmp__decoder__decode_frame(
}
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
if (coro_susp_point) {
v_status = self->private_data.s_decode_frame[0].v_status;
}
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -23513,7 +23506,6 @@ wuffs_bmp__decoder__decode_frame(
suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
self->private_data.s_decode_frame[0].v_status = v_status;
goto exit;
exit:
@@ -34278,9 +34270,6 @@ wuffs_json__decoder__decode_inf_nan(
}
uint32_t coro_susp_point = self->private_impl.p_decode_inf_nan[0];
if (coro_susp_point) {
v_neg = self->private_data.s_decode_inf_nan[0].v_neg;
}
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -34388,7 +34377,6 @@ wuffs_json__decoder__decode_inf_nan(
goto suspend;
suspend:
self->private_impl.p_decode_inf_nan[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_data.s_decode_inf_nan[0].v_neg = v_neg;
goto exit;
exit: