(self, block, successor=None, **kwargs)
Remove unnecessary jump or conditional jump statements if they jump to the successor right afterwards.

        :param ailment.Block block:
        :return:
Remove unnecessary jump or conditional jump statements if they jump to the successor right afterwards.
Remove unnecessary jump or conditional jump statements if they jump to the successor right afterwards .
def _handle_block(self, block, successor=None, **kwargs):  # pylint:disable=no-self-use
        """
        Remove unnecessary jump or conditional jump statements if they jump to the successor right afterwards.

        :param ailment.Block block:
        :return:
        """

        if block.statements and isinstance(block.statements[-1], ailment.Stmt.ConditionalJump):
            cond_stmt = block.statements[-1]  # ailment.Stmt.ConditionalJump
            if isinstance(successor, ConditionNode):
                true_cond = False
                if cond_stmt.true_target is not None and successor.true_node is not None:
                    # True branch exists. Test if the true target is the address
                    if isinstance(cond_stmt.true_target, ailment.Expr.Const) \
                            and cond_stmt.true_target.value == successor.true_node.addr:
                        true_cond = True
                if cond_stmt.true_target is not None and successor.false_node is not None:
                    # True branch exists. Test if the true target is the address
                    if isinstance(cond_stmt.true_target, ailment.Expr.Const) \
                            and cond_stmt.true_target.value == successor.false_node.addr:
                        true_cond = True

                false_cond = False
                if cond_stmt.false_target is not None and successor.false_node is not None:
                    # False branch exists. Test if the false target is the address
                    if isinstance(cond_stmt.true_target, ailment.Expr.Const) \
                            and cond_stmt.false_target.value == successor.false_node.addr:
                        false_cond = True
                if cond_stmt.false_target is not None and successor.true_node is not None:
                    # True branch exists. Test if the true target is the address
                    if isinstance(cond_stmt.true_target, ailment.Expr.Const) \
                            and cond_stmt.false_target.value == successor.true_node.addr:
                        false_cond = True

                if true_cond or false_cond:
                    # We can safely remove this statement
                    block.statements = block.statements[:-1]
                else:
                    l.error("An unexpected successor %s follows the conditional statement %s.",
                            successor, cond_stmt
                            )
def _handle_block ( self , block , successor = None , * * kwargs ) : # pylint:disable=no-self-use if block . statements and isinstance ( block . statements [ - 1 ] , ailment . Stmt . ConditionalJump ) : cond_stmt = block . statements [ - 1 ] # ailment.Stmt.ConditionalJump if isinstance ( successor , ConditionNode ) : true_cond = False if cond_stmt . true_target is not None and successor . true_node is not None : # True branch exists. Test if the true target is the address if isinstance ( cond_stmt . true_target , ailment . Expr . Const ) and cond_stmt . true_target . value == successor . true_node . addr : true_cond = True if cond_stmt . true_target is not None and successor . false_node is not None : # True branch exists. Test if the true target is the address if isinstance ( cond_stmt . true_target , ailment . Expr . Const ) and cond_stmt . true_target . value == successor . false_node . addr : true_cond = True false_cond = False if cond_stmt . false_target is not None and successor . false_node is not None : # False branch exists. Test if the false target is the address if isinstance ( cond_stmt . true_target , ailment . Expr . Const ) and cond_stmt . false_target . value == successor . false_node . addr : false_cond = True if cond_stmt . false_target is not None and successor . true_node is not None : # True branch exists. Test if the true target is the address if isinstance ( cond_stmt . true_target , ailment . Expr . Const ) and cond_stmt . false_target . value == successor . true_node . addr : false_cond = True if true_cond or false_cond : # We can safely remove this statement block . statements = block . statements [ : - 1 ] else : l . error ( "An unexpected successor %s follows the conditional statement %s." , successor , cond_stmt )