Simplify case_label_to_firm() a bit, which can be done since new_immBlock() does...
[cparser] / ast2firm.c
index 0be75e8..a7d60dd 100644 (file)
@@ -4982,18 +4982,13 @@ static void while_statement_to_firm(while_statement_t *statement)
 
 static void do_while_statement_to_firm(do_while_statement_t *statement)
 {
-       ir_node *jmp = NULL;
-       if (get_cur_block() != NULL) {
-               jmp = new_Jmp();
-       }
-
        /* create the header block */
        ir_node *header_block = new_immBlock();
 
        /* the loop body */
        ir_node *body_block = new_immBlock();
-       if (jmp != NULL) {
-               add_immBlock_pred(body_block, jmp);
+       if (get_cur_block() != NULL) {
+               add_immBlock_pred(body_block, new_Jmp());
        }
 
        ir_node *old_continue_label = continue_label;
@@ -5080,28 +5075,23 @@ static void for_statement_to_firm(for_statement_t *statement)
        ir_node *const false_block = new_immBlock();
 
        /* the loop body */
-       ir_node *body_block;
-       if (statement->body != NULL) {
-               ir_node *const old_continue_label = continue_label;
-               ir_node *const old_break_label    = break_label;
-               continue_label = step_block;
-               break_label    = false_block;
-
-               body_block = new_immBlock();
-               set_cur_block(body_block);
-               statement_to_firm(statement->body);
+       ir_node *const old_continue_label = continue_label;
+       ir_node *const old_break_label    = break_label;
+       continue_label = step_block;
+       break_label    = false_block;
 
-               assert(continue_label == step_block);
-               assert(break_label    == false_block);
-               continue_label = old_continue_label;
-               break_label    = old_break_label;
+       ir_node *const body_block = new_immBlock();
+       set_cur_block(body_block);
+       statement_to_firm(statement->body);
 
-               if (get_cur_block() != NULL) {
-                       jmp = new_Jmp();
-                       add_immBlock_pred(step_block, jmp);
-               }
-       } else {
-               body_block = step_block;
+       assert(continue_label == step_block);
+       assert(break_label    == false_block);
+       continue_label = old_continue_label;
+       break_label    = old_break_label;
+
+       if (get_cur_block() != NULL) {
+               jmp = new_Jmp();
+               add_immBlock_pred(step_block, jmp);
        }
 
        /* create the condition */
@@ -5226,9 +5216,7 @@ static void switch_statement_to_firm(switch_statement_t *statement)
                set_Cond_default_proj(cond, default_proj_nr);
        }
 
-       if (statement->body != NULL) {
-               statement_to_firm(statement->body);
-       }
+       statement_to_firm(statement->body);
 
        if (get_cur_block() != NULL) {
                ir_node *jmp = new_Jmp();
@@ -5260,11 +5248,14 @@ static void case_label_to_firm(const case_label_statement_t *statement)
 
        dbg_info *dbgi = get_dbg_info(&statement->base.source_position);
 
-       ir_node *const fallthrough = (get_cur_block() == NULL ? NULL : new_Jmp());
-
        ir_node *proj;
        ir_node *block = new_immBlock();
 
+       if (get_cur_block() != NULL) {
+               /* Fallthrough from previous case */
+               add_immBlock_pred(block, new_Jmp());
+       }
+
        if (current_switch_cond != NULL) {
                set_cur_block(get_nodes_block(current_switch_cond));
                if (statement->expression != NULL) {
@@ -5285,15 +5276,10 @@ static void case_label_to_firm(const case_label_statement_t *statement)
                }
        }
 
-       if (fallthrough != NULL) {
-               add_immBlock_pred(block, fallthrough);
-       }
        mature_immBlock(block);
        set_cur_block(block);
 
-       if (statement->statement != NULL) {
-               statement_to_firm(statement->statement);
-       }
+       statement_to_firm(statement->statement);
 }
 
 static void label_to_firm(const label_statement_t *statement)
@@ -5309,9 +5295,7 @@ static void label_to_firm(const label_statement_t *statement)
        keep_alive(block);
        keep_all_memory(block);
 
-       if (statement->statement != NULL) {
-               statement_to_firm(statement->statement);
-       }
+       statement_to_firm(statement->statement);
 }
 
 static void goto_to_firm(const goto_statement_t *statement)