gcc/ChangeLog.gimple-classes: * gimple.h (gimple_expr_type): Split out if clause handling GIMPLE_ASSIGN and GIMPLE_CALL with an inner if GIMPLE_CALL into a pair of if clauses, first for GIMPLE_CALL, then for GIMPLE_ASSIGN. Replace them with dyn_casts, introducing local "assign_stmt", using it in place of "stmt" for typesafety. Eliminate local "type" in favor of directly returning. --- gcc/ChangeLog.gimple-classes | 9 +++++++++ gcc/gimple.h | 46 +++++++++++++++++++------------------------- 2 files changed, 29 insertions(+), 26 deletions(-)
diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 776073d..d207213 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,14 @@ 2014-11-04 David Malcolm <dmalc...@redhat.com> + * gimple.h (gimple_expr_type): Split out if clause handling + GIMPLE_ASSIGN and GIMPLE_CALL with an inner if GIMPLE_CALL + into a pair of if clauses, first for GIMPLE_CALL, then for + GIMPLE_ASSIGN. Replace them with dyn_casts, introducing local + "assign_stmt", using it in place of "stmt" for typesafety. + Eliminate local "type" in favor of directly returning. + +2014-11-04 David Malcolm <dmalc...@redhat.com> + * asan.c (get_mem_ref_of_assignment): Weaken param "assignment" from const gassign * to gassign *. * gimple.h (gimple_assign_single_p): Eliminate const_gimple variant, diff --git a/gcc/gimple.h b/gcc/gimple.h index b4782e8..a42ec11 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -5521,35 +5521,29 @@ gimple_expr_type (const_gimple stmt) { enum gimple_code code = gimple_code (stmt); - if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL) + /* In general we want to pass out a type that can be substituted + for both the RHS and the LHS types if there is a possibly + useless conversion involved. That means returning the + original RHS type as far as we can reconstruct it. */ + if (const gcall *call_stmt = dyn_cast <const gcall *> (stmt)) { - tree type; - /* In general we want to pass out a type that can be substituted - for both the RHS and the LHS types if there is a possibly - useless conversion involved. That means returning the - original RHS type as far as we can reconstruct it. */ - if (code == GIMPLE_CALL) + if (gimple_call_internal_p (call_stmt) + && gimple_call_internal_fn (call_stmt) == IFN_MASK_STORE) + return TREE_TYPE (gimple_call_arg (call_stmt, 3)); + else + return gimple_call_return_type (call_stmt); + } + else if (const gassign *assign_stmt = dyn_cast <const gassign *> (stmt)) + { + switch (gimple_assign_rhs_code (assign_stmt)) { - const gcall *call_stmt = as_a <const gcall *> (stmt); - if (gimple_call_internal_p (call_stmt) - && gimple_call_internal_fn (call_stmt) == IFN_MASK_STORE) - type = TREE_TYPE (gimple_call_arg (call_stmt, 3)); - else - type = gimple_call_return_type (call_stmt); + case POINTER_PLUS_EXPR: + return TREE_TYPE (gimple_assign_rhs1 (assign_stmt)); + + default: + /* As fallback use the type of the LHS. */ + return TREE_TYPE (gimple_get_lhs (assign_stmt)); } - else - switch (gimple_assign_rhs_code (stmt)) - { - case POINTER_PLUS_EXPR: - type = TREE_TYPE (gimple_assign_rhs1 (stmt)); - break; - - default: - /* As fallback use the type of the LHS. */ - type = TREE_TYPE (gimple_get_lhs (stmt)); - break; - } - return type; } else if (code == GIMPLE_COND) return boolean_type_node; -- 1.7.11.7