From c759b73b24fbba997012a6d4a60e67b85e1901a2 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 21 Nov 2012 12:23:15 +0900 Subject: [PATCH] Cope with empty sblocks when producing dot graphs. --- tools/qfcc/source/dot_sblock.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tools/qfcc/source/dot_sblock.c b/tools/qfcc/source/dot_sblock.c index 014205e02..ab42916be 100644 --- a/tools/qfcc/source/dot_sblock.c +++ b/tools/qfcc/source/dot_sblock.c @@ -94,15 +94,22 @@ flow_sblock (dstring_t *dstr, sblock_t *sblock, int blockno) dasprintf (dstr, " \n"); dasprintf (dstr, " \n"); dasprintf (dstr, " >];\n"); - if (sblock->next && !flow_is_goto ((statement_t *) sblock->tail) - && !flow_is_jumpb ((statement_t *) sblock->tail) - && !flow_is_return ((statement_t *) sblock->tail)) - dasprintf (dstr, " sb_%p:e -> sb_%p:s;\n", sblock, sblock->next); - if ((target_list = flow_get_targetlist ((statement_t *) sblock->tail))) { - for (target = target_list; *target; target++) - dasprintf (dstr, " sb_%p:e -> sb_%p:s [label=\"%s\"];\n", sblock, - *target, ((statement_t *) sblock->tail)->opcode); - free (target_list); + if (sblock->statements) { + statement_t *st = (statement_t *) sblock->tail; + if (sblock->next + && !flow_is_goto (st) + && !flow_is_jumpb (st) + && !flow_is_return (st)) + dasprintf (dstr, " sb_%p:e -> sb_%p:s;\n", sblock, sblock->next); + if ((target_list = flow_get_targetlist (st))) { + for (target = target_list; *target; target++) + dasprintf (dstr, " sb_%p:e -> sb_%p:s [label=\"%s\"];\n", + sblock, *target, st->opcode); + free (target_list); + } + } else { + if (sblock->next) + dasprintf (dstr, " sb_%p:e -> sb_%p:s;\n", sblock, sblock->next); } dasprintf (dstr, "\n"); }