Commit c74985e3 by Jakub Jelinek Committed by Jakub Jelinek

cp-gimplify.c (cp_genericize_r): Turn most of the function into a switch…

cp-gimplify.c (cp_genericize_r): Turn most of the function into a switch (TREE_CODE (stmt)) statement from long...

	* cp-gimplify.c (cp_genericize_r): Turn most of the function
	into a switch (TREE_CODE (stmt)) statement from long else if
	sequence.

From-SVN: r249191
parent 938a807a
2017-06-14 Jakub Jelinek <jakub@redhat.com>
* cp-gimplify.c (cp_genericize_r): Turn most of the function
into a switch (TREE_CODE (stmt)) statement from long else if
sequence.
2017-06-13 Jakub Jelinek <jakub@redhat.com> 2017-06-13 Jakub Jelinek <jakub@redhat.com>
PR c++/80973 PR c++/80973
......
...@@ -1118,8 +1118,10 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) ...@@ -1118,8 +1118,10 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
return NULL_TREE; return NULL_TREE;
} }
if (TREE_CODE (stmt) == ADDR_EXPR switch (TREE_CODE (stmt))
&& is_invisiref_parm (TREE_OPERAND (stmt, 0))) {
case ADDR_EXPR:
if (is_invisiref_parm (TREE_OPERAND (stmt, 0)))
{ {
/* If in an OpenMP context, note var uses. */ /* If in an OpenMP context, note var uses. */
if (__builtin_expect (wtd->omp_ctx != NULL, 0) if (__builtin_expect (wtd->omp_ctx != NULL, 0)
...@@ -1128,12 +1130,15 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) ...@@ -1128,12 +1130,15 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
*stmt_p = fold_convert (TREE_TYPE (stmt), TREE_OPERAND (stmt, 0)); *stmt_p = fold_convert (TREE_TYPE (stmt), TREE_OPERAND (stmt, 0));
*walk_subtrees = 0; *walk_subtrees = 0;
} }
else if (TREE_CODE (stmt) == RETURN_EXPR break;
&& TREE_OPERAND (stmt, 0)
&& is_invisiref_parm (TREE_OPERAND (stmt, 0))) case RETURN_EXPR:
if (TREE_OPERAND (stmt, 0) && is_invisiref_parm (TREE_OPERAND (stmt, 0)))
/* Don't dereference an invisiref RESULT_DECL inside a RETURN_EXPR. */ /* Don't dereference an invisiref RESULT_DECL inside a RETURN_EXPR. */
*walk_subtrees = 0; *walk_subtrees = 0;
else if (TREE_CODE (stmt) == OMP_CLAUSE) break;
case OMP_CLAUSE:
switch (OMP_CLAUSE_CODE (stmt)) switch (OMP_CLAUSE_CODE (stmt))
{ {
case OMP_CLAUSE_LASTPRIVATE: case OMP_CLAUSE_LASTPRIVATE:
...@@ -1189,30 +1194,28 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) ...@@ -1189,30 +1194,28 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
default: default:
break; break;
} }
else if (IS_TYPE_OR_DECL_P (stmt)) break;
*walk_subtrees = 0;
/* Due to the way voidify_wrapper_expr is written, we don't get a chance /* Due to the way voidify_wrapper_expr is written, we don't get a chance
to lower this construct before scanning it, so we need to lower these to lower this construct before scanning it, so we need to lower these
before doing anything else. */ before doing anything else. */
else if (TREE_CODE (stmt) == CLEANUP_STMT) case CLEANUP_STMT:
*stmt_p = build2_loc (EXPR_LOCATION (stmt), *stmt_p = build2_loc (EXPR_LOCATION (stmt),
CLEANUP_EH_ONLY (stmt) ? TRY_CATCH_EXPR CLEANUP_EH_ONLY (stmt) ? TRY_CATCH_EXPR
: TRY_FINALLY_EXPR, : TRY_FINALLY_EXPR,
void_type_node, void_type_node,
CLEANUP_BODY (stmt), CLEANUP_BODY (stmt),
CLEANUP_EXPR (stmt)); CLEANUP_EXPR (stmt));
break;
else if (TREE_CODE (stmt) == IF_STMT) case IF_STMT:
{
genericize_if_stmt (stmt_p); genericize_if_stmt (stmt_p);
/* *stmt_p has changed, tail recurse to handle it again. */ /* *stmt_p has changed, tail recurse to handle it again. */
return cp_genericize_r (stmt_p, walk_subtrees, data); return cp_genericize_r (stmt_p, walk_subtrees, data);
}
/* COND_EXPR might have incompatible types in branches if one or both /* COND_EXPR might have incompatible types in branches if one or both
arms are bitfields. Fix it up now. */ arms are bitfields. Fix it up now. */
else if (TREE_CODE (stmt) == COND_EXPR) case COND_EXPR:
{ {
tree type_left tree type_left
= (TREE_OPERAND (stmt, 1) = (TREE_OPERAND (stmt, 1)
...@@ -1241,9 +1244,9 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) ...@@ -1241,9 +1244,9 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
type_right)); type_right));
} }
} }
break;
else if (TREE_CODE (stmt) == BIND_EXPR) case BIND_EXPR:
{
if (__builtin_expect (wtd->omp_ctx != NULL, 0)) if (__builtin_expect (wtd->omp_ctx != NULL, 0))
{ {
tree decl; tree decl;
...@@ -1281,9 +1284,9 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) ...@@ -1281,9 +1284,9 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
cp_walk_tree (&BIND_EXPR_BODY (stmt), cp_walk_tree (&BIND_EXPR_BODY (stmt),
cp_genericize_r, data, NULL); cp_genericize_r, data, NULL);
wtd->bind_expr_stack.pop (); wtd->bind_expr_stack.pop ();
} break;
else if (TREE_CODE (stmt) == USING_STMT) case USING_STMT:
{ {
tree block = NULL_TREE; tree block = NULL_TREE;
...@@ -1314,23 +1317,26 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) ...@@ -1314,23 +1317,26 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
*stmt_p = build1 (NOP_EXPR, void_type_node, integer_zero_node); *stmt_p = build1 (NOP_EXPR, void_type_node, integer_zero_node);
*walk_subtrees = 0; *walk_subtrees = 0;
} }
break;
else if (TREE_CODE (stmt) == DECL_EXPR case DECL_EXPR:
&& TREE_CODE (DECL_EXPR_DECL (stmt)) == USING_DECL) if (TREE_CODE (DECL_EXPR_DECL (stmt)) == USING_DECL)
{ {
/* Using decls inside DECL_EXPRs are just dropped on the floor. */ /* Using decls inside DECL_EXPRs are just dropped on the floor. */
*stmt_p = build1 (NOP_EXPR, void_type_node, integer_zero_node); *stmt_p = build1 (NOP_EXPR, void_type_node, integer_zero_node);
*walk_subtrees = 0; *walk_subtrees = 0;
} }
else if (TREE_CODE (stmt) == DECL_EXPR) else
{ {
tree d = DECL_EXPR_DECL (stmt); tree d = DECL_EXPR_DECL (stmt);
if (VAR_P (d)) if (VAR_P (d))
gcc_assert (CP_DECL_THREAD_LOCAL_P (d) == DECL_THREAD_LOCAL_P (d)); gcc_assert (CP_DECL_THREAD_LOCAL_P (d) == DECL_THREAD_LOCAL_P (d));
} }
else if (TREE_CODE (stmt) == OMP_PARALLEL break;
|| TREE_CODE (stmt) == OMP_TASK
|| TREE_CODE (stmt) == OMP_TASKLOOP) case OMP_PARALLEL:
case OMP_TASK:
case OMP_TASKLOOP:
{ {
struct cp_genericize_omp_taskreg omp_ctx; struct cp_genericize_omp_taskreg omp_ctx;
tree c, decl; tree c, decl;
...@@ -1360,8 +1366,7 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) ...@@ -1360,8 +1366,7 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED
? OMP_CLAUSE_DEFAULT_SHARED ? OMP_CLAUSE_DEFAULT_SHARED
: OMP_CLAUSE_DEFAULT_PRIVATE); : OMP_CLAUSE_DEFAULT_PRIVATE);
if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_PRIVATE if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_PRIVATE && omp_ctx.outer)
&& omp_ctx.outer)
omp_cxx_notice_variable (omp_ctx.outer, decl); omp_cxx_notice_variable (omp_ctx.outer, decl);
break; break;
case OMP_CLAUSE_DEFAULT: case OMP_CLAUSE_DEFAULT:
...@@ -1377,7 +1382,9 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) ...@@ -1377,7 +1382,9 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
wtd->omp_ctx = omp_ctx.outer; wtd->omp_ctx = omp_ctx.outer;
splay_tree_delete (omp_ctx.variables); splay_tree_delete (omp_ctx.variables);
} }
else if (TREE_CODE (stmt) == TRY_BLOCK) break;
case TRY_BLOCK:
{ {
*walk_subtrees = 0; *walk_subtrees = 0;
tree try_block = wtd->try_block; tree try_block = wtd->try_block;
...@@ -1386,8 +1393,9 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) ...@@ -1386,8 +1393,9 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
wtd->try_block = try_block; wtd->try_block = try_block;
cp_walk_tree (&TRY_HANDLERS (stmt), cp_genericize_r, data, NULL); cp_walk_tree (&TRY_HANDLERS (stmt), cp_genericize_r, data, NULL);
} }
else if (TREE_CODE (stmt) == MUST_NOT_THROW_EXPR) break;
{
case MUST_NOT_THROW_EXPR:
/* MUST_NOT_THROW_COND might be something else with TM. */ /* MUST_NOT_THROW_COND might be something else with TM. */
if (MUST_NOT_THROW_COND (stmt) == NULL_TREE) if (MUST_NOT_THROW_COND (stmt) == NULL_TREE)
{ {
...@@ -1397,8 +1405,9 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) ...@@ -1397,8 +1405,9 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
cp_walk_tree (&TREE_OPERAND (stmt, 0), cp_genericize_r, data, NULL); cp_walk_tree (&TREE_OPERAND (stmt, 0), cp_genericize_r, data, NULL);
wtd->try_block = try_block; wtd->try_block = try_block;
} }
} break;
else if (TREE_CODE (stmt) == THROW_EXPR)
case THROW_EXPR:
{ {
location_t loc = location_of (stmt); location_t loc = location_of (stmt);
if (TREE_NO_WARNING (stmt)) if (TREE_NO_WARNING (stmt))
...@@ -1425,33 +1434,50 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) ...@@ -1425,33 +1434,50 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
"destructors default to noexcept"); "destructors default to noexcept");
} }
} }
else if (TREE_CODE (stmt) == CONVERT_EXPR) break;
case CONVERT_EXPR:
gcc_assert (!CONVERT_EXPR_VBASE_PATH (stmt)); gcc_assert (!CONVERT_EXPR_VBASE_PATH (stmt));
else if (TREE_CODE (stmt) == FOR_STMT) break;
case FOR_STMT:
genericize_for_stmt (stmt_p, walk_subtrees, data); genericize_for_stmt (stmt_p, walk_subtrees, data);
else if (TREE_CODE (stmt) == WHILE_STMT) break;
case WHILE_STMT:
genericize_while_stmt (stmt_p, walk_subtrees, data); genericize_while_stmt (stmt_p, walk_subtrees, data);
else if (TREE_CODE (stmt) == DO_STMT) break;
case DO_STMT:
genericize_do_stmt (stmt_p, walk_subtrees, data); genericize_do_stmt (stmt_p, walk_subtrees, data);
else if (TREE_CODE (stmt) == SWITCH_STMT) break;
case SWITCH_STMT:
genericize_switch_stmt (stmt_p, walk_subtrees, data); genericize_switch_stmt (stmt_p, walk_subtrees, data);
else if (TREE_CODE (stmt) == CONTINUE_STMT) break;
case CONTINUE_STMT:
genericize_continue_stmt (stmt_p); genericize_continue_stmt (stmt_p);
else if (TREE_CODE (stmt) == BREAK_STMT) break;
case BREAK_STMT:
genericize_break_stmt (stmt_p); genericize_break_stmt (stmt_p);
else if (TREE_CODE (stmt) == OMP_FOR break;
|| TREE_CODE (stmt) == OMP_SIMD
|| TREE_CODE (stmt) == OMP_DISTRIBUTE) case OMP_FOR:
case OMP_SIMD:
case OMP_DISTRIBUTE:
genericize_omp_for_stmt (stmt_p, walk_subtrees, data); genericize_omp_for_stmt (stmt_p, walk_subtrees, data);
else if (TREE_CODE (stmt) == PTRMEM_CST) break;
{
case PTRMEM_CST:
/* By the time we get here we're handing off to the back end, so we don't /* By the time we get here we're handing off to the back end, so we don't
need or want to preserve PTRMEM_CST anymore. */ need or want to preserve PTRMEM_CST anymore. */
*stmt_p = cplus_expand_constant (stmt); *stmt_p = cplus_expand_constant (stmt);
*walk_subtrees = 0; *walk_subtrees = 0;
} break;
else if (TREE_CODE (stmt) == MEM_REF)
{ case MEM_REF:
/* For MEM_REF, make sure not to sanitize the second operand even /* For MEM_REF, make sure not to sanitize the second operand even
if it has reference type. It is just an offset with a type if it has reference type. It is just an offset with a type
holding other information. There is no other processing we holding other information. There is no other processing we
...@@ -1459,16 +1485,19 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) ...@@ -1459,16 +1485,19 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
unconditionally. */ unconditionally. */
cp_walk_tree (&TREE_OPERAND (stmt, 0), cp_genericize_r, data, NULL); cp_walk_tree (&TREE_OPERAND (stmt, 0), cp_genericize_r, data, NULL);
*walk_subtrees = 0; *walk_subtrees = 0;
} break;
else if (sanitize_flags_p ((SANITIZE_NULL
| SANITIZE_ALIGNMENT | SANITIZE_VPTR)) case NOP_EXPR:
&& !wtd->no_sanitize_p) if (!wtd->no_sanitize_p
{ && sanitize_flags_p (SANITIZE_NULL | SANITIZE_ALIGNMENT)
if (sanitize_flags_p (SANITIZE_NULL | SANITIZE_ALIGNMENT)
&& TREE_CODE (stmt) == NOP_EXPR
&& TREE_CODE (TREE_TYPE (stmt)) == REFERENCE_TYPE) && TREE_CODE (TREE_TYPE (stmt)) == REFERENCE_TYPE)
ubsan_maybe_instrument_reference (stmt_p); ubsan_maybe_instrument_reference (stmt_p);
else if (TREE_CODE (stmt) == CALL_EXPR) break;
case CALL_EXPR:
if (!wtd->no_sanitize_p
&& sanitize_flags_p ((SANITIZE_NULL
| SANITIZE_ALIGNMENT | SANITIZE_VPTR)))
{ {
tree fn = CALL_EXPR_FN (stmt); tree fn = CALL_EXPR_FN (stmt);
if (fn != NULL_TREE if (fn != NULL_TREE
...@@ -1486,6 +1515,12 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) ...@@ -1486,6 +1515,12 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
cp_ubsan_maybe_instrument_member_call (stmt); cp_ubsan_maybe_instrument_member_call (stmt);
} }
} }
break;
default:
if (IS_TYPE_OR_DECL_P (stmt))
*walk_subtrees = 0;
break;
} }
p_set->add (*stmt_p); p_set->add (*stmt_p);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment