From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2049) id 57F4B385DC09; Thu, 5 May 2022 12:07:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 57F4B385DC09 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Matthew Malcomson To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] Add ADDR_EXPR_P X-Act-Checkin: gcc X-Git-Author: Richard Sandiford X-Git-Refname: refs/vendors/ARM/heads/morello X-Git-Oldrev: 08dafc1f06db0e5b61ced9ab4801a00263cbbf8d X-Git-Newrev: 03dec41d28bab047daa0a2423218219fa5144d0a Message-Id: <20220505120742.57F4B385DC09@sourceware.org> Date: Thu, 5 May 2022 12:07:42 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 May 2022 12:07:42 -0000 https://gcc.gnu.org/g:03dec41d28bab047daa0a2423218219fa5144d0a commit 03dec41d28bab047daa0a2423218219fa5144d0a Author: Richard Sandiford Date: Mon Apr 11 18:13:06 2022 +0100 Add ADDR_EXPR_P Mechanically replace checks of the form: TREE_CODE (t) == ADDR_EXPR with: ADDR_EXPR_P (t) as is done for various other tree (and rtl) operations. Diff: --- gcc/ada/gcc-interface/decl.c | 2 +- gcc/ada/gcc-interface/trans.c | 6 +-- gcc/ada/gcc-interface/utils.c | 2 +- gcc/ada/gcc-interface/utils2.c | 6 +-- gcc/analyzer/sm-signal.cc | 2 +- gcc/analyzer/sm-taint.cc | 2 +- gcc/asan.c | 2 +- gcc/brig/brigfrontend/brig-to-generic.cc | 2 +- gcc/builtins.c | 24 ++++----- gcc/c-family/c-attribs.c | 4 +- gcc/c-family/c-common.c | 2 +- gcc/c-family/c-format.c | 4 +- gcc/c-family/c-gimplify.c | 2 +- gcc/c-family/c-omp.c | 2 +- gcc/c-family/c-pretty-print.c | 2 +- gcc/c-family/c-ubsan.c | 2 +- gcc/c-family/c-warn.c | 18 +++---- gcc/c/c-parser.c | 2 +- gcc/c/c-typeck.c | 22 ++++---- gcc/calls.c | 4 +- gcc/cfgexpand.c | 5 +- gcc/cgraphbuild.c | 2 +- gcc/config/darwin.c | 4 +- gcc/config/i386/i386.md | 4 +- gcc/config/rs6000/rs6000-call.c | 2 +- gcc/cp/call.c | 14 ++--- gcc/cp/class.c | 6 +-- gcc/cp/constexpr.c | 40 +++++++-------- gcc/cp/coroutines.cc | 2 +- gcc/cp/cp-gimplify.c | 2 +- gcc/cp/cp-ubsan.c | 4 +- gcc/cp/cvt.c | 6 +-- gcc/cp/cxx-pretty-print.c | 4 +- gcc/cp/decl2.c | 2 +- gcc/cp/error.c | 10 ++-- gcc/cp/except.c | 2 +- gcc/cp/init.c | 2 +- gcc/cp/mangle.c | 6 +-- gcc/cp/method.c | 2 +- gcc/cp/name-lookup.c | 2 +- gcc/cp/parser.c | 2 +- gcc/cp/pt.c | 26 +++++----- gcc/cp/rtti.c | 4 +- gcc/cp/semantics.c | 6 +-- gcc/cp/tree.c | 2 +- gcc/cp/typeck.c | 16 +++--- gcc/cp/typeck2.c | 2 +- gcc/cp/vtable-class-hierarchy.c | 6 +-- gcc/d/d-codegen.cc | 8 +-- gcc/d/intrinsics.cc | 10 ++-- gcc/dwarf2out.c | 4 +- gcc/except.c | 2 +- gcc/expr.c | 12 ++--- gcc/fold-const.c | 38 +++++++------- gcc/fortran/trans-array.c | 2 +- gcc/fortran/trans-expr.c | 6 +-- gcc/fortran/trans-openmp.c | 2 +- gcc/gimple-array-bounds.cc | 6 +-- gcc/gimple-expr.c | 18 +++---- gcc/gimple-expr.h | 4 +- gcc/gimple-fold.c | 60 +++++++++++----------- gcc/gimple-low.c | 2 +- gcc/gimple-match-head.c | 4 +- gcc/gimple-pretty-print.c | 2 +- gcc/gimple-ssa-isolate-paths.c | 2 +- gcc/gimple-ssa-sprintf.c | 2 +- gcc/gimple-ssa-warn-restrict.c | 2 +- gcc/gimple-streamer-in.c | 4 +- gcc/gimple-streamer-out.c | 2 +- gcc/gimple-walk.c | 30 +++++------ gcc/gimplify.c | 24 ++++----- gcc/go/go-gcc.cc | 2 +- gcc/internal-fn.c | 2 +- gcc/ipa-cp.c | 10 ++-- gcc/ipa-devirt.c | 6 +-- gcc/ipa-fnsummary.c | 2 +- gcc/ipa-param-manipulation.c | 4 +- gcc/ipa-polymorphic-call.c | 6 +-- gcc/ipa-prop.c | 24 ++++----- gcc/objc/objc-act.c | 8 +-- gcc/omp-expand.c | 6 +-- gcc/omp-low.c | 34 ++++++------ gcc/omp-offload.c | 2 +- gcc/omp-simd-clone.c | 6 +-- gcc/sanopt.c | 2 +- gcc/stor-layout.c | 2 +- gcc/testsuite/g++.dg/plugin/selfassign.c | 4 +- .../gcc.dg/plugin/diagnostic_group_plugin.c | 2 +- .../gcc.dg/plugin/diagnostic_plugin_show_trees.c | 2 +- .../plugin/diagnostic_plugin_test_inlining.c | 2 +- .../diagnostic_plugin_test_string_literals.c | 2 +- .../diagnostic_plugin_test_tree_expression_range.c | 2 +- gcc/testsuite/gcc.dg/plugin/selfassign.c | 4 +- gcc/trans-mem.c | 16 +++--- gcc/tree-affine.c | 2 +- gcc/tree-cfg.c | 12 ++--- gcc/tree-cfgcleanup.c | 6 +-- gcc/tree-data-ref.c | 4 +- gcc/tree-dfa.c | 8 +-- gcc/tree-eh.c | 4 +- gcc/tree-inline.c | 8 +-- gcc/tree-nested.c | 6 +-- gcc/tree-object-size.c | 12 ++--- gcc/tree-parloops.c | 4 +- gcc/tree-pretty-print.c | 10 ++-- gcc/tree-sra.c | 6 +-- gcc/tree-ssa-address.c | 6 +-- gcc/tree-ssa-alias.c | 20 ++++---- gcc/tree-ssa-ccp.c | 20 ++++---- gcc/tree-ssa-dce.c | 2 +- gcc/tree-ssa-dom.c | 4 +- gcc/tree-ssa-forwprop.c | 10 ++-- gcc/tree-ssa-loop-ivopts.c | 6 +-- gcc/tree-ssa-loop-manip.c | 2 +- gcc/tree-ssa-operands.c | 2 +- gcc/tree-ssa-phiprop.c | 4 +- gcc/tree-ssa-pre.c | 2 +- gcc/tree-ssa-propagate.c | 2 +- gcc/tree-ssa-sccvn.c | 42 +++++++-------- gcc/tree-ssa-strlen.c | 16 +++--- gcc/tree-ssa-structalias.c | 12 ++--- gcc/tree-ssa-uninit.c | 4 +- gcc/tree-ssa.c | 18 +++---- gcc/tree-stdarg.c | 4 +- gcc/tree-vect-stmts.c | 14 ++--- gcc/tree.c | 18 +++---- gcc/tree.h | 4 ++ gcc/ubsan.c | 6 +-- gcc/value-range.cc | 4 +- gcc/var-tracking.c | 2 +- gcc/varasm.c | 15 +++--- gcc/vtable-verify.c | 4 +- 132 files changed, 509 insertions(+), 509 deletions(-) diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 025714bd339..b487e911738 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -6471,7 +6471,7 @@ constructor_address_p (tree gnu_expr) || TREE_CODE (gnu_expr) == NON_LVALUE_EXPR) gnu_expr = TREE_OPERAND (gnu_expr, 0); - return (TREE_CODE (gnu_expr) == ADDR_EXPR + return (ADDR_EXPR_P (gnu_expr) && TREE_CODE (TREE_OPERAND (gnu_expr, 0)) == CONSTRUCTOR); } diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index f74e0e728c9..64ec73b35ee 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -1794,7 +1794,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) { gnu_expr = remove_conversions (gnu_result, false); - if (TREE_CODE (gnu_expr) == ADDR_EXPR) + if (ADDR_EXPR_P (gnu_expr)) TREE_NO_TRAMPOLINE (gnu_expr) = TREE_CONSTANT (gnu_expr) = 1; /* On targets for which function symbols denote a descriptor, the @@ -1822,7 +1822,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) a useful warning with -Wtrampolines. */ else if (FUNC_OR_METHOD_TYPE_P (TREE_TYPE (gnu_prefix)) && (gnu_expr = remove_conversions (gnu_result, false)) - && TREE_CODE (gnu_expr) == ADDR_EXPR + && ADDR_EXPR_P (gnu_expr) && decl_function_context (TREE_OPERAND (gnu_expr, 0))) { set_expr_location_from_node (gnu_expr, gnat_node); @@ -8728,7 +8728,7 @@ gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p, tree t = CALL_EXPR_ARG (inner, 0); if (TREE_CODE (t) == NOP_EXPR) t = TREE_OPERAND (t, 0); - if (TREE_CODE (t) == ADDR_EXPR) + if (ADDR_EXPR_P (t)) TREE_OPERAND (op, 0) = TREE_OPERAND (t, 0); else TREE_OPERAND (op, 0) = build_fold_indirect_ref (t); diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index a96fde668be..301802418d1 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -2785,7 +2785,7 @@ create_var_decl (tree name, tree asm_name, tree type, tree init, if (TREE_CODE (inner) == COMPOUND_EXPR) inner = TREE_OPERAND (inner, 1); inner = remove_conversions (inner, true); - if (TREE_CODE (inner) == ADDR_EXPR + if (ADDR_EXPR_P (inner) && ((TREE_CODE (TREE_OPERAND (inner, 0)) == CALL_EXPR && !call_is_atomic_load (TREE_OPERAND (inner, 0))) || (TREE_CODE (TREE_OPERAND (inner, 0)) == VAR_DECL diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index c8a2d7c31be..27817e897a7 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -785,7 +785,7 @@ build_load_modify_store (tree dest, tree src, Node_Id gnat_node) /* Find out the loaded object. */ if (TREE_CODE (t) == NOP_EXPR) t = TREE_OPERAND (t, 0); - if (TREE_CODE (t) == ADDR_EXPR) + if (ADDR_EXPR_P (t)) obj = TREE_OPERAND (t, 0); else obj = build1 (INDIRECT_REF, type, t); @@ -1572,7 +1572,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) } /* If we are dereferencing an ADDR_EXPR, return its operand. */ - else if (TREE_CODE (operand) == ADDR_EXPR) + else if (ADDR_EXPR_P (operand)) result = TREE_OPERAND (operand, 0); /* Otherwise, build and fold the indirect reference. */ @@ -2775,7 +2775,7 @@ gnat_rewrite_reference (tree ref, rewrite_fn func, void *data, tree *init) tree t = CALL_EXPR_ARG (ref, 0); if (TREE_CODE (t) == NOP_EXPR) t = TREE_OPERAND (t, 0); - if (TREE_CODE (t) == ADDR_EXPR) + if (ADDR_EXPR_P (t)) t = build1 (ADDR_EXPR, TREE_TYPE (t), gnat_rewrite_reference (TREE_OPERAND (t, 0), func, data, init)); diff --git a/gcc/analyzer/sm-signal.cc b/gcc/analyzer/sm-signal.cc index 85c4b433d7b..6a2fb91b265 100644 --- a/gcc/analyzer/sm-signal.cc +++ b/gcc/analyzer/sm-signal.cc @@ -336,7 +336,7 @@ signal_state_machine::on_stmt (sm_context *sm_ctxt, if (is_named_call_p (callee_fndecl, "signal", call, 2)) { tree handler = gimple_call_arg (call, 1); - if (TREE_CODE (handler) == ADDR_EXPR + if (ADDR_EXPR_P (handler) && TREE_CODE (TREE_OPERAND (handler, 0)) == FUNCTION_DECL) { tree fndecl = TREE_OPERAND (handler, 0); diff --git a/gcc/analyzer/sm-taint.cc b/gcc/analyzer/sm-taint.cc index 28d196505d2..9aa7d7fec92 100644 --- a/gcc/analyzer/sm-taint.cc +++ b/gcc/analyzer/sm-taint.cc @@ -213,7 +213,7 @@ taint_state_machine::on_stmt (sm_context *sm_ctxt, /* Dereference an ADDR_EXPR. */ // TODO: should the engine do this? - if (TREE_CODE (arg) == ADDR_EXPR) + if (ADDR_EXPR_P (arg)) sm_ctxt->on_transition (node, stmt, TREE_OPERAND (arg, 0), m_start, m_tainted); return true; diff --git a/gcc/asan.c b/gcc/asan.c index 6c47d9386d8..e1aabb664de 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -3237,7 +3237,7 @@ asan_expand_mark_ifn (gimple_stmt_iterator *iter) bool is_poison = ((asan_mark_flags)flag) == ASAN_MARK_POISON; tree base = gimple_call_arg (g, 1); - gcc_checking_assert (TREE_CODE (base) == ADDR_EXPR); + gcc_checking_assert (ADDR_EXPR_P (base)); tree decl = TREE_OPERAND (base, 0); /* For a nested function, we can have: ASAN_MARK (2, &FRAME.2.fp_input, 4) */ diff --git a/gcc/brig/brigfrontend/brig-to-generic.cc b/gcc/brig/brigfrontend/brig-to-generic.cc index 052ba7eac75..ccbec59e2e7 100644 --- a/gcc/brig/brigfrontend/brig-to-generic.cc +++ b/gcc/brig/brigfrontend/brig-to-generic.cc @@ -872,7 +872,7 @@ brig_to_generic::write_globals () decl_call = CALL_EXPR_FN (decl_call); STRIP_NOPS (decl_call); - if (TREE_CODE (decl_call) == ADDR_EXPR + if (ADDR_EXPR_P (decl_call) && TREE_CODE (TREE_OPERAND (decl_call, 0)) == FUNCTION_DECL) TREE_OPERAND (decl_call, 0) = brig_function->m_func_decl; } diff --git a/gcc/builtins.c b/gcc/builtins.c index 56d22eaaaba..996dee6d6fe 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -424,7 +424,7 @@ get_pointer_alignment_1 (tree exp, unsigned int *alignp, { STRIP_NOPS (exp); - if (TREE_CODE (exp) == ADDR_EXPR) + if (ADDR_EXPR_P (exp)) return get_object_alignment_2 (TREE_OPERAND (exp, 0), alignp, bitposp, true); else if (TREE_CODE (exp) == POINTER_PLUS_EXPR) @@ -1505,7 +1505,7 @@ get_memory_rtx (tree exp, tree len) unknown-sized access to that one. */ if (is_gimple_mem_ref_addr (TREE_OPERAND (exp, 0))) set_mem_attributes (mem, exp, 0); - else if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR + else if (ADDR_EXPR_P (TREE_OPERAND (exp, 0)) && (exp = get_base_address (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))) { @@ -4005,7 +4005,7 @@ static bool compute_objsize (tree ptr, int ostype, access_ref *pref, bitmap *visited, const vr_values *rvals /* = NULL */) { - const bool addr = TREE_CODE (ptr) == ADDR_EXPR; + const bool addr = ADDR_EXPR_P (ptr); if (addr) ptr = TREE_OPERAND (ptr, 0); @@ -4200,7 +4200,7 @@ compute_objsize (tree ptr, int ostype, access_ref *pref, tree type = TREE_TYPE (ptr); type = TYPE_MAIN_VARIANT (type); - if (TREE_CODE (ptr) == ADDR_EXPR) + if (ADDR_EXPR_P (ptr)) ptr = TREE_OPERAND (ptr, 0); if (TREE_CODE (type) == ARRAY_TYPE @@ -6322,7 +6322,7 @@ expand_builtin_init_trampoline (tree exp, bool onstack) /* If ONSTACK, the TRAMP argument should be the address of a field within the local function's FRAME decl. Either way, let's see if we can fill in the MEM_ATTRs for this memory. */ - if (TREE_CODE (t_tramp) == ADDR_EXPR) + if (ADDR_EXPR_P (t_tramp)) set_mem_attributes (m_tramp, TREE_OPERAND (t_tramp, 0), true); /* Creator of a heap trampoline is responsible for making sure the @@ -6338,7 +6338,7 @@ expand_builtin_init_trampoline (tree exp, bool onstack) /* The FUNC argument should be the address of the nested function. Extract the actual function decl to pass to the hook. */ - gcc_assert (TREE_CODE (t_func) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (t_func)); t_func = TREE_OPERAND (t_func, 0); gcc_assert (TREE_CODE (t_func) == FUNCTION_DECL); @@ -9229,7 +9229,7 @@ fold_builtin_constant_p (tree arg) || (TREE_CODE (arg) == CONSTRUCTOR && TREE_CONSTANT (arg))) return integer_one_node; - if (TREE_CODE (arg) == ADDR_EXPR) + if (ADDR_EXPR_P (arg)) { tree op = TREE_OPERAND (arg, 0); if (TREE_CODE (op) == STRING_CST @@ -9346,7 +9346,7 @@ fold_builtin_expect (location_t loc, tree arg0, tree arg1, tree arg2, constant or the address of a non-weak symbol. */ inner = inner_arg0; STRIP_NOPS (inner); - if (TREE_CODE (inner) == ADDR_EXPR) + if (ADDR_EXPR_P (inner)) { do { @@ -10702,7 +10702,7 @@ fold_builtin_call_array (location_t loc, tree, int n, tree *argarray) { - if (TREE_CODE (fn) != ADDR_EXPR) + if (!ADDR_EXPR_P (fn)) return NULL_TREE; tree fndecl = TREE_OPERAND (fn, 0); @@ -10837,7 +10837,7 @@ readonly_data_expr (tree exp) { STRIP_NOPS (exp); - if (TREE_CODE (exp) != ADDR_EXPR) + if (!ADDR_EXPR_P (exp)) return false; exp = get_base_address (TREE_OPERAND (exp, 0)); @@ -11423,7 +11423,7 @@ maybe_emit_free_warning (tree exp) tree arg = CALL_EXPR_ARG (exp, 0); STRIP_NOPS (arg); - if (TREE_CODE (arg) != ADDR_EXPR) + if (!ADDR_EXPR_P (arg)) return; arg = get_base_address (TREE_OPERAND (arg, 0)); @@ -11466,7 +11466,7 @@ fold_builtin_object_size (tree ptr, tree ost) if (TREE_SIDE_EFFECTS (ptr)) return build_int_cst_type (size_type_node, object_size_type < 2 ? -1 : 0); - if (TREE_CODE (ptr) == ADDR_EXPR) + if (ADDR_EXPR_P (ptr)) { compute_builtin_object_size (ptr, object_size_type, &bytes); if (wi::fits_to_tree_p (bytes, size_type_node)) diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index 67aaaa2b90f..9852ed35889 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -2574,7 +2574,7 @@ handle_copy_attribute (tree *node, tree name, tree args, /* Consider address-of expressions in the attribute argument as requests to copy from the referenced entity. */ - if (TREE_CODE (ref) == ADDR_EXPR) + if (ADDR_EXPR_P (ref)) ref = TREE_OPERAND (ref, 0); do @@ -4072,7 +4072,7 @@ handle_access_attribute (tree *node, tree name, tree args, if (TREE_CODE (access_mode) == CALL_EXPR) { access_mode = CALL_EXPR_FN (access_mode); - if (TREE_CODE (access_mode) != ADDR_EXPR) + if (!ADDR_EXPR_P (access_mode)) { error ("attribute %qE invalid mode", name); return NULL_TREE; diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 394069675cd..f4367a86c67 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -8578,7 +8578,7 @@ pointer_to_zero_sized_aggr_p (tree t) bool reject_gcc_builtin (const_tree expr, location_t loc /* = UNKNOWN_LOCATION */) { - if (TREE_CODE (expr) == ADDR_EXPR) + if (ADDR_EXPR_P (expr)) expr = TREE_OPERAND (expr, 0); STRIP_ANY_LOCATION_WRAPPER (expr); diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index 77d24ad94e4..a41a1e32e0c 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -1689,7 +1689,7 @@ check_format_arg (void *ctx, tree format_tree, } offset = int_cst_value (arg1); } - if (TREE_CODE (format_tree) != ADDR_EXPR) + if (!ADDR_EXPR_P (format_tree)) { res->number_non_literal++; return; @@ -4155,7 +4155,7 @@ check_format_types (const substring_loc &fmt_loc, warning (OPT_Wformat_, "reading through null pointer " "(argument %d)", arg_num); - if (cur_param != 0 && TREE_CODE (cur_param) == ADDR_EXPR) + if (cur_param != 0 && ADDR_EXPR_P (cur_param)) cur_param = TREE_OPERAND (cur_param, 0); else cur_param = 0; diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c index 5d357d0f17e..0186f2bf086 100644 --- a/gcc/c-family/c-gimplify.c +++ b/gcc/c-family/c-gimplify.c @@ -84,7 +84,7 @@ ubsan_walk_array_refs_r (tree *tp, int *walk_subtrees, void *data) } walk_tree (&BIND_EXPR_BODY (*tp), ubsan_walk_array_refs_r, pset, pset); } - else if (TREE_CODE (*tp) == ADDR_EXPR + else if (ADDR_EXPR_P (*tp) && TREE_CODE (TREE_OPERAND (*tp, 0)) == ARRAY_REF) { ubsan_maybe_instrument_array_ref (&TREE_OPERAND (*tp, 0), true); diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index 246ba3051a1..237b63d0d53 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -266,7 +266,7 @@ c_finish_omp_atomic (location_t loc, enum tree_code code, addr = save_expr (addr); if (!test && TREE_CODE (addr) != SAVE_EXPR - && (TREE_CODE (addr) != ADDR_EXPR + && (!ADDR_EXPR_P (addr) || !VAR_P (TREE_OPERAND (addr, 0)))) { /* Make sure LHS is simple enough so that goa_lhs_expr_p can recognize diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index 94aa4bff891..2b20b218651 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -1786,7 +1786,7 @@ c_pretty_printer::unary_expression (tree e) break; case MEM_REF: - if (TREE_CODE (TREE_OPERAND (e, 0)) == ADDR_EXPR + if (ADDR_EXPR_P (TREE_OPERAND (e, 0)) && integer_zerop (TREE_OPERAND (e, 1))) expression (TREE_OPERAND (TREE_OPERAND (e, 0), 0)); else diff --git a/gcc/c-family/c-ubsan.c b/gcc/c-family/c-ubsan.c index 06a96399e64..c24e36d1a95 100644 --- a/gcc/c-family/c-ubsan.c +++ b/gcc/c-family/c-ubsan.c @@ -429,7 +429,7 @@ ubsan_maybe_instrument_reference_or_call (location_t loc, tree op, tree ptype, } else { - if (sanitize_flags_p (SANITIZE_NULL) && TREE_CODE (op) == ADDR_EXPR) + if (sanitize_flags_p (SANITIZE_NULL) && ADDR_EXPR_P (op)) { bool strict_overflow_p = false; /* tree_single_nonzero_warnv_p will not return true for non-weak diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index c32d8228b5c..1259211e9da 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -698,7 +698,7 @@ strict_aliasing_warning (location_t loc, tree type, tree expr) || TYPE_REF_CAN_ALIAS_ALL (type)) return false; - if ((warn_strict_aliasing > 1) && TREE_CODE (expr) == ADDR_EXPR + if ((warn_strict_aliasing > 1) && ADDR_EXPR_P (expr) && (DECL_P (TREE_OPERAND (expr, 0)) || handled_component_p (TREE_OPERAND (expr, 0)))) { @@ -877,7 +877,7 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee, if (strop && !cmp && fncode != BUILT_IN_STRNDUP && src) { tem = tree_strip_nop_conversions (src); - if (TREE_CODE (tem) == ADDR_EXPR) + if (ADDR_EXPR_P (tem)) tem = TREE_OPERAND (tem, 0); /* Avoid diagnosing sizeof SRC when SRC is declared with @@ -887,7 +887,7 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee, return; tree d = tree_strip_nop_conversions (dest); - if (TREE_CODE (d) == ADDR_EXPR) + if (ADDR_EXPR_P (d)) d = TREE_OPERAND (d, 0); tree dstsz = TYPE_SIZE_UNIT (TREE_TYPE (d)); @@ -927,7 +927,7 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee, && operand_equal_p (dest, sizeof_arg[idx], 0) && comp_types (TREE_TYPE (dest), type)) { - if (TREE_CODE (sizeof_arg[idx]) == ADDR_EXPR && !strop) + if (ADDR_EXPR_P (sizeof_arg[idx]) && !strop) warning_at (loc, OPT_Wsizeof_pointer_memaccess, "argument to % in %qD call is the same " "expression as the destination; did you mean to " @@ -967,7 +967,7 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee, && operand_equal_p (src, sizeof_arg[idx], 0) && comp_types (TREE_TYPE (src), type)) { - if (TREE_CODE (sizeof_arg[idx]) == ADDR_EXPR && !strop) + if (ADDR_EXPR_P (sizeof_arg[idx]) && !strop) warning_at (loc, OPT_Wsizeof_pointer_memaccess, "argument to % in %qD call is the same " "expression as the source; did you mean to " @@ -1007,7 +1007,7 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee, && operand_equal_p (dest, sizeof_arg[idx], 0) && comp_types (TREE_TYPE (dest), type)) { - if (TREE_CODE (sizeof_arg[idx]) == ADDR_EXPR && !strop) + if (ADDR_EXPR_P (sizeof_arg[idx]) && !strop) warning_at (loc, OPT_Wsizeof_pointer_memaccess, "argument to % in %qD call is the same " "expression as the first source; did you mean to " @@ -1047,7 +1047,7 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee, && operand_equal_p (src, sizeof_arg[idx], 0) && comp_types (TREE_TYPE (src), type)) { - if (TREE_CODE (sizeof_arg[idx]) == ADDR_EXPR && !strop) + if (ADDR_EXPR_P (sizeof_arg[idx]) && !strop) warning_at (loc, OPT_Wsizeof_pointer_memaccess, "argument to % in %qD call is the same " "expression as the second source; did you mean to " @@ -2181,7 +2181,7 @@ warn_for_memset (location_t loc, tree arg0, tree arg2, if (warn_memset_elt_size && TREE_CODE (arg2) == INTEGER_CST) { STRIP_NOPS (arg0); - if (TREE_CODE (arg0) == ADDR_EXPR) + if (ADDR_EXPR_P (arg0)) arg0 = TREE_OPERAND (arg0, 0); tree type = TREE_TYPE (arg0); if (type != NULL_TREE && TREE_CODE (type) == ARRAY_TYPE) @@ -2936,7 +2936,7 @@ check_address_or_pointer_of_packed_member (tree type, tree rhs) indirect = true; } - if (TREE_CODE (rhs) == ADDR_EXPR) + if (ADDR_EXPR_P (rhs)) { rhs = TREE_OPERAND (rhs, 0); rvalue = indirect; diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 70b267775f1..a37e2d8c0ec 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -21060,7 +21060,7 @@ c_parser_omp_declare_reduction (c_parser *parser, enum pragma_context context) { tree a = CALL_EXPR_ARG (c, j); STRIP_NOPS (a); - if (TREE_CODE (a) == ADDR_EXPR + if (ADDR_EXPR_P (a) && TREE_OPERAND (a, 0) == omp_priv) break; } diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 74f7245e5b5..454dae790e0 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -2583,7 +2583,7 @@ build_indirect_ref (location_t loc, tree ptr, ref_operator errstring) TREE_NO_WARNING (pointer) = 1; } - if (TREE_CODE (pointer) == ADDR_EXPR + if (ADDR_EXPR_P (pointer) && (TREE_TYPE (TREE_OPERAND (pointer, 0)) == TREE_TYPE (type))) { @@ -3134,7 +3134,7 @@ build_function_call_vec (location_t loc, vec arg_loc, /* Check that the function is called through a compatible prototype. If it is not, warn. */ if (CONVERT_EXPR_P (function) - && TREE_CODE (tem = TREE_OPERAND (function, 0)) == ADDR_EXPR + && ADDR_EXPR_P (tem = TREE_OPERAND (function, 0)) && TREE_CODE (tem = TREE_OPERAND (tem, 0)) == FUNCTION_DECL && !comptypes (fntype, TREE_TYPE (tem))) { @@ -3453,7 +3453,7 @@ convert_arguments (location_t loc, vec arg_loc, tree typelist, /* Change pointer to function to the function itself for diagnostics. */ - if (TREE_CODE (function) == ADDR_EXPR + if (ADDR_EXPR_P (function) && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL) function = TREE_OPERAND (function, 0); @@ -3647,7 +3647,7 @@ convert_arguments (location_t loc, vec arg_loc, tree typelist, error (invalid_func_diag); return -1; } - else if (TREE_CODE (val) == ADDR_EXPR && reject_gcc_builtin (val)) + else if (ADDR_EXPR_P (val) && reject_gcc_builtin (val)) { return -1; } @@ -5149,7 +5149,7 @@ type_or_builtin_type (tree expr, tree *bltin = NULL) *bltin = NULL_TREE; tree type = TREE_TYPE (expr); - if (TREE_CODE (expr) != ADDR_EXPR) + if (!ADDR_EXPR_P (expr)) return type; tree oper = TREE_OPERAND (expr, 0); @@ -6117,7 +6117,7 @@ c_cast_expr (location_t loc, struct c_type_name *type_name, tree expr) type = groktypename (type_name, &type_expr, &type_expr_const); warn_strict_prototypes = saved_wsp; - if (TREE_CODE (expr) == ADDR_EXPR && !VOID_TYPE_P (type) + if (ADDR_EXPR_P (expr) && !VOID_TYPE_P (type) && reject_gcc_builtin (expr)) return error_mark_node; @@ -6718,7 +6718,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, tree selector; /* Change pointer to function to the function itself for diagnostics. */ - if (TREE_CODE (function) == ADDR_EXPR + if (ADDR_EXPR_P (function) && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL) function = TREE_OPERAND (function, 0); @@ -11470,7 +11470,7 @@ c_process_expr_stmt (location_t loc, tree expr) exprv = TREE_OPERAND (exprv, 0); if (DECL_P (exprv) || handled_component_p (exprv) - || TREE_CODE (exprv) == ADDR_EXPR) + || ADDR_EXPR_P (exprv)) mark_exp_read (exprv); /* If the expression is not of a type to which we cannot assign a line @@ -12353,7 +12353,7 @@ build_binary_op (location_t location, enum tree_code code, short_compare = 1; else if (code0 == POINTER_TYPE && null_pointer_constant_p (orig_op1)) { - if (TREE_CODE (op0) == ADDR_EXPR + if (ADDR_EXPR_P (op0) && decl_with_nonnull_addr_p (TREE_OPERAND (op0, 0)) && !from_macro_expansion_at (location)) { @@ -12374,7 +12374,7 @@ build_binary_op (location_t location, enum tree_code code, } else if (code1 == POINTER_TYPE && null_pointer_constant_p (orig_op0)) { - if (TREE_CODE (op1) == ADDR_EXPR + if (ADDR_EXPR_P (op1) && decl_with_nonnull_addr_p (TREE_OPERAND (op1, 0)) && !from_macro_expansion_at (location)) { @@ -14492,7 +14492,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) t = TREE_OPERAND (t, 0); if (TREE_CODE (t) == POINTER_PLUS_EXPR) t = TREE_OPERAND (t, 0); - if (TREE_CODE (t) == ADDR_EXPR) + if (ADDR_EXPR_P (t)) t = TREE_OPERAND (t, 0); } goto check_dup_generic_t; diff --git a/gcc/calls.c b/gcc/calls.c index 87af7720c60..0e0888bd114 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1531,7 +1531,7 @@ get_attr_nonstring_decl (tree expr, tree *ref) var = SSA_NAME_VAR (decl); } - if (TREE_CODE (decl) == ADDR_EXPR) + if (ADDR_EXPR_P (decl)) decl = TREE_OPERAND (decl, 0); /* To simplify calling code, store the referenced DECL regardless of @@ -1742,7 +1742,7 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp) continue; tree callarg = CALL_EXPR_ARG (exp, argno); - if (TREE_CODE (callarg) == ADDR_EXPR) + if (ADDR_EXPR_P (callarg)) callarg = TREE_OPERAND (callarg, 0); /* See if the destination is declared with attribute "nonstring". */ diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index f9f6d1de7c5..e86ed48239a 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -4526,7 +4526,7 @@ expand_debug_expr (tree exp) return op0; case TARGET_MEM_REF: - if (TREE_CODE (TMR_BASE (exp)) == ADDR_EXPR + if (ADDR_EXPR_P (TMR_BASE (exp)) && !DECL_RTL_SET_P (TREE_OPERAND (TMR_BASE (exp), 0))) return NULL; @@ -5021,8 +5021,7 @@ expand_debug_expr (tree exp) } if (TREE_CODE (TREE_OPERAND (exp, 0)) == MEM_REF - && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) - == ADDR_EXPR) + && ADDR_EXPR_P (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))) { op0 = expand_debug_expr (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)); diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c index d72b3514f67..d5dd270d525 100644 --- a/gcc/cgraphbuild.c +++ b/gcc/cgraphbuild.c @@ -111,7 +111,7 @@ record_type_list (cgraph_node *node, tree list) if (TYPE_P (type)) type = lookup_type_for_runtime (type); STRIP_NOPS (type); - if (TREE_CODE (type) == ADDR_EXPR) + if (ADDR_EXPR_P (type)) { type = TREE_OPERAND (type, 0); if (VAR_P (type)) diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 2c6da2b47c4..db8cec27b63 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -3594,7 +3594,7 @@ darwin_build_constant_cfstring (tree str) STRIP_NOPS (str); - if (TREE_CODE (str) == ADDR_EXPR) + if (ADDR_EXPR_P (str)) str = TREE_OPERAND (str, 0); if (TREE_CODE (str) != STRING_CST) @@ -3689,7 +3689,7 @@ darwin_cfstring_p (tree str) STRIP_NOPS (str); - if (TREE_CODE (str) == ADDR_EXPR) + if (ADDR_EXPR_P (str)) str = TREE_OPERAND (str, 0); if (TREE_CODE (str) != STRING_CST) diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 446793b78db..afda391efcd 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -18107,10 +18107,10 @@ tree t1 = MEM_EXPR (operands[1]); tree t2 = MEM_EXPR (operands[2]); if (!((t1 && TREE_CODE (t1) == MEM_REF - && TREE_CODE (TREE_OPERAND (t1, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (t1, 0)) && TREE_CODE (TREE_OPERAND (TREE_OPERAND (t1, 0), 0)) == STRING_CST) || (t2 && TREE_CODE (t2) == MEM_REF - && TREE_CODE (TREE_OPERAND (t2, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (t2, 0)) && TREE_CODE (TREE_OPERAND (TREE_OPERAND (t2, 0), 0)) == STRING_CST))) FAIL; diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c index 0e9dc77da91..f728f02bbd0 100644 --- a/gcc/config/rs6000/rs6000-call.c +++ b/gcc/config/rs6000/rs6000-call.c @@ -9808,7 +9808,7 @@ mma_expand_builtin (tree exp, rtx target, bool *expandedp) rtx opnd; insn_op = &insn_data[icode].operand[nopnds]; - if (TREE_CODE (arg) == ADDR_EXPR + if (ADDR_EXPR_P (arg) && MEM_P (DECL_RTL (TREE_OPERAND (arg, 0)))) opnd = DECL_RTL (TREE_OPERAND (arg, 0)); else diff --git a/gcc/cp/call.c b/gcc/cp/call.c index d083808b877..fafb93b3c1f 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -8359,7 +8359,7 @@ bool unsafe_return_slot_p (tree t) { STRIP_NOPS (t); - if (TREE_CODE (t) == ADDR_EXPR) + if (ADDR_EXPR_P (t)) t = TREE_OPERAND (t, 0); if (TREE_CODE (t) == COMPONENT_REF) t = TREE_OPERAND (t, 1); @@ -8550,7 +8550,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) { tree addr = TREE_OPERAND (obj_arg, 0); STRIP_NOPS (addr); - if (TREE_CODE (addr) == ADDR_EXPR) + if (ADDR_EXPR_P (addr)) { tree typeo = TREE_TYPE (obj_arg); tree typei = TREE_TYPE (TREE_OPERAND (addr, 0)); @@ -8918,7 +8918,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) { /* For -Wformat undo the implicit passing by hidden reference done by convert_arg_to_ellipsis. */ - if (TREE_CODE (argarray[j]) == ADDR_EXPR + if (ADDR_EXPR_P (argarray[j]) && TYPE_REF_P (TREE_TYPE (argarray[j]))) fargs[j] = TREE_OPERAND (argarray[j], 0); else @@ -8983,7 +8983,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) && !TYPE_REF_P (TREE_TYPE (targ))) || TREE_CODE (targ) == NON_LVALUE_EXPR) targ = TREE_OPERAND (targ, 0); - if (TREE_CODE (targ) == ADDR_EXPR) + if (ADDR_EXPR_P (targ)) { targ = TREE_OPERAND (targ, 0); if (!same_type_ignoring_top_level_qualifiers_p @@ -9168,7 +9168,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) if (TREE_CODE (c) == CALL_EXPR) TREE_NO_WARNING (c) = 1; } - if (TREE_CODE (fn) == ADDR_EXPR) + if (ADDR_EXPR_P (fn)) { tree fndecl = STRIP_TEMPLATE (TREE_OPERAND (fn, 0)); if (TREE_CODE (fndecl) == FUNCTION_DECL @@ -9192,7 +9192,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) { tree addr = TREE_OPERAND (obj_arg, 0); STRIP_NOPS (addr); - if (TREE_CODE (addr) == ADDR_EXPR) + if (ADDR_EXPR_P (addr)) { tree typeo = TREE_TYPE (obj_arg); tree typei = TREE_TYPE (TREE_OPERAND (addr, 0)); @@ -12367,7 +12367,7 @@ extend_ref_init_temps_1 (tree decl, tree init, vec **cleanups, } return init; } - if (TREE_CODE (sub) != ADDR_EXPR) + if (!ADDR_EXPR_P (sub)) return init; /* Deal with binding to a subobject. */ for (p = &TREE_OPERAND (sub, 0); diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 27a16cc3f23..6c572bf8486 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -7723,7 +7723,7 @@ fixed_type_or_null (tree instance, int *nonnull, int *cdtorp) case POINTER_PLUS_EXPR: case PLUS_EXPR: case MINUS_EXPR: - if (TREE_CODE (TREE_OPERAND (instance, 0)) == ADDR_EXPR) + if (ADDR_EXPR_P (TREE_OPERAND (instance, 0))) return RECUR (TREE_OPERAND (instance, 0)); if (TREE_CODE (TREE_OPERAND (instance, 1)) == INTEGER_CST) /* Propagate nonnull. */ @@ -8580,7 +8580,7 @@ instantiate_type (tree lhstype, tree rhs, tsubst_flags_t complain) /* There are only a few kinds of expressions that may have a type dependent on overload resolution. */ - gcc_assert (TREE_CODE (rhs) == ADDR_EXPR + gcc_assert (ADDR_EXPR_P (rhs) || TREE_CODE (rhs) == COMPONENT_REF || is_overloaded_fn (rhs) || (flag_ms_extensions && TREE_CODE (rhs) == FUNCTION_DECL)); @@ -8845,7 +8845,7 @@ get_vtbl_decl_for_binfo (tree binfo) decl = BINFO_VTABLE (binfo); if (decl && TREE_CODE (decl) == POINTER_PLUS_EXPR) { - gcc_assert (TREE_CODE (TREE_OPERAND (decl, 0)) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (TREE_OPERAND (decl, 0))); decl = TREE_OPERAND (TREE_OPERAND (decl, 0), 0); } if (decl) diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 8ee0f2abe1a..8528212788b 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -387,7 +387,7 @@ build_data_member_initialization (tree t, vec **vec) { tree op = member; STRIP_NOPS (op); - if (TREE_CODE (op) == ADDR_EXPR) + if (ADDR_EXPR_P (op)) { gcc_assert (same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (TREE_TYPE (op)), @@ -409,7 +409,7 @@ build_data_member_initialization (tree t, vec **vec) gcc_assert (is_empty_class (TREE_TYPE (TREE_TYPE (member)))); } } - if (TREE_CODE (member) == ADDR_EXPR) + if (ADDR_EXPR_P (member)) member = TREE_OPERAND (member, 0); if (TREE_CODE (member) == COMPONENT_REF) { @@ -663,7 +663,7 @@ static tree get_function_named_in_call (tree t) { tree fun = cp_get_callee (t); - if (fun && TREE_CODE (fun) == ADDR_EXPR + if (fun && ADDR_EXPR_P (fun) && TREE_CODE (TREE_OPERAND (fun, 0)) == FUNCTION_DECL) fun = TREE_OPERAND (fun, 0); return fun; @@ -1374,7 +1374,7 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun, if (strop) { STRIP_NOPS (arg); - if (TREE_CODE (arg) == ADDR_EXPR) + if (ADDR_EXPR_P (arg)) arg = TREE_OPERAND (arg, 0); else strop = false; @@ -1457,7 +1457,7 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun, STRIP_NOPS (new_call); if (TREE_CODE (new_call) == POINTER_PLUS_EXPR) TREE_OPERAND (new_call, 0) = op; - else if (TREE_CODE (new_call) == ADDR_EXPR) + else if (ADDR_EXPR_P (new_call)) new_call = op; } @@ -1603,7 +1603,7 @@ cxx_bind_parameters_in_call (const constexpr_ctx *ctx, tree t, { tree addr = arg; STRIP_NOPS (addr); - if (TREE_CODE (addr) == ADDR_EXPR) + if (ADDR_EXPR_P (addr)) { tree obj = TREE_OPERAND (addr, 0); while (TREE_CODE (obj) == COMPONENT_REF @@ -1857,7 +1857,7 @@ extract_obj_from_addr_offset (tree expr) if (TREE_CODE (expr) == POINTER_PLUS_EXPR) expr = TREE_OPERAND (expr, 0); STRIP_NOPS (expr); - if (TREE_CODE (expr) == ADDR_EXPR) + if (ADDR_EXPR_P (expr)) expr = TREE_OPERAND (expr, 0); return expr; } @@ -1932,7 +1932,7 @@ cxx_eval_dynamic_cast_fn (const constexpr_ctx *ctx, tree call, location_t loc = cp_expr_loc_or_input_loc (call); /* Get the target type of the dynamic_cast. */ - gcc_assert (TREE_CODE (type) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (type)); type = TREE_OPERAND (type, 0); type = TREE_TYPE (DECL_NAME (type)); @@ -2205,7 +2205,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, /*lval*/false, non_constant_p, overflow_p); STRIP_NOPS (fun); - if (TREE_CODE (fun) == ADDR_EXPR) + if (ADDR_EXPR_P (fun)) fun = TREE_OPERAND (fun, 0); /* For TARGET_VTABLE_USES_DESCRIPTORS targets, there is no indirection, the called expression is a pointer into the @@ -2213,7 +2213,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, FUNCTION_DECL from there. */ else if (TARGET_VTABLE_USES_DESCRIPTORS && TREE_CODE (fun) == POINTER_PLUS_EXPR - && TREE_CODE (TREE_OPERAND (fun, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (fun, 0)) && TREE_CODE (TREE_OPERAND (fun, 1)) == INTEGER_CST) { tree d = TREE_OPERAND (TREE_OPERAND (fun, 0), 0); @@ -2293,7 +2293,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, else { STRIP_NOPS (arg0); - if (TREE_CODE (arg0) == ADDR_EXPR + if (ADDR_EXPR_P (arg0) && VAR_P (TREE_OPERAND (arg0, 0))) { tree var = TREE_OPERAND (arg0, 0); @@ -2471,7 +2471,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, to cxx_bind_parameters_in_call. */ new_obj = TREE_VEC_ELT (new_call.bindings, 0); STRIP_NOPS (new_obj); - if (TREE_CODE (new_obj) == ADDR_EXPR) + if (ADDR_EXPR_P (new_obj)) new_obj = TREE_OPERAND (new_obj, 0); if (ctx->call && ctx->call->fundef @@ -2479,7 +2479,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, { tree cur_obj = TREE_VEC_ELT (ctx->call->bindings, 0); STRIP_NOPS (cur_obj); - if (TREE_CODE (cur_obj) == ADDR_EXPR) + if (ADDR_EXPR_P (cur_obj)) cur_obj = TREE_OPERAND (cur_obj, 0); if (new_obj == cur_obj) /* We're calling the target constructor of a delegating @@ -2965,7 +2965,7 @@ cxx_fold_pointer_plus_expression (const constexpr_ctx *ctx, tree t, bool *overflow_p) { STRIP_NOPS (lhs); - if (TREE_CODE (lhs) != ADDR_EXPR) + if (!ADDR_EXPR_P (lhs)) return NULL_TREE; lhs = TREE_OPERAND (lhs, 0); @@ -4435,7 +4435,7 @@ cxx_fold_indirect_ref (location_t loc, tree type, tree op0, bool *empty_base) if (!INDIRECT_TYPE_P (subtype)) return NULL_TREE; - if (TREE_CODE (sub) == ADDR_EXPR) + if (ADDR_EXPR_P (sub)) { tree op = TREE_OPERAND (sub, 0); tree optype = TREE_TYPE (op); @@ -4462,7 +4462,7 @@ cxx_fold_indirect_ref (location_t loc, tree type, tree op0, bool *empty_base) tree op01 = TREE_OPERAND (sub, 1); STRIP_NOPS (op00); - if (TREE_CODE (op00) == ADDR_EXPR) + if (ADDR_EXPR_P (op00)) return cxx_fold_indirect_ref_1 (loc, type, TREE_OPERAND (op00, 0), tree_to_uhwi (op01), empty_base); } @@ -4536,7 +4536,7 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t, something we should have been able to fold. */ tree sub = op0; STRIP_NOPS (sub); - if (TREE_CODE (sub) == ADDR_EXPR) + if (ADDR_EXPR_P (sub)) { gcc_assert (!similar_type_p (TREE_TYPE (TREE_TYPE (sub)), TREE_TYPE (t))); @@ -6008,7 +6008,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, gcc_checking_assert (TREE_CODE (op) != CONSTRUCTOR); /* This function does more aggressive folding than fold itself. */ r = build_fold_addr_expr_with_type (op, TREE_TYPE (t)); - if (TREE_CODE (r) == ADDR_EXPR && TREE_OPERAND (r, 0) == oldop) + if (ADDR_EXPR_P (r) && TREE_OPERAND (r, 0) == oldop) { ggc_free (r); return t; @@ -6342,7 +6342,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, if (INDIRECT_TYPE_P (type) && TREE_CODE (op) == NOP_EXPR && TREE_TYPE (op) == ptr_type_node - && TREE_CODE (TREE_OPERAND (op, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (op, 0)) && VAR_P (TREE_OPERAND (TREE_OPERAND (op, 0), 0)) && DECL_NAME (TREE_OPERAND (TREE_OPERAND (op, 0), 0)) == heap_uninit_identifier) @@ -6876,7 +6876,7 @@ cxx_eval_outermost_constant_expr (tree t, bool allow_non_constant, it to be set if it is invariant address, even when it is not a valid C++ constant expression. Wrap it with a NOP_EXPR instead. */ - if (EXPR_P (r) && TREE_CODE (r) != ADDR_EXPR) + if (EXPR_P (r) && !ADDR_EXPR_P (r)) r = copy_node (r); else if (TREE_CODE (r) == CONSTRUCTOR) r = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (r), r); diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 5538449e603..3e5e55118ce 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -848,7 +848,7 @@ build_co_await (location_t loc, tree a, suspend_point_kind suspend_kind) { e_proxy = CALL_EXPR_ARG (e_proxy, 0); STRIP_NOPS (e_proxy); - gcc_checking_assert (TREE_CODE (e_proxy) == ADDR_EXPR); + gcc_checking_assert (ADDR_EXPR_P (e_proxy)); e_proxy = TREE_OPERAND (e_proxy, 0); } } diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index f8695835684..d2cc4ac26db 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -1779,7 +1779,7 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) && TREE_CODE (TREE_TYPE (TREE_TYPE (fn))) == METHOD_TYPE) { bool is_ctor - = TREE_CODE (fn) == ADDR_EXPR + = ADDR_EXPR_P (fn) && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL && DECL_CONSTRUCTOR_P (TREE_OPERAND (fn, 0)); if (sanitize_flags_p (SANITIZE_NULL | SANITIZE_ALIGNMENT)) diff --git a/gcc/cp/cp-ubsan.c b/gcc/cp/cp-ubsan.c index 183bd238aff..95d47a01f13 100644 --- a/gcc/cp/cp-ubsan.c +++ b/gcc/cp/cp-ubsan.c @@ -206,7 +206,7 @@ cp_ubsan_check_member_access_r (tree *stmt_p, int *walk_subtrees, void *data) case ADDR_EXPR: t = TREE_OPERAND (stmt, 0); while ((TREE_CODE (t) == MEM_REF || INDIRECT_REF_P (t)) - && TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR) + && ADDR_EXPR_P (TREE_OPERAND (t, 0))) t = TREE_OPERAND (TREE_OPERAND (t, 0), 0); if (handled_component_p (t)) { @@ -220,7 +220,7 @@ cp_ubsan_check_member_access_r (tree *stmt_p, int *walk_subtrees, void *data) case MEM_REF: case INDIRECT_REF: t = TREE_OPERAND (stmt, 0); - if (TREE_CODE (t) == ADDR_EXPR) + if (ADDR_EXPR_P (t)) { *walk_subtrees = 0; t = TREE_OPERAND (t, 0); diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 182646674d3..fe18bd0c3db 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -1028,7 +1028,7 @@ cp_get_fndecl_from_callee (tree fn, bool fold /* = true */) if (fold) fn = maybe_constant_init (fn); STRIP_NOPS (fn); - if (TREE_CODE (fn) == ADDR_EXPR + if (ADDR_EXPR_P (fn) || TREE_CODE (fn) == FDESC_EXPR) fn = TREE_OPERAND (fn, 0); if (TREE_CODE (fn) == FUNCTION_DECL) @@ -1503,7 +1503,7 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain) { tree probe = expr; - if (TREE_CODE (probe) == ADDR_EXPR) + if (ADDR_EXPR_P (probe)) probe = TREE_OPERAND (expr, 0); if (type_unknown_p (probe)) { @@ -1731,7 +1731,7 @@ convert_force (tree type, tree expr, int convtype, tsubst_flags_t complain) return convert_to_pointer_force (type, e, complain); /* From typeck.c convert_for_assignment */ - if (((TYPE_PTR_P (TREE_TYPE (e)) && TREE_CODE (e) == ADDR_EXPR + if (((TYPE_PTR_P (TREE_TYPE (e)) && ADDR_EXPR_P (e) && TREE_CODE (TREE_TYPE (TREE_TYPE (e))) == METHOD_TYPE) || integer_zerop (e) || TYPE_PTRMEMFUNC_P (TREE_TYPE (e))) diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index 263f225a492..edfd5309602 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -544,7 +544,7 @@ cxx_pretty_printer::postfix_expression (tree t) bool skipfirst = false; tree arg; - if (TREE_CODE (fun) == ADDR_EXPR) + if (ADDR_EXPR_P (fun)) fun = TREE_OPERAND (fun, 0); /* In templates, where there is no way to tell whether a given @@ -564,7 +564,7 @@ cxx_pretty_printer::postfix_expression (tree t) while (TREE_CODE (object) == NOP_EXPR) object = TREE_OPERAND (object, 0); - if (TREE_CODE (object) == ADDR_EXPR) + if (ADDR_EXPR_P (object)) object = TREE_OPERAND (object, 0); if (!TYPE_PTR_P (TREE_TYPE (object))) diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 33c83773d33..b348d5dbb95 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1894,7 +1894,7 @@ mark_vtable_entries (tree decl, vec &consteval_vtables) STRIP_NOPS (fnaddr); - if (TREE_CODE (fnaddr) != ADDR_EXPR + if (!ADDR_EXPR_P (fnaddr) && TREE_CODE (fnaddr) != FDESC_EXPR) /* This entry is an offset: a virtual base class offset, a virtual call offset, an RTTI offset, etc. */ diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 6c137b30d94..6bb407484b8 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -2178,7 +2178,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) { tree fn = NULL_TREE; - if (TREE_CODE (AGGR_INIT_EXPR_FN (t)) == ADDR_EXPR) + if (ADDR_EXPR_P (AGGR_INIT_EXPR_FN (t))) fn = TREE_OPERAND (AGGR_INIT_EXPR_FN (t), 0); if (fn && TREE_CODE (fn) == FUNCTION_DECL) @@ -2207,7 +2207,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) break; } - if (TREE_CODE (fn) == ADDR_EXPR) + if (ADDR_EXPR_P (fn)) fn = TREE_OPERAND (fn, 0); /* Nobody is interested in seeing the guts of vcalls. */ @@ -2219,7 +2219,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) && call_expr_nargs (t)) { tree ob = CALL_EXPR_ARG (t, 0); - if (TREE_CODE (ob) == ADDR_EXPR) + if (ADDR_EXPR_P (ob)) { dump_expr (pp, TREE_OPERAND (ob, 0), flags | TFF_EXPR_IN_PARENS); @@ -2375,7 +2375,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) break; case MEM_REF: - if (TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR + if (ADDR_EXPR_P (TREE_OPERAND (t, 0)) && integer_zerop (TREE_OPERAND (t, 1))) dump_expr (pp, TREE_OPERAND (TREE_OPERAND (t, 0), 0), flags); else @@ -2462,7 +2462,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) if (TYPE_REF_P (ttype)) { STRIP_NOPS (op); - if (TREE_CODE (op) == ADDR_EXPR) + if (ADDR_EXPR_P (op)) dump_expr (pp, TREE_OPERAND (op, 0), flags); else dump_unary_op (pp, "*", t, flags); diff --git a/gcc/cp/except.c b/gcc/cp/except.c index cb1a4105dae..4a7abd72148 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -1051,7 +1051,7 @@ check_noexcept_r (tree *tp, int * /*walk_subtrees*/, void * /*data*/) type = TREE_TYPE (type); STRIP_NOPS (fn); - if (TREE_CODE (fn) == ADDR_EXPR) + if (ADDR_EXPR_P (fn)) fn = TREE_OPERAND (fn, 0); if (TREE_CODE (fn) == FUNCTION_DECL) { diff --git a/gcc/cp/init.c b/gcc/cp/init.c index c83ec67d561..615b1f23b07 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2637,7 +2637,7 @@ warn_placement_new_too_small (tree type, tree nelts, tree size, tree oper) if (TREE_CODE (oper) == TARGET_EXPR) oper = TREE_OPERAND (oper, 1); - else if (TREE_CODE (oper) == ADDR_EXPR) + else if (ADDR_EXPR_P (oper)) { addr_expr = true; oper = TREE_OPERAND (oper, 0); diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index c5fab5057dd..1210cc82a20 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -3285,7 +3285,7 @@ write_expression (tree expr) argument with reference type, we create an ADDR_EXPR to show the fact that the entity's address has been taken. But, we don't actually want to output a mangling code for the `&'. */ - if (TREE_CODE (expr) == ADDR_EXPR + if (ADDR_EXPR_P (expr) && TREE_TYPE (expr) && TYPE_REF_P (TREE_TYPE (expr))) { @@ -3360,7 +3360,7 @@ write_expression (tree expr) { tree fn = CALL_EXPR_FN (expr); - if (TREE_CODE (fn) == ADDR_EXPR) + if (ADDR_EXPR_P (fn)) fn = TREE_OPERAND (fn, 0); /* Mangle a dependent name as the name, not whatever happens to @@ -3592,7 +3592,7 @@ write_template_arg (tree node) /* Template parameters can be of reference type. To maintain internal consistency, such arguments use a conversion from address of object to reference type. */ - gcc_assert (TREE_CODE (TREE_OPERAND (node, 0)) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (TREE_OPERAND (node, 0))); node = TREE_OPERAND (TREE_OPERAND (node, 0), 0); } diff --git a/gcc/cp/method.c b/gcc/cp/method.c index ae154ef2872..4d719003436 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1771,7 +1771,7 @@ check_nontriv (tree *tp, int *, void *) if (fn == NULL_TREE) return NULL_TREE; - if (TREE_CODE (fn) == ADDR_EXPR) + if (ADDR_EXPR_P (fn)) fn = TREE_OPERAND (fn, 0); if (TREE_CODE (fn) != FUNCTION_DECL diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index c68ea09e610..c9afe6a9de6 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -913,7 +913,7 @@ name_lookup::adl_expr (tree expr) return; } - if (TREE_CODE (expr) == ADDR_EXPR) + if (ADDR_EXPR_P (expr)) expr = TREE_OPERAND (expr, 0); if (TREE_CODE (expr) == COMPONENT_REF || TREE_CODE (expr) == OFFSET_REF) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index bb30c927d90..2a41821ab2e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -42387,7 +42387,7 @@ cp_parser_omp_declare_reduction_exprs (tree fndecl, cp_parser *parser) tree arg; FOR_EACH_VEC_SAFE_ELT (args, i, arg) if (arg == omp_priv - || (TREE_CODE (arg) == ADDR_EXPR + || (ADDR_EXPR_P (arg) && TREE_OPERAND (arg, 0) == omp_priv)) break; cp_parser_abort_tentative_parse (parser); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index afea77c84c9..f606c1f117b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6564,7 +6564,7 @@ convert_nontype_argument_function (tree type, tree expr, goto accept; fn_no_ptr = strip_fnptr_conv (fn); - if (TREE_CODE (fn_no_ptr) == ADDR_EXPR) + if (ADDR_EXPR_P (fn_no_ptr)) fn_no_ptr = TREE_OPERAND (fn_no_ptr, 0); if (BASELINK_P (fn_no_ptr)) fn_no_ptr = BASELINK_FUNCTIONS (fn_no_ptr); @@ -6646,7 +6646,7 @@ check_valid_ptrmem_cst_expr (tree type, tree expr, if (cxx_dialect >= cxx11 && null_member_pointer_value_p (expr)) return true; if (processing_template_decl - && TREE_CODE (expr) == ADDR_EXPR + && ADDR_EXPR_P (expr) && TREE_CODE (TREE_OPERAND (expr, 0)) == OFFSET_REF) return true; if (complain & tf_error) @@ -7268,7 +7268,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) and this is not folded by convert_from_reference. */ tree addr = TREE_OPERAND (probe, 0); if (TYPE_REF_P (probe_type) - && TREE_CODE (addr) == ADDR_EXPR + && ADDR_EXPR_P (addr) && TYPE_PTR_P (TREE_TYPE (addr)) && (same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (probe_type), @@ -7354,7 +7354,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) { tree probe = expr; STRIP_NOPS (probe); - if (TREE_CODE (probe) == ADDR_EXPR + if (ADDR_EXPR_P (probe) && TYPE_PTR_P (TREE_TYPE (probe))) { expr = probe; @@ -7381,7 +7381,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) ; else if (cxx_dialect >= cxx11 && integer_zerop (expr)) /* Null pointer values are OK in C++11. */; - else if (TREE_CODE (expr) != ADDR_EXPR + else if (!ADDR_EXPR_P (expr) && !INDIRECT_TYPE_P (expr_type)) /* Other values, like integer constants, might be valid non-type arguments of some other type. */ @@ -7492,7 +7492,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) (_over.over_). */ else if (TYPE_REFFN_P (type)) { - if (TREE_CODE (expr) == ADDR_EXPR) + if (ADDR_EXPR_P (expr)) { if (complain & tf_error) { @@ -19866,7 +19866,7 @@ tsubst_copy_and_build (tree t, else qualified_p = false; - if (TREE_CODE (function) == ADDR_EXPR + if (ADDR_EXPR_P (function) && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL) /* Avoid error about taking the address of a constructor. */ function = TREE_OPERAND (function, 0); @@ -22156,7 +22156,7 @@ resolve_overloaded_unification (tree tparms, tree goodfn = NULL_TREE; bool addr_p; - if (TREE_CODE (arg) == ADDR_EXPR) + if (ADDR_EXPR_P (arg)) { arg = TREE_OPERAND (arg, 0); addr_p = true; @@ -22299,7 +22299,7 @@ resolve_nondeduced_context (tree orig_expr, tsubst_flags_t complain) offset = NULL_TREE; baselink = NULL_TREE; - if (TREE_CODE (expr) == ADDR_EXPR) + if (ADDR_EXPR_P (expr)) { expr = TREE_OPERAND (expr, 0); addr = true; @@ -23769,7 +23769,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, { tree sub = TREE_OPERAND (arg, 0); STRIP_NOPS (sub); - if (TREE_CODE (sub) == ADDR_EXPR) + if (ADDR_EXPR_P (sub)) arg = TREE_OPERAND (sub, 0); } /* Now use the normal expression code to check whether they match. */ @@ -26734,7 +26734,7 @@ value_dependent_expression_p (tree expression) look through it in potential_constant_expression. */ if (i == 0 && fn && DECL_DECLARED_CONSTEXPR_P (fn) && DECL_NONSTATIC_MEMBER_FUNCTION_P (fn) - && TREE_CODE (op) == ADDR_EXPR) + && ADDR_EXPR_P (op)) op = TREE_OPERAND (op, 0); if (value_dependent_expression_p (op)) return true; @@ -26983,7 +26983,7 @@ type_dependent_expression_p (tree expression) if (TREE_TYPE (expression) == unknown_type_node) { - if (TREE_CODE (expression) == ADDR_EXPR) + if (ADDR_EXPR_P (expression)) return type_dependent_expression_p (TREE_OPERAND (expression, 0)); if (TREE_CODE (expression) == COMPONENT_REF || TREE_CODE (expression) == OFFSET_REF) @@ -27703,7 +27703,7 @@ build_non_dependent_expr (tree expr) inner_expr = expr; if (TREE_CODE (inner_expr) == STMT_EXPR) inner_expr = stmt_expr_value_expr (inner_expr); - if (TREE_CODE (inner_expr) == ADDR_EXPR) + if (ADDR_EXPR_P (inner_expr)) inner_expr = TREE_OPERAND (inner_expr, 0); if (TREE_CODE (inner_expr) == COMPONENT_REF) inner_expr = TREE_OPERAND (inner_expr, 1); diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index d5bb6d09026..2900b0b8802 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -666,7 +666,7 @@ build_dynamic_cast_1 (location_t loc, tree type, tree expr, if (tc == POINTER_TYPE && VOID_TYPE_P (TREE_TYPE (type))) { /* if b is an object, dynamic_cast(&b) == (void *)&b. */ - if (TREE_CODE (expr) == ADDR_EXPR + if (ADDR_EXPR_P (expr) && VAR_P (TREE_OPERAND (expr, 0)) && TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == RECORD_TYPE) return build1 (NOP_EXPR, type, expr); @@ -704,7 +704,7 @@ build_dynamic_cast_1 (location_t loc, tree type, tree expr, } } /* Ditto for dynamic_cast(&b). */ - else if (TREE_CODE (expr) == ADDR_EXPR) + else if (ADDR_EXPR_P (expr)) { tree op = TREE_OPERAND (expr, 0); if (VAR_P (op) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 7f861fde7d6..69cf1aa4125 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1914,7 +1914,7 @@ maybe_undo_parenthesized_ref (tree t) || TREE_CODE (t) == NOP_EXPR) t = TREE_OPERAND (t, 0); - gcc_assert (TREE_CODE (t) == ADDR_EXPR + gcc_assert (ADDR_EXPR_P (t) || TREE_CODE (t) == STATIC_CAST_EXPR); t = TREE_OPERAND (t, 0); } @@ -2579,7 +2579,7 @@ finish_call_expr (tree fn, vec **args, bool disallow_virtual, } /* Per 13.3.1.1, '(&f)(...)' is the same as '(f)(...)'. */ - if (TREE_CODE (fn) == ADDR_EXPR + if (ADDR_EXPR_P (fn) && TREE_CODE (TREE_OPERAND (fn, 0)) == OVERLOAD) fn = TREE_OPERAND (fn, 0); @@ -6449,7 +6449,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) t = TREE_OPERAND (t, 0); if (TREE_CODE (t) == POINTER_PLUS_EXPR) t = TREE_OPERAND (t, 0); - if (TREE_CODE (t) == ADDR_EXPR + if (ADDR_EXPR_P (t) || INDIRECT_REF_P (t)) t = TREE_OPERAND (t, 0); } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index e8606602bd2..3e6a51a86f1 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -629,7 +629,7 @@ build_aggr_init_expr (tree type, tree init) if (fn == NULL_TREE) return convert (type, init); - is_ctor = (TREE_CODE (fn) == ADDR_EXPR + is_ctor = (ADDR_EXPR_P (fn) && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL && DECL_CONSTRUCTOR_P (TREE_OPERAND (fn, 0))); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 0bd527737ae..d3c4bc7b13f 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2373,7 +2373,7 @@ string_conv_p (const_tree totype, const_tree exp, int warn) if (!same_type_p (TREE_TYPE (exp), t)) return 0; STRIP_NOPS (exp); - if (TREE_CODE (exp) != ADDR_EXPR + if (!ADDR_EXPR_P (exp) || TREE_CODE (TREE_OPERAND (exp, 0)) != STRING_CST) return 0; } @@ -3434,7 +3434,7 @@ cp_build_indirect_ref_1 (location_t loc, tree ptr, ref_operator errorstring, error_at (loc, "%qT is not a pointer-to-object type", type); return error_mark_node; } - else if (do_fold && TREE_CODE (pointer) == ADDR_EXPR + else if (do_fold && ADDR_EXPR_P (pointer) && same_type_p (t, TREE_TYPE (TREE_OPERAND (pointer, 0)))) /* The POINTER was something like `&x'. We simplify `*&x' to `x'. */ @@ -4434,7 +4434,7 @@ warn_for_null_address (location_t location, tree op, tsubst_flags_t complain) tree cop = fold_for_warn (op); - if (TREE_CODE (cop) == ADDR_EXPR + if (ADDR_EXPR_P (cop) && decl_with_nonnull_addr_p (TREE_OPERAND (cop, 0)) && !TREE_NO_WARNING (cop)) warning_at (location, OPT_Waddress, "the address of %qD will never " @@ -5173,7 +5173,7 @@ cp_build_binary_op (const op_location_t &location, pfn0 = pfn_from_ptrmemfunc (op0); pfn0 = cp_fully_fold (pfn0); /* Avoid -Waddress warnings (c++/64877). */ - if (TREE_CODE (pfn0) == ADDR_EXPR) + if (ADDR_EXPR_P (pfn0)) TREE_NO_WARNING (pfn0) = 1; pfn1 = pfn_from_ptrmemfunc (op1); pfn1 = cp_fully_fold (pfn1); @@ -6180,7 +6180,7 @@ build_x_unary_op (location_t loc, enum tree_code code, cp_expr xarg, exp = build_min_non_dep (code, exp, orig_expr, /*For {PRE,POST}{INC,DEC}REMENT_EXPR*/NULL_TREE); } - if (TREE_CODE (exp) == ADDR_EXPR) + if (ADDR_EXPR_P (exp)) PTRMEM_OK_P (exp) = ptrmem; return exp; } @@ -6258,7 +6258,7 @@ build_address (tree t) gcc_checking_assert (TREE_CODE (t) != CONSTRUCTOR || processing_template_decl); t = build_fold_addr_expr_loc (EXPR_LOCATION (t), t); - if (TREE_CODE (t) != ADDR_EXPR) + if (!ADDR_EXPR_P (t)) t = rvalue (t); return t; } @@ -9682,7 +9682,7 @@ maybe_warn_about_returning_address_of_local (tree retval, location_t loc) return maybe_warn_about_returning_address_of_local (arg, loc); } - if (TREE_CODE (whats_returned) != ADDR_EXPR) + if (!ADDR_EXPR_P (whats_returned)) return false; whats_returned = TREE_OPERAND (whats_returned, 0); @@ -9938,7 +9938,7 @@ maybe_warn_pessimizing_move (tree retval, tree functype) if (TREE_CODE (arg) != NOP_EXPR) return; arg = TREE_OPERAND (arg, 0); - if (TREE_CODE (arg) != ADDR_EXPR) + if (!ADDR_EXPR_P (arg)) return; arg = TREE_OPERAND (arg, 0); arg = convert_from_reference (arg); diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index b95f112a744..da613277d76 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -573,7 +573,7 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value, gcc_assert (type == unknown_type_node); if (value && TREE_CODE (value) == COMPONENT_REF) goto bad_member; - else if (value && TREE_CODE (value) == ADDR_EXPR) + else if (value && ADDR_EXPR_P (value)) emit_diagnostic (diag_kind, loc, 0, "address of overloaded function with no contextual " "type information"); diff --git a/gcc/cp/vtable-class-hierarchy.c b/gcc/cp/vtable-class-hierarchy.c index 2a816d826a6..ddf5d4df7a9 100644 --- a/gcc/cp/vtable-class-hierarchy.c +++ b/gcc/cp/vtable-class-hierarchy.c @@ -449,7 +449,7 @@ check_and_record_registered_pairs (tree vtable_decl, tree vptr_address, bool inserted_something = false; - if (TREE_CODE (vptr_address) == ADDR_EXPR + if (ADDR_EXPR_P (vptr_address) && TREE_CODE (TREE_OPERAND (vptr_address, 0)) == MEM_REF) vptr_address = TREE_OPERAND (vptr_address, 0); @@ -544,7 +544,7 @@ register_construction_vtables (tree base_class, tree record_type, while (value && TREE_OPERAND (value, 0) - && TREE_CODE (TREE_OPERAND (value, 0)) == ADDR_EXPR) + && ADDR_EXPR_P (TREE_OPERAND (value, 0))) value = TREE_OPERAND (value, 0); /* The VAR_DECL for the vtable should be the first @@ -870,7 +870,7 @@ output_set_info (tree record_type, vec vtbl_ptr_array) tree arg0 = TREE_OPERAND (vtbl_ptr_array[i], 0); tree arg1 = TREE_OPERAND (vtbl_ptr_array[i], 1); - if (TREE_CODE (arg0) == ADDR_EXPR) + if (ADDR_EXPR_P (arg0)) arg0 = TREE_OPERAND (arg0, 0); if (VAR_P (arg0)) diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc index 4050b85af28..1f71b8a0754 100644 --- a/gcc/d/d-codegen.cc +++ b/gcc/d/d-codegen.cc @@ -689,7 +689,7 @@ build_address (tree exp) d_mark_addressable (exp); exp = build_fold_addr_expr_with_type_loc (input_location, exp, ptrtype); - if (TREE_CODE (exp) == ADDR_EXPR) + if (ADDR_EXPR_P (exp)) TREE_NO_TRAMPOLINE (exp) = 1; return compound_expr (init, exp); @@ -834,7 +834,7 @@ build_memset_call (tree ptr, tree num) { if (num == NULL_TREE) { - gcc_assert (TREE_CODE (ptr) != ADDR_EXPR); + gcc_assert (!ADDR_EXPR_P (ptr)); num = TYPE_SIZE_UNIT (TREE_TYPE (ptr)); ptr = build_address (ptr); } @@ -1396,7 +1396,7 @@ build_vconvert (tree type, tree exp) static void warn_for_null_address (tree arg) { - if (TREE_CODE (arg) == ADDR_EXPR + if (ADDR_EXPR_P (arg) && decl_with_nonnull_addr_p (TREE_OPERAND (arg, 0))) warning (OPT_Waddress, "the address of %qD will never be %", @@ -1572,7 +1572,7 @@ build_deref (tree exp) gcc_assert (POINTER_TYPE_P (TREE_TYPE (exp))); - if (TREE_CODE (exp) == ADDR_EXPR) + if (ADDR_EXPR_P (exp)) exp = TREE_OPERAND (exp, 0); else exp = build_fold_indirect_ref (exp); diff --git a/gcc/d/intrinsics.cc b/gcc/d/intrinsics.cc index 486db127747..25256033f3e 100644 --- a/gcc/d/intrinsics.cc +++ b/gcc/d/intrinsics.cc @@ -422,7 +422,7 @@ expand_intrinsic_rotate (intrinsic_code intrinsic, tree callexp) { tree callee = CALL_EXPR_FN (callexp); - if (TREE_CODE (callee) == ADDR_EXPR) + if (ADDR_EXPR_P (callee)) callee = TREE_OPERAND (callee, 0); /* Retrieve from the encoded template instantation. */ @@ -553,7 +553,7 @@ expand_intrinsic_vaarg (tree callexp) parmn = build_deref (parmn); else { - gcc_assert (TREE_CODE (parmn) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (parmn)); parmn = TREE_OPERAND (parmn, 0); } @@ -590,14 +590,14 @@ expand_intrinsic_vastart (tree callexp) /* The va_list argument should already have its address taken. The second argument, however, is inout and that needs to be fixed to prevent a warning. Could be casting, so need to check type too? */ - gcc_assert (TREE_CODE (ap) == ADDR_EXPR + gcc_assert (ADDR_EXPR_P (ap) || (TREE_CODE (ap) == PARM_DECL && POINTER_TYPE_P (TREE_TYPE (ap)))); /* Assuming nobody tries to change the return type. */ if (TREE_CODE (parmn) != PARM_DECL) { - gcc_assert (TREE_CODE (parmn) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (parmn)); parmn = TREE_OPERAND (parmn, 0); } @@ -759,7 +759,7 @@ maybe_expand_intrinsic (tree callexp) { tree callee = CALL_EXPR_FN (callexp); - if (TREE_CODE (callee) == ADDR_EXPR) + if (ADDR_EXPR_P (callee)) callee = TREE_OPERAND (callee, 0); if (TREE_CODE (callee) != FUNCTION_DECL) diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 3129efb3e13..0b57b0acbb5 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -6257,7 +6257,7 @@ add_var_loc_to_decl (tree decl, rtx loc_note, const char *label, var_loc_view vi tree realdecl = DECL_DEBUG_EXPR (decl); if (handled_component_p (realdecl) || (TREE_CODE (realdecl) == MEM_REF - && TREE_CODE (TREE_OPERAND (realdecl, 0)) == ADDR_EXPR)) + && ADDR_EXPR_P (TREE_OPERAND (realdecl, 0)))) { bool reverse; tree innerdecl = get_ref_base_and_extent_hwi (realdecl, &bitpos, @@ -30283,7 +30283,7 @@ optimize_location_into_implicit_ptr (dw_die_ref die, tree decl) init = TREE_OPERAND (init, 0); STRIP_NOPS (init); } - if (TREE_CODE (init) != ADDR_EXPR) + if (!ADDR_EXPR_P (init)) return; if ((TREE_CODE (TREE_OPERAND (init, 0)) == STRING_CST && !TREE_ASM_WRITTEN (TREE_OPERAND (init, 0))) diff --git a/gcc/except.c b/gcc/except.c index d799147ec29..09525244dc5 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -3077,7 +3077,7 @@ output_ttype (tree type, int tt_format, int tt_format_size) paths below go through assemble_integer, which would take care of this for us. */ STRIP_NOPS (type); - if (TREE_CODE (type) == ADDR_EXPR) + if (ADDR_EXPR_P (type)) { type = TREE_OPERAND (type, 0); if (VAR_P (type)) diff --git a/gcc/expr.c b/gcc/expr.c index 2ec3735e9de..ca65796597d 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -5201,7 +5201,7 @@ mem_ref_refers_to_non_mem_p (tree ref) { tree addr = TREE_OPERAND (ref, 0); - if (TREE_CODE (addr) != ADDR_EXPR) + if (!ADDR_EXPR_P (addr)) return false; base = TREE_OPERAND (addr, 0); @@ -5856,7 +5856,7 @@ store_expr (tree exp, rtx target, int call_param_p, } else if ((TREE_CODE (exp) == STRING_CST || (TREE_CODE (exp) == MEM_REF - && TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (exp, 0)) && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == STRING_CST && integer_zerop (TREE_OPERAND (exp, 1)))) @@ -7272,7 +7272,7 @@ store_field (rtx target, poly_int64 bitsize, poly_int64 bitpos, decl we must use bitfield operations. */ || (known_size_p (bitsize) && TREE_CODE (exp) == MEM_REF - && TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (exp, 0)) && DECL_P (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) && !TREE_ADDRESSABLE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) && DECL_MODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) != BLKmode)) @@ -7591,7 +7591,7 @@ get_inner_reference (tree exp, poly_int64_pod *pbitsize, case MEM_REF: /* Hand back the decl for MEM[&decl, off]. */ - if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR) + if (ADDR_EXPR_P (TREE_OPERAND (exp, 0))) { tree off = TREE_OPERAND (exp, 1); if (!integer_zerop (off)) @@ -11860,7 +11860,7 @@ is_aligning_offset (const_tree offset, const_tree exp) offset = TREE_OPERAND (offset, 0); /* This must now be the address of EXP. */ - return TREE_CODE (offset) == ADDR_EXPR && TREE_OPERAND (offset, 0) == exp; + return ADDR_EXPR_P (offset) && TREE_OPERAND (offset, 0) == exp; } /* If EXPR is a constant initializer (either an expression or CONSTRUCTOR), @@ -11998,7 +11998,7 @@ constant_byte_string (tree arg, tree *ptr_offset, tree *mem_size, tree *decl, poly_int64 base_off = 0; - if (TREE_CODE (arg) == ADDR_EXPR) + if (ADDR_EXPR_P (arg)) { arg = TREE_OPERAND (arg, 0); tree ref = arg; diff --git a/gcc/fold-const.c b/gcc/fold-const.c index c593bb9a74c..e02d496fc39 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -3110,13 +3110,13 @@ operand_compare::operand_equal_p (const_tree arg0, const_tree arg1, TBAA reasons. */ if (TREE_CODE (arg0) == MEM_REF && DECL_P (arg1) - && TREE_CODE (TREE_OPERAND (arg0, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (arg0, 0)) && TREE_OPERAND (TREE_OPERAND (arg0, 0), 0) == arg1 && integer_zerop (TREE_OPERAND (arg0, 1))) return true; else if (TREE_CODE (arg1) == MEM_REF && DECL_P (arg0) - && TREE_CODE (TREE_OPERAND (arg1, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (arg1, 0)) && TREE_OPERAND (TREE_OPERAND (arg1, 0), 0) == arg0 && integer_zerop (TREE_OPERAND (arg1, 1))) return true; @@ -3812,7 +3812,7 @@ operand_compare::hash_operand (const_tree t, inchash::hash &hstate, /* For OEP_ADDRESS_OF, hash MEM_EXPR[&decl, 0] the same as decl. */ else if (code == MEM_REF && (flags & OEP_ADDRESS_OF) != 0 - && TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (t, 0)) && DECL_P (TREE_OPERAND (TREE_OPERAND (t, 0), 0)) && integer_zerop (TREE_OPERAND (t, 1))) hash_operand (TREE_OPERAND (TREE_OPERAND (t, 0), 0), @@ -8920,7 +8920,7 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0) /* Handle (T *)&A.B.C for A being of type T and B and C living at offset zero. This occurs frequently in C++ upcasting and then accessing the base. */ - if (TREE_CODE (op0) == ADDR_EXPR + if (ADDR_EXPR_P (op0) && POINTER_TYPE_P (type) && handled_component_p (TREE_OPERAND (op0, 0))) { @@ -9130,7 +9130,7 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0) case INDIRECT_REF: /* Fold *&X to X if X is an lvalue. */ - if (TREE_CODE (op0) == ADDR_EXPR) + if (ADDR_EXPR_P (op0)) { tree op00 = TREE_OPERAND (op0, 0); if ((VAR_P (op00) @@ -9472,7 +9472,7 @@ pointer_may_wrap_p (tree base, tree offset, poly_int64 bitpos) /* We can do slightly better for SIZE if we have an ADDR_EXPR of an array. */ - if (TREE_CODE (base) == ADDR_EXPR + if (ADDR_EXPR_P (base) && poly_int_tree_p (TYPE_SIZE_UNIT (TREE_TYPE (TREE_OPERAND (base, 0))), &size) && maybe_ne (size, 0U) @@ -9530,8 +9530,8 @@ fold_comparison (location_t loc, enum tree_code code, tree type, This requires at least one operand being an ADDR_EXPR or a POINTER_PLUS_EXPR to do more than the operand_equal_p test below. */ if (POINTER_TYPE_P (TREE_TYPE (arg0)) - && (TREE_CODE (arg0) == ADDR_EXPR - || TREE_CODE (arg1) == ADDR_EXPR + && (ADDR_EXPR_P (arg0) + || ADDR_EXPR_P (arg1) || TREE_CODE (arg0) == POINTER_PLUS_EXPR || TREE_CODE (arg1) == POINTER_PLUS_EXPR)) { @@ -9546,7 +9546,7 @@ fold_comparison (location_t loc, enum tree_code code, tree type, off the base object if possible. indirect_baseN will be true if baseN is not an address but refers to the object itself. */ base0 = arg0; - if (TREE_CODE (arg0) == ADDR_EXPR) + if (ADDR_EXPR_P (arg0)) { base0 = get_inner_reference (TREE_OPERAND (arg0, 0), @@ -9561,7 +9561,7 @@ fold_comparison (location_t loc, enum tree_code code, tree type, { base0 = TREE_OPERAND (arg0, 0); STRIP_SIGN_NOPS (base0); - if (TREE_CODE (base0) == ADDR_EXPR) + if (ADDR_EXPR_P (base0)) { base0 = get_inner_reference (TREE_OPERAND (base0, 0), @@ -9589,7 +9589,7 @@ fold_comparison (location_t loc, enum tree_code code, tree type, } base1 = arg1; - if (TREE_CODE (arg1) == ADDR_EXPR) + if (ADDR_EXPR_P (arg1)) { base1 = get_inner_reference (TREE_OPERAND (arg1, 0), @@ -9604,7 +9604,7 @@ fold_comparison (location_t loc, enum tree_code code, tree type, { base1 = TREE_OPERAND (arg1, 0); STRIP_SIGN_NOPS (base1); - if (TREE_CODE (base1) == ADDR_EXPR) + if (ADDR_EXPR_P (base1)) { base1 = get_inner_reference (TREE_OPERAND (base1, 0), @@ -10473,7 +10473,7 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type, { case MEM_REF: /* MEM[&MEM[p, CST1], CST2] -> MEM[p, CST1 + CST2]. */ - if (TREE_CODE (arg0) == ADDR_EXPR + if (ADDR_EXPR_P (arg0) && TREE_CODE (TREE_OPERAND (arg0, 0)) == MEM_REF) { tree iref = TREE_OPERAND (arg0, 0); @@ -10482,7 +10482,7 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type, } /* MEM[&a.b, CST2] -> MEM[&a, offsetof (a, b) + CST2]. */ - if (TREE_CODE (arg0) == ADDR_EXPR + if (ADDR_EXPR_P (arg0) && handled_component_p (TREE_OPERAND (arg0, 0))) { tree base; @@ -10969,9 +10969,9 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type, case POINTER_DIFF_EXPR: case MINUS_EXPR: /* Fold &a[i] - &a[j] to i-j. */ - if (TREE_CODE (arg0) == ADDR_EXPR + if (ADDR_EXPR_P (arg0) && TREE_CODE (TREE_OPERAND (arg0, 0)) == ARRAY_REF - && TREE_CODE (arg1) == ADDR_EXPR + && ADDR_EXPR_P (arg1) && TREE_CODE (TREE_OPERAND (arg1, 0)) == ARRAY_REF) { tree tem = fold_addr_of_array_ref_difference (loc, type, @@ -15225,7 +15225,7 @@ fold_indirect_ref_1 (location_t loc, tree type, tree op0) || TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (op0))) return NULL_TREE; - if (TREE_CODE (sub) == ADDR_EXPR) + if (ADDR_EXPR_P (sub)) { tree op = TREE_OPERAND (sub, 0); tree optype = TREE_TYPE (op); @@ -15280,7 +15280,7 @@ fold_indirect_ref_1 (location_t loc, tree type, tree op0) tree op01 = TREE_OPERAND (sub, 1); STRIP_NOPS (op00); - if (TREE_CODE (op00) == ADDR_EXPR) + if (ADDR_EXPR_P (op00)) { tree op00type; op00 = TREE_OPERAND (op00, 0); @@ -15562,7 +15562,7 @@ split_address_to_core_and_offset (tree exp, poly_int64 bitsize; location_t loc = EXPR_LOCATION (exp); - if (TREE_CODE (exp) == ADDR_EXPR) + if (ADDR_EXPR_P (exp)) { core = get_inner_reference (TREE_OPERAND (exp, 0), &bitsize, pbitpos, poffset, &mode, &unsignedp, &reversep, diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 0e3495d59cc..dcb0d166f9f 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -2987,7 +2987,7 @@ gfc_conv_ss_descriptor (stmtblock_t * block, gfc_ss * ss, int base) analysis by pulling the expressions for elemental array indices inside the loop. */ if (!(DECL_P (tmp) - || (TREE_CODE (tmp) == ADDR_EXPR + || (ADDR_EXPR_P (tmp) && DECL_P (TREE_OPERAND (tmp, 0))))) tmp = gfc_evaluate_now (tmp, block); info->data = tmp; diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 36ff9b5cbc6..b0b6e90939e 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -3680,7 +3680,7 @@ gfc_string_to_single_character (tree len, tree str, int kind) } if (kind == 1 - && TREE_CODE (str) == ADDR_EXPR + && ADDR_EXPR_P (str) && TREE_CODE (TREE_OPERAND (str, 0)) == ARRAY_REF && TREE_CODE (TREE_OPERAND (TREE_OPERAND (str, 0), 0)) == STRING_CST && array_ref_low_bound (TREE_OPERAND (str, 0)) @@ -3778,7 +3778,7 @@ static int gfc_optimize_len_trim (tree len, tree str, int kind) { if (kind == 1 - && TREE_CODE (str) == ADDR_EXPR + && ADDR_EXPR_P (str) && TREE_CODE (TREE_OPERAND (str, 0)) == ARRAY_REF && TREE_CODE (TREE_OPERAND (TREE_OPERAND (str, 0), 0)) == STRING_CST && array_ref_low_bound (TREE_OPERAND (str, 0)) @@ -6053,7 +6053,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, && fsym->ts.type != BT_CLASS && e->expr_type != EXPR_NULL) { tmp = parmse.expr; - if (TREE_CODE (tmp) == ADDR_EXPR) + if (ADDR_EXPR_P (tmp)) tmp = build_fold_indirect_ref_loc (input_location, tmp); parmse.expr = gfc_conv_scalar_to_descriptor (&parmse, tmp, fsym->attr); diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 063d4c145e2..68974d61d4f 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -4150,7 +4150,7 @@ gfc_trans_omp_atomic (gfc_code *code) lhsaddr = save_expr (lhsaddr); if (TREE_CODE (lhsaddr) != SAVE_EXPR - && (TREE_CODE (lhsaddr) != ADDR_EXPR + && (!ADDR_EXPR_P (lhsaddr) || !VAR_P (TREE_OPERAND (lhsaddr, 0)))) { /* Make sure LHS is simple enough so that goa_lhs_expr_p can recognize diff --git a/gcc/gimple-array-bounds.cc b/gcc/gimple-array-bounds.cc index c2dd6663c3a..5ae5e63391c 100644 --- a/gcc/gimple-array-bounds.cc +++ b/gcc/gimple-array-bounds.cc @@ -366,7 +366,7 @@ array_bounds_checker::check_mem_ref (location_t location, tree ref, offrange[1] = arrbounds[1]; } - if (TREE_CODE (arg) == ADDR_EXPR) + if (ADDR_EXPR_P (arg)) { arg = TREE_OPERAND (arg, 0); if (TREE_CODE (arg) != STRING_CST @@ -543,7 +543,7 @@ array_bounds_checker::check_addr_expr (location_t location, tree t) while (handled_component_p (t) || TREE_CODE (t) == MEM_REF); if (TREE_CODE (t) != MEM_REF - || TREE_CODE (TREE_OPERAND (t, 0)) != ADDR_EXPR + || !ADDR_EXPR_P (TREE_OPERAND (t, 0)) || TREE_NO_WARNING (t)) return; @@ -634,7 +634,7 @@ array_bounds_checker::check_array_bounds (tree *tp, int *walk_subtree, else if (TREE_CODE (t) == MEM_REF) warned = checker->check_mem_ref (location, t, false /*ignore_off_by_one*/); - else if (TREE_CODE (t) == ADDR_EXPR) + else if (ADDR_EXPR_P (t)) { checker->check_addr_expr (location, t); *walk_subtree = FALSE; diff --git a/gcc/gimple-expr.c b/gcc/gimple-expr.c index 8d82fcc65ed..6c7fda9cc2c 100644 --- a/gcc/gimple-expr.c +++ b/gcc/gimple-expr.c @@ -641,7 +641,7 @@ is_gimple_address (const_tree t) { tree op; - if (TREE_CODE (t) != ADDR_EXPR) + if (!ADDR_EXPR_P (t)) return false; op = TREE_OPERAND (t, 0); @@ -682,7 +682,7 @@ is_gimple_invariant_address (const_tree t) { const_tree op; - if (TREE_CODE (t) != ADDR_EXPR) + if (!ADDR_EXPR_P (t)) return false; op = strip_invariant_refs (TREE_OPERAND (t, 0)); @@ -692,7 +692,7 @@ is_gimple_invariant_address (const_tree t) if (TREE_CODE (op) == MEM_REF) { const_tree op0 = TREE_OPERAND (op, 0); - return (TREE_CODE (op0) == ADDR_EXPR + return (ADDR_EXPR_P (op0) && (CONSTANT_CLASS_P (TREE_OPERAND (op0, 0)) || decl_address_invariant_p (TREE_OPERAND (op0, 0)))); } @@ -708,7 +708,7 @@ is_gimple_ip_invariant_address (const_tree t) { const_tree op; - if (TREE_CODE (t) != ADDR_EXPR) + if (!ADDR_EXPR_P (t)) return false; op = strip_invariant_refs (TREE_OPERAND (t, 0)); @@ -718,7 +718,7 @@ is_gimple_ip_invariant_address (const_tree t) if (TREE_CODE (op) == MEM_REF) { const_tree op0 = TREE_OPERAND (op, 0); - return (TREE_CODE (op0) == ADDR_EXPR + return (ADDR_EXPR_P (op0) && (CONSTANT_CLASS_P (TREE_OPERAND (op0, 0)) || decl_address_ip_invariant_p (TREE_OPERAND (op0, 0)))); } @@ -732,7 +732,7 @@ is_gimple_ip_invariant_address (const_tree t) bool is_gimple_min_invariant (const_tree t) { - if (TREE_CODE (t) == ADDR_EXPR) + if (ADDR_EXPR_P (t)) return is_gimple_invariant_address (t); return is_gimple_constant (t); @@ -744,7 +744,7 @@ is_gimple_min_invariant (const_tree t) bool is_gimple_ip_invariant (const_tree t) { - if (TREE_CODE (t) == ADDR_EXPR) + if (ADDR_EXPR_P (t)) return is_gimple_ip_invariant_address (t); return is_gimple_constant (t); @@ -846,7 +846,7 @@ is_gimple_mem_ref_addr (tree t) { return (is_gimple_reg (t) || TREE_CODE (t) == INTEGER_CST - || (TREE_CODE (t) == ADDR_EXPR + || (ADDR_EXPR_P (t) && (CONSTANT_CLASS_P (TREE_OPERAND (t, 0)) || decl_address_invariant_p (TREE_OPERAND (t, 0))))); } @@ -911,7 +911,7 @@ mark_addressable (tree x) while (handled_component_p (x)) x = TREE_OPERAND (x, 0); if (TREE_CODE (x) == MEM_REF - && TREE_CODE (TREE_OPERAND (x, 0)) == ADDR_EXPR) + && ADDR_EXPR_P (TREE_OPERAND (x, 0))) x = TREE_OPERAND (TREE_OPERAND (x, 0), 0); if (!VAR_P (x) && TREE_CODE (x) != PARM_DECL diff --git a/gcc/gimple-expr.h b/gcc/gimple-expr.h index 1b8f6afb496..6ddd09ee07e 100644 --- a/gcc/gimple-expr.h +++ b/gcc/gimple-expr.h @@ -163,11 +163,11 @@ extract_ops_from_tree (tree expr, enum tree_code *code, tree *op0, static inline tree gimple_call_addr_fndecl (const_tree fn) { - if (fn && TREE_CODE (fn) == ADDR_EXPR) + if (fn && ADDR_EXPR_P (fn)) { tree fndecl = TREE_OPERAND (fn, 0); if (TREE_CODE (fndecl) == MEM_REF - && TREE_CODE (TREE_OPERAND (fndecl, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (fndecl, 0)) && integer_zerop (TREE_OPERAND (fndecl, 1))) fndecl = TREE_OPERAND (TREE_OPERAND (fndecl, 0), 0); if (TREE_CODE (fndecl) == FUNCTION_DECL) diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index e710cf83656..e63371d65c6 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -225,7 +225,7 @@ canonicalize_constructor_val (tree cval, tree from_decl) fold_convert_for_mem_ref (ptr_type_node, TREE_OPERAND (cval, 1)))); } - if (TREE_CODE (cval) == ADDR_EXPR) + if (ADDR_EXPR_P (cval)) { tree base = NULL_TREE; if (TREE_CODE (TREE_OPERAND (cval, 0)) == COMPOUND_LITERAL_EXPR) @@ -402,7 +402,7 @@ fold_gimple_assign (gimple_stmt_iterator *si) } } - else if (TREE_CODE (rhs) == ADDR_EXPR) + else if (ADDR_EXPR_P (rhs)) { tree ref = TREE_OPERAND (rhs, 0); tree tem = maybe_fold_reference (ref, true); @@ -657,7 +657,7 @@ var_decl_component_p (tree var) inner = TREE_OPERAND (inner, 0); return (DECL_P (inner) || (TREE_CODE (inner) == MEM_REF - && TREE_CODE (TREE_OPERAND (inner, 0)) == ADDR_EXPR)); + && ADDR_EXPR_P (TREE_OPERAND (inner, 0)))); } /* Return TRUE if the SIZE argument, representing the size of an @@ -892,8 +892,8 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi, } /* If *src and *dest can't overlap, optimize into memcpy as well. */ - if (TREE_CODE (src) == ADDR_EXPR - && TREE_CODE (dest) == ADDR_EXPR) + if (ADDR_EXPR_P (src) + && ADDR_EXPR_P (dest)) { tree src_base, dest_base, fn; poly_int64 src_offset = 0, dest_offset = 0; @@ -1026,14 +1026,14 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi, string store. */ destvar = NULL_TREE; srcvar = NULL_TREE; - if (TREE_CODE (dest) == ADDR_EXPR + if (ADDR_EXPR_P (dest) && var_decl_component_p (TREE_OPERAND (dest, 0)) && tree_int_cst_equal (TYPE_SIZE_UNIT (desttype), len) && dest_align >= TYPE_ALIGN (desttype) && (is_gimple_reg_type (desttype) || src_align >= TYPE_ALIGN (desttype))) destvar = fold_build2 (MEM_REF, desttype, dest, off0); - else if (TREE_CODE (src) == ADDR_EXPR + else if (ADDR_EXPR_P (src) && var_decl_component_p (TREE_OPERAND (src, 0)) && tree_int_cst_equal (TYPE_SIZE_UNIT (srctype), len) && src_align >= TYPE_ALIGN (srctype) @@ -1266,7 +1266,7 @@ gimple_fold_builtin_memset (gimple_stmt_iterator *gsi, tree c, tree len) tree dest = gimple_call_arg (stmt, 0); tree var = dest; - if (TREE_CODE (var) != ADDR_EXPR) + if (!ADDR_EXPR_P (var)) return false; var = TREE_OPERAND (var, 0); @@ -1349,7 +1349,7 @@ get_range_strlen_tree (tree arg, bitmap *visited, strlen_range_kind rkind, bool tight_bound = false; /* We can end up with &(*iftmp_1)[0] here as well, so handle it. */ - if (TREE_CODE (arg) == ADDR_EXPR + if (ADDR_EXPR_P (arg) && TREE_CODE (TREE_OPERAND (arg, 0)) == ARRAY_REF) { tree op = TREE_OPERAND (arg, 0); @@ -1408,7 +1408,7 @@ get_range_strlen_tree (tree arg, bitmap *visited, strlen_range_kind rkind, if (!val && rkind == SRK_LENRANGE) { - if (TREE_CODE (arg) == ADDR_EXPR) + if (ADDR_EXPR_P (arg)) return get_range_strlen (TREE_OPERAND (arg, 0), visited, rkind, pdata, eltsize); @@ -1487,7 +1487,7 @@ get_range_strlen_tree (tree arg, bitmap *visited, strlen_range_kind rkind, else if (TREE_CODE (arg) == MEM_REF && TREE_CODE (TREE_TYPE (arg)) == ARRAY_TYPE && TREE_CODE (TREE_TYPE (TREE_TYPE (arg))) == INTEGER_TYPE - && TREE_CODE (TREE_OPERAND (arg, 0)) == ADDR_EXPR) + && ADDR_EXPR_P (TREE_OPERAND (arg, 0))) { /* Handle a MEM_REF into a DECL accessing an array of integers, being conservative about references to extern structures with @@ -4192,7 +4192,7 @@ optimize_atomic_compare_exchange_p (gimple *stmt) } tree expected = gimple_call_arg (stmt, 1); - if (TREE_CODE (expected) != ADDR_EXPR + if (!ADDR_EXPR_P (expected) || !SSA_VAR_P (TREE_OPERAND (expected, 0))) return false; @@ -4893,7 +4893,7 @@ maybe_canonicalize_mem_ref_addr (tree *t, bool is_debug = false) bool res = false; tree *orig_t = t; - if (TREE_CODE (*t) == ADDR_EXPR) + if (ADDR_EXPR_P (*t)) t = &TREE_OPERAND (*t, 0); /* The C and C++ frontends use an ARRAY_REF for indexing with their @@ -4943,7 +4943,7 @@ maybe_canonicalize_mem_ref_addr (tree *t, bool is_debug = false) || TREE_CODE (*t) == TARGET_MEM_REF) { tree addr = TREE_OPERAND (*t, 0); - if (TREE_CODE (addr) == ADDR_EXPR + if (ADDR_EXPR_P (addr) && (TREE_CODE (TREE_OPERAND (addr, 0)) == MEM_REF || handled_component_p (TREE_OPERAND (addr, 0)))) { @@ -4971,7 +4971,7 @@ maybe_canonicalize_mem_ref_addr (tree *t, bool is_debug = false) /* Canonicalize back MEM_REFs to plain reference trees if the object accessed is a decl that has the same access semantics as the MEM_REF. */ if (TREE_CODE (*t) == MEM_REF - && TREE_CODE (TREE_OPERAND (*t, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (*t, 0)) && integer_zerop (TREE_OPERAND (*t, 1)) && MR_DEPENDENCE_CLIQUE (*t) == 0) { @@ -4996,7 +4996,7 @@ maybe_canonicalize_mem_ref_addr (tree *t, bool is_debug = false) } } - else if (TREE_CODE (*orig_t) == ADDR_EXPR + else if (ADDR_EXPR_P (*orig_t) && TREE_CODE (*t) == MEM_REF && TREE_CODE (TREE_OPERAND (*t, 0)) == INTEGER_CST) { @@ -5061,7 +5061,7 @@ fold_stmt_1 (gimple_stmt_iterator *gsi, bool inplace, tree (*valueize) (tree)) { tree *rhs = gimple_assign_rhs1_ptr (stmt); if ((REFERENCE_CLASS_P (*rhs) - || TREE_CODE (*rhs) == ADDR_EXPR) + || ADDR_EXPR_P (*rhs)) && maybe_canonicalize_mem_ref_addr (rhs)) changed = true; tree *lhs = gimple_assign_lhs_ptr (stmt); @@ -5123,7 +5123,7 @@ fold_stmt_1 (gimple_stmt_iterator *gsi, bool inplace, tree (*valueize) (tree)) tree link = gimple_asm_input_op (asm_stmt, i); tree op = TREE_VALUE (link); if ((REFERENCE_CLASS_P (op) - || TREE_CODE (op) == ADDR_EXPR) + || ADDR_EXPR_P (op)) && maybe_canonicalize_mem_ref_addr (&TREE_VALUE (link))) changed = true; } @@ -5135,7 +5135,7 @@ fold_stmt_1 (gimple_stmt_iterator *gsi, bool inplace, tree (*valueize) (tree)) tree *val = gimple_debug_bind_get_value_ptr (stmt); if (*val && (REFERENCE_CLASS_P (*val) - || TREE_CODE (*val) == ADDR_EXPR) + || ADDR_EXPR_P (*val)) && maybe_canonicalize_mem_ref_addr (val, true)) changed = true; } @@ -5304,7 +5304,7 @@ fold_stmt_1 (gimple_stmt_iterator *gsi, bool inplace, tree (*valueize) (tree)) } } else if (val - && TREE_CODE (val) == ADDR_EXPR) + && ADDR_EXPR_P (val)) { tree ref = TREE_OPERAND (val, 0); tree tem = maybe_fold_reference (ref, false); @@ -6404,7 +6404,7 @@ gimple_fold_stmt_to_constant_1 (gimple *stmt, tree (*valueize) (tree), } /* Handle propagating invariant addresses into address operations. */ - else if (TREE_CODE (rhs) == ADDR_EXPR + else if (ADDR_EXPR_P (rhs) && !is_gimple_min_invariant (rhs)) { poly_int64 offset = 0; @@ -6475,7 +6475,7 @@ gimple_fold_stmt_to_constant_1 (gimple *stmt, tree (*valueize) (tree), && TREE_CODE (TREE_OPERAND (rhs, 0)) == SSA_NAME) { tree val = (*valueize) (TREE_OPERAND (rhs, 0)); - if (TREE_CODE (val) == ADDR_EXPR + if (ADDR_EXPR_P (val) && is_gimple_min_invariant (val)) { tree tem = fold_build2 (MEM_REF, TREE_TYPE (rhs), @@ -6502,7 +6502,7 @@ gimple_fold_stmt_to_constant_1 (gimple *stmt, tree (*valueize) (tree), { tree op0 = (*valueize) (gimple_assign_rhs1 (stmt)); tree op1 = (*valueize) (gimple_assign_rhs2 (stmt)); - if (TREE_CODE (op0) == ADDR_EXPR + if (ADDR_EXPR_P (op0) && TREE_CODE (op1) == INTEGER_CST) { tree off = fold_convert_for_mem_ref (ptr_type_node, op1); @@ -6618,7 +6618,7 @@ gimple_fold_stmt_to_constant_1 (gimple *stmt, tree (*valueize) (tree), } fn = (*valueize) (gimple_call_fn (stmt)); - if (TREE_CODE (fn) == ADDR_EXPR + if (ADDR_EXPR_P (fn) && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL && fndecl_built_in_p (TREE_OPERAND (fn, 0)) && gimple_builtin_call_types_compatible_p (stmt, @@ -6690,7 +6690,7 @@ get_base_constructor (tree base, poly_int64_pod *bit_offset, if (valueize && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME) base = valueize (TREE_OPERAND (base, 0)); - if (!base || TREE_CODE (base) != ADDR_EXPR) + if (!base || !ADDR_EXPR_P (base)) return NULL_TREE; base = TREE_OPERAND (base, 0); } @@ -7368,7 +7368,7 @@ gimple_get_virt_method_for_vtable (HOST_WIDE_INT token, the virtual table and pick up a constant or RTTI info pointer. In any case the call is undefined. */ if (!fn - || (TREE_CODE (fn) != ADDR_EXPR && TREE_CODE (fn) != FDESC_EXPR) + || (!ADDR_EXPR_P (fn) && TREE_CODE (fn) != FDESC_EXPR) || TREE_CODE (TREE_OPERAND (fn, 0)) != FUNCTION_DECL) fn = builtin_decl_implicit (BUILT_IN_UNREACHABLE); else @@ -7446,7 +7446,7 @@ gimple_fold_indirect_ref (tree t) || TYPE_REF_CAN_ALIAS_ALL (ptype)) return NULL_TREE; - if (TREE_CODE (sub) == ADDR_EXPR) + if (ADDR_EXPR_P (sub)) { tree op = TREE_OPERAND (sub, 0); tree optype = TREE_TYPE (op); @@ -7492,7 +7492,7 @@ gimple_fold_indirect_ref (tree t) addrtype = TREE_TYPE (addr); /* ((foo*)&vectorfoo)[1] -> BIT_FIELD_REF */ - if (TREE_CODE (addr) == ADDR_EXPR + if (ADDR_EXPR_P (addr) && TREE_CODE (TREE_TYPE (addrtype)) == VECTOR_TYPE && useless_type_conversion_p (type, TREE_TYPE (TREE_TYPE (addrtype))) && tree_fits_uhwi_p (off)) @@ -7510,7 +7510,7 @@ gimple_fold_indirect_ref (tree t) } /* ((foo*)&complexfoo)[1] -> __imag__ complexfoo */ - if (TREE_CODE (addr) == ADDR_EXPR + if (ADDR_EXPR_P (addr) && TREE_CODE (TREE_TYPE (addrtype)) == COMPLEX_TYPE && useless_type_conversion_p (type, TREE_TYPE (TREE_TYPE (addrtype)))) { @@ -7520,7 +7520,7 @@ gimple_fold_indirect_ref (tree t) } /* *(p + CST) -> MEM_REF . */ - if (TREE_CODE (addr) != ADDR_EXPR + if (!ADDR_EXPR_P (addr) || DECL_P (TREE_OPERAND (addr, 0))) return fold_build2 (MEM_REF, type, addr, diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c index e744d2a9cf8..ba34884f1ac 100644 --- a/gcc/gimple-low.c +++ b/gcc/gimple-low.c @@ -877,7 +877,7 @@ lower_builtin_posix_memalign (gimple_stmt_iterator *gsi) tree align = gimple_call_arg (call, 1); tree res = gimple_call_lhs (call); tree ptr = create_tmp_reg (ptr_type_node); - if (TREE_CODE (pptr) == ADDR_EXPR) + if (ADDR_EXPR_P (pptr)) { tree tem = create_tmp_var (ptr_type_node); TREE_ADDRESSABLE (tem) = 1; diff --git a/gcc/gimple-match-head.c b/gcc/gimple-match-head.c index 4a65be703b9..f47fe5b87ba 100644 --- a/gcc/gimple-match-head.c +++ b/gcc/gimple-match-head.c @@ -78,7 +78,7 @@ constant_for_folding (tree t) { return (CONSTANT_CLASS_P (t) /* The following is only interesting to string builtins. */ - || (TREE_CODE (t) == ADDR_EXPR + || (ADDR_EXPR_P (t) && TREE_CODE (TREE_OPERAND (t, 0)) == STRING_CST)); } @@ -1024,7 +1024,7 @@ gimple_simplify (gimple *stmt, gimple_match_op *res_op, gimple_seq *seq, return false; fn = do_valueize (fn, top_valueize, valueized); - if (TREE_CODE (fn) != ADDR_EXPR + if (!ADDR_EXPR_P (fn) || TREE_CODE (TREE_OPERAND (fn, 0)) != FUNCTION_DECL) return false; diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index 90a9e52a71c..10228ea0795 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -954,7 +954,7 @@ dump_gimple_call (pretty_printer *buffer, const gcall *gs, int spc, return; /* Dump the arguments of _ITM_beginTransaction sanely. */ - if (TREE_CODE (fn) == ADDR_EXPR) + if (ADDR_EXPR_P (fn)) fn = TREE_OPERAND (fn, 0); if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn)) pp_string (buffer, " [tm-clone]"); diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c index f3ffd426ca6..30f57ff63f3 100644 --- a/gcc/gimple-ssa-isolate-paths.c +++ b/gcc/gimple-ssa-isolate-paths.c @@ -427,7 +427,7 @@ static bool is_addr_local (gimple *return_stmt, tree exp, locmap_t *plocmap, hash_set *visited) { - if (TREE_CODE (exp) == ADDR_EXPR) + if (ADDR_EXPR_P (exp)) { tree baseaddr = get_base_address (TREE_OPERAND (exp, 0)); if (TREE_CODE (baseaddr) == MEM_REF) diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c index 7d5c1f0cf50..2355709fa2b 100644 --- a/gcc/gimple-ssa-sprintf.c +++ b/gcc/gimple-ssa-sprintf.c @@ -2331,7 +2331,7 @@ get_origin_and_offset (tree x, HOST_WIDE_INT *fldoff, HOST_WIDE_INT *off) if (off) { tree xtype - = (TREE_CODE (x) == ADDR_EXPR + = (ADDR_EXPR_P (x) ? TREE_TYPE (TREE_OPERAND (x, 0)) : TREE_TYPE (TREE_TYPE (x))); /* The byte offset of the most basic struct member the byte diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c index 512fc138528..6c1534e01df 100644 --- a/gcc/gimple-ssa-warn-restrict.c +++ b/gcc/gimple-ssa-warn-restrict.c @@ -445,7 +445,7 @@ builtin_memref::set_base_and_offset (tree expr) } } - if (TREE_CODE (expr) == ADDR_EXPR) + if (ADDR_EXPR_P (expr)) expr = TREE_OPERAND (expr, 0); /* Stash the reference for offset validation. */ diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c index 87dd962e610..5031f2d9b0e 100644 --- a/gcc/gimple-streamer-in.c +++ b/gcc/gimple-streamer-in.c @@ -162,7 +162,7 @@ input_gimple_stmt (class lto_input_block *ib, class data_in *data_in, continue; opp = gimple_op_ptr (stmt, i); - if (TREE_CODE (*opp) == ADDR_EXPR) + if (ADDR_EXPR_P (*opp)) opp = &TREE_OPERAND (*opp, 0); while (handled_component_p (*opp)) opp = &TREE_OPERAND (*opp, 0); @@ -171,7 +171,7 @@ input_gimple_stmt (class lto_input_block *ib, class data_in *data_in, here if the prevailing decl allows for this. ??? Maybe we should simply fold all stmts. */ if (TREE_CODE (*opp) == MEM_REF - && TREE_CODE (TREE_OPERAND (*opp, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (*opp, 0)) && integer_zerop (TREE_OPERAND (*opp, 1)) && (TREE_THIS_VOLATILE (*opp) == TREE_THIS_VOLATILE diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c index 232453713dc..822bdbc321f 100644 --- a/gcc/gimple-streamer-out.c +++ b/gcc/gimple-streamer-out.c @@ -142,7 +142,7 @@ output_gimple_stmt (struct output_block *ob, struct function *fn, gimple *stmt) if (!flag_wpa && op && (i || !is_gimple_debug (stmt))) { basep = &op; - if (TREE_CODE (*basep) == ADDR_EXPR) + if (ADDR_EXPR_P (*basep)) basep = &TREE_OPERAND (*basep, 0); while (handled_component_p (*basep)) basep = &TREE_OPERAND (*basep, 0); diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c index a1ae3aa4060..a4b42151b42 100644 --- a/gcc/gimple-walk.c +++ b/gcc/gimple-walk.c @@ -746,14 +746,14 @@ walk_stmt_load_store_addr_ops (gimple *stmt, void *data, rhs = TREE_OPERAND (rhs, 0); if (visit_addr) { - if (TREE_CODE (rhs) == ADDR_EXPR) + if (ADDR_EXPR_P (rhs)) ret |= visit_addr (stmt, TREE_OPERAND (rhs, 0), arg, data); else if (TREE_CODE (rhs) == TARGET_MEM_REF - && TREE_CODE (TMR_BASE (rhs)) == ADDR_EXPR) + && ADDR_EXPR_P (TMR_BASE (rhs))) ret |= visit_addr (stmt, TREE_OPERAND (TMR_BASE (rhs), 0), arg, data); else if (TREE_CODE (rhs) == OBJ_TYPE_REF - && TREE_CODE (OBJ_TYPE_REF_OBJECT (rhs)) == ADDR_EXPR) + && ADDR_EXPR_P (OBJ_TYPE_REF_OBJECT (rhs))) ret |= visit_addr (stmt, TREE_OPERAND (OBJ_TYPE_REF_OBJECT (rhs), 0), arg, data); else if (TREE_CODE (rhs) == CONSTRUCTOR) @@ -762,17 +762,17 @@ walk_stmt_load_store_addr_ops (gimple *stmt, void *data, tree val; FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (rhs), ix, val) - if (TREE_CODE (val) == ADDR_EXPR) + if (ADDR_EXPR_P (val)) ret |= visit_addr (stmt, TREE_OPERAND (val, 0), arg, data); else if (TREE_CODE (val) == OBJ_TYPE_REF - && TREE_CODE (OBJ_TYPE_REF_OBJECT (val)) == ADDR_EXPR) + && ADDR_EXPR_P (OBJ_TYPE_REF_OBJECT (val))) ret |= visit_addr (stmt, TREE_OPERAND (OBJ_TYPE_REF_OBJECT (val), 0), arg, data); } lhs = gimple_assign_lhs (stmt); if (TREE_CODE (lhs) == TARGET_MEM_REF - && TREE_CODE (TMR_BASE (lhs)) == ADDR_EXPR) + && ADDR_EXPR_P (TMR_BASE (lhs))) ret |= visit_addr (stmt, TREE_OPERAND (TMR_BASE (lhs), 0), lhs, data); } if (visit_load) @@ -791,16 +791,16 @@ walk_stmt_load_store_addr_ops (gimple *stmt, void *data, tree op = gimple_op (stmt, i); if (op == NULL_TREE) ; - else if (TREE_CODE (op) == ADDR_EXPR) + else if (ADDR_EXPR_P (op)) ret |= visit_addr (stmt, TREE_OPERAND (op, 0), op, data); /* COND_EXPR and VCOND_EXPR rhs1 argument is a comparison tree with two operands. */ else if (i == 1 && COMPARISON_CLASS_P (op)) { - if (TREE_CODE (TREE_OPERAND (op, 0)) == ADDR_EXPR) + if (ADDR_EXPR_P (TREE_OPERAND (op, 0))) ret |= visit_addr (stmt, TREE_OPERAND (TREE_OPERAND (op, 0), 0), op, data); - if (TREE_CODE (TREE_OPERAND (op, 1)) == ADDR_EXPR) + if (ADDR_EXPR_P (TREE_OPERAND (op, 1))) ret |= visit_addr (stmt, TREE_OPERAND (TREE_OPERAND (op, 1), 0), op, data); } @@ -823,7 +823,7 @@ walk_stmt_load_store_addr_ops (gimple *stmt, void *data, { tree arg = gimple_call_arg (call_stmt, i); if (visit_addr - && TREE_CODE (arg) == ADDR_EXPR) + && ADDR_EXPR_P (arg)) ret |= visit_addr (stmt, TREE_OPERAND (arg, 0), arg, data); else if (visit_load) { @@ -834,7 +834,7 @@ walk_stmt_load_store_addr_ops (gimple *stmt, void *data, } if (visit_addr && gimple_call_chain (call_stmt) - && TREE_CODE (gimple_call_chain (call_stmt)) == ADDR_EXPR) + && ADDR_EXPR_P (gimple_call_chain (call_stmt))) ret |= visit_addr (stmt, TREE_OPERAND (gimple_call_chain (call_stmt), 0), gimple_call_chain (call_stmt), data); if (visit_addr @@ -876,7 +876,7 @@ walk_stmt_load_store_addr_ops (gimple *stmt, void *data, tree link = gimple_asm_input_op (asm_stmt, i); tree op = TREE_VALUE (link); if (visit_addr - && TREE_CODE (op) == ADDR_EXPR) + && ADDR_EXPR_P (op)) ret |= visit_addr (stmt, TREE_OPERAND (op, 0), op, data); else if (visit_load || visit_addr) { @@ -906,7 +906,7 @@ walk_stmt_load_store_addr_ops (gimple *stmt, void *data, if (op) { if (visit_addr - && TREE_CODE (op) == ADDR_EXPR) + && ADDR_EXPR_P (op)) ret |= visit_addr (stmt, TREE_OPERAND (op, 0), op, data); else if (visit_load) { @@ -922,7 +922,7 @@ walk_stmt_load_store_addr_ops (gimple *stmt, void *data, for (i = 0; i < gimple_phi_num_args (stmt); ++i) { tree op = gimple_phi_arg_def (stmt, i); - if (TREE_CODE (op) == ADDR_EXPR) + if (ADDR_EXPR_P (op)) ret |= visit_addr (stmt, TREE_OPERAND (op, 0), op, data); } } @@ -930,7 +930,7 @@ walk_stmt_load_store_addr_ops (gimple *stmt, void *data, && gimple_code (stmt) == GIMPLE_GOTO) { tree op = gimple_goto_dest (stmt); - if (TREE_CODE (op) == ADDR_EXPR) + if (ADDR_EXPR_P (op)) ret |= visit_addr (stmt, TREE_OPERAND (op, 0), op, data); } diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 23d0e2511f7..9e841f5573a 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2714,7 +2714,7 @@ canonicalize_addr_expr (tree *expr_p) /* We simplify only conversions from an ADDR_EXPR to a pointer type. */ if (!POINTER_TYPE_P (TREE_TYPE (expr)) - || TREE_CODE (addr_expr) != ADDR_EXPR) + || !ADDR_EXPR_P (addr_expr)) return; /* The addr_expr type should be a pointer to an array. */ @@ -2778,7 +2778,7 @@ gimplify_conversion (tree *expr_p) /* If a NOP conversion is changing a pointer to array of foo to a pointer to foo, embed that change in the ADDR_EXPR. */ - else if (TREE_CODE (sub) == ADDR_EXPR) + else if (ADDR_EXPR_P (sub)) canonicalize_addr_expr (expr_p); } @@ -6462,7 +6462,7 @@ gimplify_asm_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) while (handled_component_p (x)) x = TREE_OPERAND (x, 0); if (TREE_CODE (x) == MEM_REF - && TREE_CODE (TREE_OPERAND (x, 0)) == ADDR_EXPR) + && ADDR_EXPR_P (TREE_OPERAND (x, 0))) x = TREE_OPERAND (TREE_OPERAND (x, 0), 0); if ((VAR_P (x) || TREE_CODE (x) == PARM_DECL @@ -8627,7 +8627,7 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, } decl = TREE_OPERAND (decl, 0); } - if (TREE_CODE (decl) == ADDR_EXPR + if (ADDR_EXPR_P (decl) || TREE_CODE (decl) == INDIRECT_REF) decl = TREE_OPERAND (decl, 0); } @@ -9498,13 +9498,11 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, && (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION || decl == OMP_CLAUSE_DECL (c) || (TREE_CODE (OMP_CLAUSE_DECL (c)) == MEM_REF - && (TREE_CODE (TREE_OPERAND (OMP_CLAUSE_DECL (c), 0)) - == ADDR_EXPR + && (ADDR_EXPR_P (TREE_OPERAND (OMP_CLAUSE_DECL (c), 0)) || (TREE_CODE (TREE_OPERAND (OMP_CLAUSE_DECL (c), 0)) == POINTER_PLUS_EXPR - && (TREE_CODE (TREE_OPERAND (TREE_OPERAND - (OMP_CLAUSE_DECL (c), 0), 0)) - == ADDR_EXPR))))) + && ADDR_EXPR_P (TREE_OPERAND (TREE_OPERAND + (OMP_CLAUSE_DECL (c), 0), 0)))))) && omp_check_private (ctx, decl, false)) { error ("%s variable %qE is private in outer context", @@ -9822,7 +9820,7 @@ omp_find_stores_op (tree *tp, int *walk_subtrees, void *data) if (handled_component_p (op)) op = TREE_OPERAND (op, 0); else if ((TREE_CODE (op) == MEM_REF || TREE_CODE (op) == TARGET_MEM_REF) - && TREE_CODE (TREE_OPERAND (op, 0)) == ADDR_EXPR) + && ADDR_EXPR_P (TREE_OPERAND (op, 0))) op = TREE_OPERAND (TREE_OPERAND (op, 0), 0); else break; @@ -13087,11 +13085,11 @@ goa_lhs_expr_p (tree expr, tree addr) } if (expr == addr) return true; - return (TREE_CODE (addr) == ADDR_EXPR - && TREE_CODE (expr) == ADDR_EXPR + return (ADDR_EXPR_P (addr) + && ADDR_EXPR_P (expr) && TREE_OPERAND (addr, 0) == TREE_OPERAND (expr, 0)); } - if (TREE_CODE (addr) == ADDR_EXPR && expr == TREE_OPERAND (addr, 0)) + if (ADDR_EXPR_P (addr) && expr == TREE_OPERAND (addr, 0)) return true; return false; } diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc index fd96481b12d..09221c0efd1 100644 --- a/gcc/go/go-gcc.cc +++ b/gcc/go/go-gcc.cc @@ -2102,7 +2102,7 @@ Gcc_backend::call_expression(Bfunction*, // containing fcn for call } tree fndecl = fn; - if (TREE_CODE(fndecl) == ADDR_EXPR) + if (ADDR_EXPR_P(fndecl)) fndecl = TREE_OPERAND(fndecl, 0); // This is to support builtin math functions when using 80387 math. diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c index c75d8dfa7d1..9a1e8878cb6 100644 --- a/gcc/internal-fn.c +++ b/gcc/internal-fn.c @@ -2465,7 +2465,7 @@ expand_call_mem_ref (tree type, gcall *stmt, int index) tmp = gimple_assign_rhs1 (def); } - if (TREE_CODE (tmp) == ADDR_EXPR) + if (ADDR_EXPR_P (tmp)) { tree mem = TREE_OPERAND (tmp, 0); if (TREE_CODE (mem) == TARGET_MEM_REF diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 959a9960e49..176db54ee28 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -428,7 +428,7 @@ ipcp_lattice::is_single_const () static void print_ipcp_constant_value (FILE * f, tree v) { - if (TREE_CODE (v) == ADDR_EXPR + if (ADDR_EXPR_P (v) && TREE_CODE (TREE_OPERAND (v, 0)) == CONST_DECL) { fprintf (f, "& "); @@ -1353,7 +1353,7 @@ static tree ipa_get_jf_ancestor_result (struct ipa_jump_func *jfunc, tree input) { gcc_checking_assert (TREE_CODE (input) != TREE_BINFO); - if (TREE_CODE (input) == ADDR_EXPR) + if (ADDR_EXPR_P (input)) { gcc_checking_assert (is_gimple_ip_invariant_address (input)); poly_int64 off = ipa_get_jf_ancestor_offset (jfunc); @@ -1752,8 +1752,8 @@ values_equal_for_ipcp_p (tree x, tree y) if (x == y) return true; - if (TREE_CODE (x) == ADDR_EXPR - && TREE_CODE (y) == ADDR_EXPR + if (ADDR_EXPR_P (x) + && ADDR_EXPR_P (y) && TREE_CODE (TREE_OPERAND (x, 0)) == CONST_DECL && TREE_CODE (TREE_OPERAND (y, 0)) == CONST_DECL) return operand_equal_p (DECL_INITIAL (TREE_OPERAND (x, 0)), @@ -2992,7 +2992,7 @@ ipa_get_indirect_edge_target_1 (struct cgraph_edge *ie, t = known_csts[param_index]; if (t - && TREE_CODE (t) == ADDR_EXPR + && ADDR_EXPR_P (t) && TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL) return TREE_OPERAND (t, 0); else diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index 3ab7049734f..696250c7208 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -2818,9 +2818,9 @@ vtable_pointer_value_to_vtable (const_tree t, tree *v, In the case of virtual inheritance, the virtual tables may be nested, i.e. the offset may be different from 16 and we may need to dive into the type representation. */ - if (TREE_CODE (t) == ADDR_EXPR + if (ADDR_EXPR_P (t) && TREE_CODE (TREE_OPERAND (t, 0)) == MEM_REF - && TREE_CODE (TREE_OPERAND (TREE_OPERAND (t, 0), 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (TREE_OPERAND (t, 0), 0)) && TREE_CODE (TREE_OPERAND (TREE_OPERAND (t, 0), 1)) == INTEGER_CST && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (t, 0), 0), 0)) == VAR_DECL) @@ -2843,7 +2843,7 @@ vtable_pointer_value_to_vtable (const_tree t, tree *v, else *offset = 0; - if (TREE_CODE (t) != ADDR_EXPR) + if (!ADDR_EXPR_P (t)) return false; *v = TREE_OPERAND (t, 0); return true; diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c index cd56362c11e..85ccda3835e 100644 --- a/gcc/ipa-fnsummary.c +++ b/gcc/ipa-fnsummary.c @@ -1264,7 +1264,7 @@ eliminated_by_inlining_prob (ipa_func_body_info *fbi, gimple *stmt) rhs_free = true; /* Match expressions of form &this->field. Those will most likely combine with something upstream after inlining. */ - else if (TREE_CODE (inner_rhs) == ADDR_EXPR) + else if (ADDR_EXPR_P (inner_rhs)) { tree op = get_base_address (TREE_OPERAND (inner_rhs, 0)); if (TREE_CODE (op) == PARM_DECL) diff --git a/gcc/ipa-param-manipulation.c b/gcc/ipa-param-manipulation.c index 92b2df7f72b..8d28db1c48b 100644 --- a/gcc/ipa-param-manipulation.c +++ b/gcc/ipa-param-manipulation.c @@ -669,7 +669,7 @@ ipa_param_adjustments::modify_call (gcall *stmt, tree off; bool deref_base = false; unsigned int deref_align = 0; - if (TREE_CODE (base) != ADDR_EXPR + if (!ADDR_EXPR_P (base) && is_gimple_reg_type (TREE_TYPE (base))) { /* Detect type mismatches in calls in invalid programs and make a @@ -682,7 +682,7 @@ ipa_param_adjustments::modify_call (gcall *stmt, else { bool addrof; - if (TREE_CODE (base) == ADDR_EXPR) + if (ADDR_EXPR_P (base)) { base = TREE_OPERAND (base, 0); addrof = true; diff --git a/gcc/ipa-polymorphic-call.c b/gcc/ipa-polymorphic-call.c index 65516b6d7b2..846477ca094 100644 --- a/gcc/ipa-polymorphic-call.c +++ b/gcc/ipa-polymorphic-call.c @@ -766,7 +766,7 @@ ipa_polymorphic_call_context::set_by_invariant (tree cst, off = 0; clear_outer_type (otr_type); - if (TREE_CODE (cst) != ADDR_EXPR) + if (!ADDR_EXPR_P (cst)) return false; cst = TREE_OPERAND (cst, 0); @@ -896,7 +896,7 @@ ipa_polymorphic_call_context::ipa_polymorphic_call_context (tree fndecl, while (true) { base_pointer = walk_ssa_copies (base_pointer, &visited); - if (TREE_CODE (base_pointer) == ADDR_EXPR) + if (ADDR_EXPR_P (base_pointer)) { HOST_WIDE_INT offset2, size; bool reverse; @@ -1443,7 +1443,7 @@ check_stmt_for_type_change (ao_ref *ao ATTRIBUTE_UNUSED, tree vdef, void *data) } /* See if THIS parameter seems like instance pointer. */ - if (TREE_CODE (op) == ADDR_EXPR) + if (ADDR_EXPR_P (op)) { HOST_WIDE_INT size; op = get_ref_base_and_extent_hwi (TREE_OPERAND (op, 0), diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 269c6a53e88..b33c0c5c695 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -321,7 +321,7 @@ ipa_print_node_jump_functions_for_edge (FILE *f, struct cgraph_edge *cs) tree val = jump_func->value.constant.value; fprintf (f, "CONST: "); print_generic_expr (f, val); - if (TREE_CODE (val) == ADDR_EXPR + if (ADDR_EXPR_P (val) && TREE_CODE (TREE_OPERAND (val, 0)) == CONST_DECL) { fprintf (f, " -> "); @@ -538,7 +538,7 @@ ipa_set_jf_constant (struct ipa_jump_func *jfunc, tree constant, jfunc->type = IPA_JF_CONST; jfunc->value.constant.value = unshare_expr_without_location (constant); - if (TREE_CODE (constant) == ADDR_EXPR + if (ADDR_EXPR_P (constant) && TREE_CODE (TREE_OPERAND (constant, 0)) == FUNCTION_DECL) { struct ipa_cst_ref_desc *rdesc; @@ -1338,7 +1338,7 @@ compute_complex_assign_jump_func (struct ipa_func_body_info *fbi, return; } - if (TREE_CODE (op1) != ADDR_EXPR) + if (!ADDR_EXPR_P (op1)) return; op1 = TREE_OPERAND (op1, 0); if (TREE_CODE (TREE_TYPE (op1)) != RECORD_TYPE) @@ -1385,7 +1385,7 @@ get_ancestor_addr_info (gimple *assign, tree *obj_p, HOST_WIDE_INT *offset) return NULL_TREE; expr = gimple_assign_rhs1 (assign); - if (TREE_CODE (expr) != ADDR_EXPR) + if (!ADDR_EXPR_P (expr)) return NULL_TREE; expr = TREE_OPERAND (expr, 0); obj = expr; @@ -1879,7 +1879,7 @@ determine_known_aggregate_parts (struct ipa_func_body_info *fbi, arg_size = tree_to_uhwi (type_size); ao_ref_init_from_ptr_and_size (&r, arg_base, NULL_TREE); } - else if (TREE_CODE (arg) == ADDR_EXPR) + else if (ADDR_EXPR_P (arg)) { bool reverse; @@ -2327,7 +2327,7 @@ ipa_get_stmt_member_ptr_load_param (gimple *stmt, bool use_delta, if (TREE_CODE (rhs) != MEM_REF) return NULL_TREE; rec = TREE_OPERAND (rhs, 0); - if (TREE_CODE (rec) != ADDR_EXPR) + if (!ADDR_EXPR_P (rec)) return NULL_TREE; rec = TREE_OPERAND (rec, 0); if (TREE_CODE (rec) != PARM_DECL @@ -3176,7 +3176,7 @@ ipa_make_edge_direct_to_target (struct cgraph_edge *ie, tree target, struct cgraph_node *callee; bool unreachable = false; - if (TREE_CODE (target) == ADDR_EXPR) + if (ADDR_EXPR_P (target)) target = TREE_OPERAND (target, 0); if (TREE_CODE (target) != FUNCTION_DECL) { @@ -3414,7 +3414,7 @@ ipa_find_agg_cst_from_init (tree scalar, HOST_WIDE_INT offset, bool by_ref) { if (by_ref) { - if (TREE_CODE (scalar) != ADDR_EXPR) + if (!ADDR_EXPR_P (scalar)) return NULL; scalar = TREE_OPERAND (scalar, 0); } @@ -3520,7 +3520,7 @@ cgraph_node_for_jfunc (struct ipa_jump_func *jfunc) { gcc_checking_assert (jfunc->type == IPA_JF_CONST); tree cst = ipa_get_jf_constant (jfunc); - if (TREE_CODE (cst) != ADDR_EXPR + if (!ADDR_EXPR_P (cst) || TREE_CODE (TREE_OPERAND (cst, 0)) != FUNCTION_DECL) return NULL; @@ -3966,7 +3966,7 @@ propagate_controlled_uses (struct cgraph_edge *cs) struct ipa_ref *ref; tree t = new_root_info->known_csts[src_idx]; - if (t && TREE_CODE (t) == ADDR_EXPR + if (t && ADDR_EXPR_P (t) && TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL && (n = cgraph_node::get (TREE_OPERAND (t, 0))) && (ref = new_root->find_reference (n, NULL, 0))) @@ -3990,7 +3990,7 @@ propagate_controlled_uses (struct cgraph_edge *cs) { tree cst = ipa_get_jf_constant (jf); struct cgraph_node *n; - gcc_checking_assert (TREE_CODE (cst) == ADDR_EXPR + gcc_checking_assert (ADDR_EXPR_P (cst) && TREE_CODE (TREE_OPERAND (cst, 0)) == FUNCTION_DECL); n = cgraph_node::get (TREE_OPERAND (cst, 0)); @@ -4493,7 +4493,7 @@ ipa_write_jump_function (struct output_block *ob, /* ADDR_EXPRs are very comon IP invariants; save some streamer data as well as WPA memory by handling them specially. */ if (jump_func->type == IPA_JF_CONST - && TREE_CODE (jump_func->value.constant.value) == ADDR_EXPR) + && ADDR_EXPR_P (jump_func->value.constant.value)) flag = 1; streamer_write_uhwi (ob, jump_func->type * 2 + flag); diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 54af1cff533..27842c3ca03 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -5202,7 +5202,7 @@ receiver_is_class_object (tree receiver, int self, int super) to silence the warnings. */ if (TREE_CODE (receiver) == CALL_EXPR && (exp = CALL_EXPR_FN (receiver)) - && TREE_CODE (exp) == ADDR_EXPR + && ADDR_EXPR_P (exp) && (exp = TREE_OPERAND (exp, 0)) && TREE_CODE (exp) == FUNCTION_DECL /* For some reason, we sometimes wind up with multiple FUNCTION_DECL @@ -5214,7 +5214,7 @@ receiver_is_class_object (tree receiver, int self, int super) && (arg = CALL_EXPR_ARG (receiver, 0))) { STRIP_NOPS (arg); - if (TREE_CODE (arg) == ADDR_EXPR + if (ADDR_EXPR_P (arg) && (arg = TREE_OPERAND (arg, 0)) && TREE_CODE (arg) == STRING_CST) /* Finally, we have the class name. */ @@ -9436,7 +9436,7 @@ tree objc_rewrite_function_call (tree function, tree first_param) { if (TREE_CODE (function) == NOP_EXPR - && TREE_CODE (TREE_OPERAND (function, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (function, 0)) && TREE_CODE (TREE_OPERAND (TREE_OPERAND (function, 0), 0)) == FUNCTION_DECL) { @@ -9510,7 +9510,7 @@ objc_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) of a function in OBJ_TYPE_REF_EXPR (presumably objc_msgSend or one of its cousins). */ case OBJ_TYPE_REF: - if (TREE_CODE (OBJ_TYPE_REF_EXPR (*expr_p)) == ADDR_EXPR + if (ADDR_EXPR_P (OBJ_TYPE_REF_EXPR (*expr_p)) && TREE_CODE (TREE_OPERAND (OBJ_TYPE_REF_EXPR (*expr_p), 0)) == FUNCTION_DECL) { diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c index 8f1286e3176..dd606665f93 100644 --- a/gcc/omp-expand.c +++ b/gcc/omp-expand.c @@ -1160,7 +1160,7 @@ expand_omp_regimplify_p (tree *tp, int *walk_subtrees, void *) if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t)) return t; - if (TREE_CODE (t) == ADDR_EXPR) + if (ADDR_EXPR_P (t)) recompute_tree_invariant_for_addr_expr (t); *walk_subtrees = !TYPE_P (t) && !DECL_P (t); @@ -1293,7 +1293,7 @@ expand_omp_taskreg (struct omp_region *region) /* We're ignore the subcode because we're effectively doing a STRIP_NOPS. */ - if (TREE_CODE (arg) == ADDR_EXPR + if (ADDR_EXPR_P (arg) && (TREE_OPERAND (arg, 0) == gimple_omp_taskreg_data_arg (entry_stmt))) { @@ -9010,7 +9010,7 @@ expand_omp_target (struct omp_region *region) /* We're ignoring the subcode because we're effectively doing a STRIP_NOPS. */ - if (TREE_CODE (arg) == ADDR_EXPR + if (ADDR_EXPR_P (arg) && TREE_OPERAND (arg, 0) == sender) { tgtcopy_stmt = stmt; diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 53efe5f750c..29cc8fa5128 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -1169,7 +1169,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) if (TREE_CODE (t) == POINTER_PLUS_EXPR) t = TREE_OPERAND (t, 0); if (TREE_CODE (t) == INDIRECT_REF - || TREE_CODE (t) == ADDR_EXPR) + || ADDR_EXPR_P (t)) t = TREE_OPERAND (t, 0); install_var_local (t, ctx); if (is_taskreg_ctx (ctx) @@ -4570,7 +4570,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, if (TREE_CODE (var) == POINTER_PLUS_EXPR) var = TREE_OPERAND (var, 0); if (TREE_CODE (var) == INDIRECT_REF - || TREE_CODE (var) == ADDR_EXPR) + || ADDR_EXPR_P (var)) var = TREE_OPERAND (var, 0); if (is_variable_sized (var)) { @@ -4641,7 +4641,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, } if (TREE_CODE (orig_var) == INDIRECT_REF) x = build_simple_mem_ref (x); - else if (TREE_CODE (orig_var) == ADDR_EXPR) + else if (ADDR_EXPR_P (orig_var)) { if (var == TREE_OPERAND (orig_var, 0)) x = build_fold_addr_expr (x); @@ -4663,7 +4663,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, } if (TREE_CODE (orig_var) == INDIRECT_REF - || TREE_CODE (orig_var) == ADDR_EXPR) + || ADDR_EXPR_P (orig_var)) orig_var = TREE_OPERAND (orig_var, 0); tree d = OMP_CLAUSE_DECL (c); tree type = TREE_TYPE (d); @@ -4778,7 +4778,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, d = TREE_OPERAND (d, 0); if (TREE_CODE (d) == POINTER_PLUS_EXPR) d = TREE_OPERAND (d, 0); - if (TREE_CODE (d) == ADDR_EXPR) + if (ADDR_EXPR_P (d)) { if (orig_var != var) { @@ -4884,7 +4884,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, /* For ref build_outer_var_ref already performs this. */ if (TREE_CODE (d) == INDIRECT_REF) gcc_assert (omp_is_reference (var)); - else if (TREE_CODE (d) == ADDR_EXPR) + else if (ADDR_EXPR_P (d)) ref = build_fold_addr_expr (ref); else if (omp_is_reference (var)) ref = build_fold_addr_expr (ref); @@ -6928,7 +6928,7 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, var = TREE_OPERAND (var, 0); if (TREE_CODE (var) == POINTER_PLUS_EXPR) var = TREE_OPERAND (var, 0); - if (TREE_CODE (var) == ADDR_EXPR) + if (ADDR_EXPR_P (var)) var = TREE_OPERAND (var, 0); else { @@ -7008,7 +7008,7 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, new_var = build_simple_mem_ref_loc (clause_loc, new_var); gcc_assert (omp_is_reference (var) && var == orig_var); } - else if (TREE_CODE (d) == ADDR_EXPR) + else if (ADDR_EXPR_P (d)) { if (orig_var == var) { @@ -7244,7 +7244,7 @@ lower_send_clauses (tree clauses, gimple_seq *ilist, gimple_seq *olist, if (TREE_CODE (val) == POINTER_PLUS_EXPR) val = TREE_OPERAND (val, 0); if (TREE_CODE (val) == INDIRECT_REF - || TREE_CODE (val) == ADDR_EXPR) + || ADDR_EXPR_P (val)) val = TREE_OPERAND (val, 0); if (is_variable_sized (val)) continue; @@ -8326,7 +8326,7 @@ lower_omp_task_reductions (omp_context *ctx, enum tree_code code, tree clauses, if (TREE_CODE (var) == POINTER_PLUS_EXPR) var = TREE_OPERAND (var, 0); tree v = var; - if (TREE_CODE (var) == ADDR_EXPR) + if (ADDR_EXPR_P (var)) var = TREE_OPERAND (var, 0); else if (TREE_CODE (var) == INDIRECT_REF) var = TREE_OPERAND (var, 0); @@ -8341,8 +8341,8 @@ lower_omp_task_reductions (omp_context *ctx, enum tree_code code, tree clauses, } t = ref = maybe_lookup_decl_in_outer_ctx (var, ctx); if (orig_var != var) - gcc_assert (TREE_CODE (v) == ADDR_EXPR); - else if (TREE_CODE (v) == ADDR_EXPR) + gcc_assert (ADDR_EXPR_P (v)); + else if (ADDR_EXPR_P (v)) t = build_fold_addr_expr (t); else if (TREE_CODE (v) == INDIRECT_REF) t = build_fold_indirect_ref (t); @@ -9148,7 +9148,7 @@ lower_omp_scan (gimple_stmt_iterator *gsi_p, omp_context *ctx) val = DECL_VALUE_EXPR (new_vard); if (new_vard != new_var) { - gcc_assert (TREE_CODE (val) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (val)); val = TREE_OPERAND (val, 0); } if (TREE_CODE (val) == ARRAY_REF @@ -10549,7 +10549,7 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx) } else if (!is_gimple_min_invariant (*rhs_p)) *rhs_p = get_formal_tmp_var (*rhs_p, &cnt_list); - else if (TREE_CODE (*rhs_p) == ADDR_EXPR) + else if (ADDR_EXPR_P (*rhs_p)) recompute_tree_invariant_for_addr_expr (*rhs_p); rhs_p = gimple_omp_for_final_ptr (stmt, i); @@ -10564,7 +10564,7 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx) } else if (!is_gimple_min_invariant (*rhs_p)) *rhs_p = get_formal_tmp_var (*rhs_p, &cnt_list); - else if (TREE_CODE (*rhs_p) == ADDR_EXPR) + else if (ADDR_EXPR_P (*rhs_p)) recompute_tree_invariant_for_addr_expr (*rhs_p); rhs_p = &TREE_OPERAND (gimple_omp_for_incr (stmt, i), 1); @@ -10884,7 +10884,7 @@ create_task_copyfn (gomp_task *task_stmt, omp_context *ctx) if (TREE_CODE (decl) == POINTER_PLUS_EXPR) decl = TREE_OPERAND (decl, 0); if (TREE_CODE (decl) == INDIRECT_REF - || TREE_CODE (decl) == ADDR_EXPR) + || ADDR_EXPR_P (decl)) decl = TREE_OPERAND (decl, 0); } key = (splay_tree_key) decl; @@ -12626,7 +12626,7 @@ lower_omp_regimplify_p (tree *tp, int *walk_subtrees, /* If a global variable has been privatized, TREE_CONSTANT on ADDR_EXPR might be wrong. */ - if (data == NULL && TREE_CODE (t) == ADDR_EXPR) + if (data == NULL && ADDR_EXPR_P (t)) recompute_tree_invariant_for_addr_expr (t); *walk_subtrees = !IS_TYPE_OR_DECL_P (t); diff --git a/gcc/omp-offload.c b/gcc/omp-offload.c index 32c2485abd4..d0d5e1904e2 100644 --- a/gcc/omp-offload.c +++ b/gcc/omp-offload.c @@ -2001,7 +2001,7 @@ ompdevlow_adjust_simt_enter (gimple_stmt_iterator *gsi, bool *regimplify) tree *argp = gimple_call_arg_ptr (enter_stmt, i); if (*argp == null_pointer_node) continue; - gcc_assert (TREE_CODE (*argp) == ADDR_EXPR + gcc_assert (ADDR_EXPR_P (*argp) && VAR_P (TREE_OPERAND (*argp, 0))); tree var = TREE_OPERAND (*argp, 0); diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c index 942fb971cb7..2885f223fc0 100644 --- a/gcc/omp-simd-clone.c +++ b/gcc/omp-simd-clone.c @@ -839,7 +839,7 @@ ipa_simd_modify_stmt_ops (tree *tp, int *walk_subtrees, void *data) struct walk_stmt_info *wi = (struct walk_stmt_info *) data; struct modify_stmt_info *info = (struct modify_stmt_info *) wi->info; tree *orig_tp = tp; - if (TREE_CODE (*tp) == ADDR_EXPR) + if (ADDR_EXPR_P (*tp)) tp = &TREE_OPERAND (*tp, 0); if (TREE_CODE (*tp) == BIT_FIELD_REF @@ -885,7 +885,7 @@ ipa_simd_modify_stmt_ops (tree *tp, int *walk_subtrees, void *data) { if (gimple_code (info->stmt) == GIMPLE_PHI && pbr - && TREE_CODE (*orig_tp) == ADDR_EXPR + && ADDR_EXPR_P (*orig_tp) && TREE_CODE (TREE_OPERAND (*orig_tp, 0)) == PARM_DECL && pbr->dummy) { @@ -920,7 +920,7 @@ ipa_simd_modify_stmt_ops (tree *tp, int *walk_subtrees, void *data) gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun))); /* Cache SSA_NAME for next time. */ if (pbr - && TREE_CODE (*orig_tp) == ADDR_EXPR + && ADDR_EXPR_P (*orig_tp) && TREE_CODE (TREE_OPERAND (*orig_tp, 0)) == PARM_DECL) { gcc_assert (!pbr->dummy); diff --git a/gcc/sanopt.c b/gcc/sanopt.c index 6c3bce92378..d23864ac758 100644 --- a/gcc/sanopt.c +++ b/gcc/sanopt.c @@ -483,7 +483,7 @@ maybe_optimize_ubsan_ptr_ifn (sanopt_ctx *ctx, gimple *stmt) return true; tree base = ptr; - if (TREE_CODE (base) == ADDR_EXPR) + if (ADDR_EXPR_P (base)) { base = TREE_OPERAND (base, 0); diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 07a036a186e..43f346b95ac 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -191,7 +191,7 @@ self_referential_size (tree size) subst = ref; } /* This is the pattern built in ada/make_aligning_type. */ - else if (TREE_CODE (ref) == ADDR_EXPR) + else if (ADDR_EXPR_P (ref)) subst = ref; /* Default case: the component reference. */ else diff --git a/gcc/testsuite/g++.dg/plugin/selfassign.c b/gcc/testsuite/g++.dg/plugin/selfassign.c index 2c60c1810de..0c3438d72e2 100644 --- a/gcc/testsuite/g++.dg/plugin/selfassign.c +++ b/gcc/testsuite/g++.dg/plugin/selfassign.c @@ -241,10 +241,10 @@ warn_self_assign (gimple *stmt) ADDR_EXPR trees. In this case, just remove the address-taken operator before we compare the lhs and rhs. */ lhs = gimple_call_arg (stmt, 0); - if (TREE_CODE (lhs) == ADDR_EXPR) + if (ADDR_EXPR_P (lhs)) lhs = TREE_OPERAND (lhs, 0); rhs = gimple_call_arg (stmt, 1); - if (TREE_CODE (rhs) == ADDR_EXPR) + if (ADDR_EXPR_P (rhs)) rhs = TREE_OPERAND (rhs, 0); compare_and_warn (stmt, lhs, rhs); diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c index 67ca701adfa..28becf0f30c 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c @@ -116,7 +116,7 @@ test_groups (gimple *stmt) /* We expect an ADDR_EXPR with a STRING_CST inside it for the initial arg. */ tree t_addr_string = gimple_call_arg (call, 0); - if (TREE_CODE (t_addr_string) != ADDR_EXPR) + if (ADDR_EXPR_P (t_addr_string)) { error_at (call->location, "string literal required for arg 1"); return; diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c index 71e6740b178..e3f62f67dba 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c @@ -80,7 +80,7 @@ cb_walk_tree_fn (tree * tp, int * walk_subtrees, tree call_expr = *tp; tree fn = CALL_EXPR_FN (call_expr); - if (TREE_CODE (fn) != ADDR_EXPR) + if (!ADDR_EXPR_P (fn)) return NULL_TREE; fn = TREE_OPERAND (fn, 0); if (TREE_CODE (fn) != FUNCTION_DECL) diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c index 49b78ccf1fc..ffe4ea2356e 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c @@ -120,7 +120,7 @@ test_inlining (gimple *stmt) /* We expect an ADDR_EXPR with a STRING_CST inside it for the initial arg. */ tree t_addr_string = gimple_call_arg (call, 0); - if (TREE_CODE (t_addr_string) != ADDR_EXPR) + if (!ADDR_EXPR_P (t_addr_string)) { error_at (call->location, "string literal required for arg 1"); return; diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c index cf99697a417..2a3bc07d890 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c @@ -127,7 +127,7 @@ test_string_literals (gimple *stmt) /* We expect an ADDR_EXPR with a STRING_CST inside it for the initial arg. */ tree t_addr_string = gimple_call_arg (call, 0); - if (TREE_CODE (t_addr_string) != ADDR_EXPR) + if (!ADDR_EXPR_P (t_addr_string)) { error_at (call->location, "string literal required for arg 1"); return; diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c index 89cc95acd99..6d40285721f 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c @@ -54,7 +54,7 @@ cb_walk_tree_fn (tree * tp, int * walk_subtrees, tree call_expr = *tp; tree fn = CALL_EXPR_FN (call_expr); - if (TREE_CODE (fn) != ADDR_EXPR) + if (!ADDR_EXPR_P (fn)) return NULL_TREE; fn = TREE_OPERAND (fn, 0); if (TREE_CODE (fn) != FUNCTION_DECL) diff --git a/gcc/testsuite/gcc.dg/plugin/selfassign.c b/gcc/testsuite/gcc.dg/plugin/selfassign.c index 2adb6446b1d..0cdca99b0c6 100644 --- a/gcc/testsuite/gcc.dg/plugin/selfassign.c +++ b/gcc/testsuite/gcc.dg/plugin/selfassign.c @@ -241,10 +241,10 @@ warn_self_assign (gimple *stmt) ADDR_EXPR trees. In this case, just remove the address-taken operator before we compare the lhs and rhs. */ lhs = gimple_call_arg (stmt, 0); - if (TREE_CODE (lhs) == ADDR_EXPR) + if (!ADDR_EXPR_P (lhs)) lhs = TREE_OPERAND (lhs, 0); rhs = gimple_call_arg (stmt, 1); - if (TREE_CODE (rhs) == ADDR_EXPR) + if (!ADDR_EXPR_P (rhs)) rhs = TREE_OPERAND (rhs, 0); compare_and_warn (stmt, lhs, rhs); diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index 7f10b52bfb1..e892cab0f51 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -231,7 +231,7 @@ is_tm_irrevocable (tree x) /* A call to the irrevocable builtin is by definition, irrevocable. */ - if (TREE_CODE (x) == ADDR_EXPR) + if (ADDR_EXPR_P (x)) x = TREE_OPERAND (x, 0); if (TREE_CODE (x) == FUNCTION_DECL && fndecl_built_in_p (x, BUILT_IN_TM_IRREVOCABLE)) @@ -651,7 +651,7 @@ diagnose_tm_1 (gimple_stmt_iterator *gsi, bool *handled_ops_p, bool is_safe, direct_call_p; tree replacement; - if (TREE_CODE (fn) == ADDR_EXPR + if (ADDR_EXPR_P (fn) && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL) { direct_call_p = true; @@ -706,7 +706,7 @@ diagnose_tm_1 (gimple_stmt_iterator *gsi, bool *handled_ops_p, if (!is_safe) { - if (TREE_CODE (fn) == ADDR_EXPR) + if (ADDR_EXPR_P (fn)) fn = TREE_OPERAND (fn, 0); if (d->block_flags & DIAG_TM_SAFE) { @@ -1531,7 +1531,7 @@ requires_barrier (basic_block entry_block, tree x, gimple *stmt) } case TARGET_MEM_REF: - if (TREE_CODE (TMR_BASE (x)) != ADDR_EXPR) + if (!ADDR_EXPR_P (TMR_BASE (x))) return true; x = TREE_OPERAND (TMR_BASE (x), 0); if (TREE_CODE (x) == PARM_DECL) @@ -3443,7 +3443,7 @@ tm_memop_hasher::hash (const tm_memop *mem) tree addr = mem->addr; /* We drill down to the SSA_NAME/DECL for the hash, but equality is actually done with operand_equal_p (see tm_memop_eq). */ - if (TREE_CODE (addr) == ADDR_EXPR) + if (ADDR_EXPR_P (addr)) addr = TREE_OPERAND (addr, 0); return iterative_hash_expr (addr, 0); } @@ -3906,7 +3906,7 @@ tm_memopt_transform_stmt (unsigned int offset, gimple_stmt_iterator *gsi) { tree fn = gimple_call_fn (stmt); - gcc_assert (TREE_CODE (fn) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (fn)); TREE_OPERAND (fn, 0) = builtin_decl_explicit ((enum built_in_function) (DECL_FUNCTION_CODE (TREE_OPERAND (fn, 0)) @@ -4387,7 +4387,7 @@ ipa_tm_scan_irr_block (basic_block bb) /* For direct function calls, go ahead and check for replacement functions, or transitive irrevocable functions. For indirect functions, we'll ask the runtime. */ - if (TREE_CODE (fn) == ADDR_EXPR) + if (ADDR_EXPR_P (fn)) { struct tm_ipa_cg_data *d; struct cgraph_node *node; @@ -5074,7 +5074,7 @@ ipa_tm_insert_gettmclone_call (struct cgraph_node *node, old_fn = gimple_call_fn (stmt); - if (TREE_CODE (old_fn) == ADDR_EXPR) + if (ADDR_EXPR_P (old_fn)) { tree fndecl = TREE_OPERAND (old_fn, 0); tree clone = get_tm_clone_pair (fndecl); diff --git a/gcc/tree-affine.c b/gcc/tree-affine.c index c7559e7ffbb..d08e182d3a2 100644 --- a/gcc/tree-affine.c +++ b/gcc/tree-affine.c @@ -466,7 +466,7 @@ tree_to_aff_combination (tree expr, tree type, aff_tree *comb) else core = build_fold_addr_expr (core); - if (TREE_CODE (core) == ADDR_EXPR) + if (ADDR_EXPR_P (core)) aff_combination_add_elt (comb, core, 1); else { diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 44617788326..e441ce837c2 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -2008,7 +2008,7 @@ replace_uses_by (tree name, tree val) /* Operands may be empty here. For example, the labels of a GIMPLE_COND are nulled out following the creation of the corresponding CFG edges. */ - if (op && TREE_CODE (op) == ADDR_EXPR) + if (op && ADDR_EXPR_P (op)) recompute_tree_invariant_for_addr_expr (op); } @@ -2354,7 +2354,7 @@ find_taken_edge (basic_block bb, tree val) appear inside an ADDR_EXPR, but we also allow the LABEL_REF to appear inside a LABEL_EXPR just to be safe. */ if (val - && (TREE_CODE (val) == ADDR_EXPR || TREE_CODE (val) == LABEL_EXPR) + && (ADDR_EXPR_P (val) || TREE_CODE (val) == LABEL_EXPR) && TREE_CODE (TREE_OPERAND (val, 0)) == LABEL_DECL) return find_taken_edge_computed_goto (bb, TREE_OPERAND (val, 0)); } @@ -3236,7 +3236,7 @@ verify_types_in_gimple_reference (tree expr, bool require_lvalue) if (TREE_CODE (expr) == MEM_REF) { if (!is_gimple_mem_ref_addr (TREE_OPERAND (expr, 0)) - || (TREE_CODE (TREE_OPERAND (expr, 0)) == ADDR_EXPR + || (ADDR_EXPR_P (TREE_OPERAND (expr, 0)) && verify_address (TREE_OPERAND (expr, 0), false))) { error ("invalid address operand in %qs", code_name); @@ -3262,7 +3262,7 @@ verify_types_in_gimple_reference (tree expr, bool require_lvalue) { if (!TMR_BASE (expr) || !is_gimple_mem_ref_addr (TMR_BASE (expr)) - || (TREE_CODE (TMR_BASE (expr)) == ADDR_EXPR + || (ADDR_EXPR_P (TMR_BASE (expr)) && verify_address (TMR_BASE (expr), false))) { error ("invalid address operand in %qs", code_name); @@ -6324,7 +6324,7 @@ gimple_duplicate_bb (basic_block bb, copy_bb_data *id) tree op = gimple_op (copy, i); if (!op) continue; - if (TREE_CODE (op) == ADDR_EXPR + if (ADDR_EXPR_P (op) || TREE_CODE (op) == WITH_SIZE_EXPR) op = TREE_OPERAND (op, 0); while (handled_component_p (op)) @@ -6906,7 +6906,7 @@ move_stmt_op (tree *tp, int *walk_subtrees, void *data) addresses but unshare_expr copies them anyways. Make sure to unshare before adjusting the block in place - we do not always see a copy here. */ - if (TREE_CODE (t) == ADDR_EXPR + if (ADDR_EXPR_P (t) && is_gimple_min_invariant (t)) *tp = t = unshare_expr (t); TREE_SET_BLOCK (t, p->new_block); diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index 4763cd45a1c..c170d1d2ab6 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -252,7 +252,7 @@ cleanup_control_flow_bb (basic_block bb) retval |= cleanup_control_expr_graph (bb, gsi); } else if (gimple_code (stmt) == GIMPLE_GOTO - && TREE_CODE (gimple_goto_dest (stmt)) == ADDR_EXPR + && ADDR_EXPR_P (gimple_goto_dest (stmt)) && (TREE_CODE (TREE_OPERAND (gimple_goto_dest (stmt), 0)) == LABEL_DECL)) { @@ -806,7 +806,7 @@ maybe_dead_abnormal_edge_p (edge e) return false; tree arg = gimple_call_arg (gsi_stmt (gsi), 0); - if (TREE_CODE (arg) != ADDR_EXPR || TREE_OPERAND (arg, 0) != target) + if (!ADDR_EXPR_P (arg) || TREE_OPERAND (arg, 0) != target) return false; } return true; @@ -831,7 +831,7 @@ builtin_setjmp_setup_bb (basic_block bb) return NULL; tree arg = gimple_call_arg (gsi_stmt (gsi), 1); - if (TREE_CODE (arg) != ADDR_EXPR + if (!ADDR_EXPR_P (arg) || TREE_CODE (TREE_OPERAND (arg, 0)) != LABEL_DECL) return NULL; diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 23a7106c195..06aa315e475 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -861,7 +861,7 @@ canonicalize_base_object_address (tree addr) if (!POINTER_TYPE_P (TREE_TYPE (addr))) return orig; - if (TREE_CODE (addr) != ADDR_EXPR) + if (!ADDR_EXPR_P (addr)) return addr; return build_fold_addr_expr (TREE_OPERAND (addr, 0)); @@ -5795,7 +5795,7 @@ get_base_for_alignment (tree addr, unsigned int *max_alignment) if (base) return base; - if (TREE_CODE (addr) == ADDR_EXPR) + if (ADDR_EXPR_P (addr)) addr = TREE_OPERAND (addr, 0); *max_alignment = MAX_OFILE_ALIGNMENT / BITS_PER_UNIT; return addr; diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index 3283d113f9b..fb5130c9cde 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -589,7 +589,7 @@ get_ref_base_and_extent (tree exp, poly_int64_pod *poffset, case TARGET_MEM_REF: /* Via the variable index or index2 we can reach the whole object. Still hand back the decl here. */ - if (TREE_CODE (TMR_BASE (exp)) == ADDR_EXPR + if (ADDR_EXPR_P (TMR_BASE (exp)) && (TMR_INDEX (exp) || TMR_INDEX2 (exp))) { exp = TREE_OPERAND (TMR_BASE (exp), 0); @@ -619,7 +619,7 @@ get_ref_base_and_extent (tree exp, poly_int64_pod *poffset, maxsize = -1; /* Hand back the decl for MEM[&decl, off]. */ - if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR) + if (ADDR_EXPR_P (TREE_OPERAND (exp, 0))) { if (integer_zerop (TREE_OPERAND (exp, 1))) exp = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); @@ -846,7 +846,7 @@ get_addr_base_and_unit_offset_1 (tree exp, poly_int64_pod *poffset, base = (*valueize) (base); /* Hand back the decl for MEM[&decl, off]. */ - if (TREE_CODE (base) == ADDR_EXPR) + if (ADDR_EXPR_P (base)) { if (!integer_zerop (TREE_OPERAND (exp, 1))) { @@ -866,7 +866,7 @@ get_addr_base_and_unit_offset_1 (tree exp, poly_int64_pod *poffset, base = (*valueize) (base); /* Hand back the decl for MEM[&decl, off]. */ - if (TREE_CODE (base) == ADDR_EXPR) + if (ADDR_EXPR_P (base)) { if (TMR_INDEX (exp) || TMR_INDEX2 (exp)) return NULL_TREE; diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 4246dca8806..e75c1d06b2f 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -2692,7 +2692,7 @@ tree_could_trap_p (tree expr) case TARGET_MEM_REF: case MEM_REF: - if (TREE_CODE (TREE_OPERAND (expr, 0)) == ADDR_EXPR + if (ADDR_EXPR_P (TREE_OPERAND (expr, 0)) && tree_could_trap_p (TREE_OPERAND (TREE_OPERAND (expr, 0), 0))) return true; if (TREE_THIS_NOTRAP (expr)) @@ -2702,7 +2702,7 @@ tree_could_trap_p (tree expr) if (code == TARGET_MEM_REF && (TMR_INDEX (expr) || TMR_INDEX2 (expr))) return true; - if (TREE_CODE (TREE_OPERAND (expr, 0)) == ADDR_EXPR) + if (ADDR_EXPR_P (TREE_OPERAND (expr, 0))) { tree base = TREE_OPERAND (TREE_OPERAND (expr, 0), 0); poly_offset_int off = mem_ref_offset (expr); diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 48cdb8da59c..ab0f9b3ba44 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1169,7 +1169,7 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data) TREE_OPERAND (*tp, 1) = TREE_OPERAND (*tp, 3); TREE_OPERAND (*tp, 3) = NULL_TREE; } - else if (TREE_CODE (*tp) == ADDR_EXPR) + else if (ADDR_EXPR_P (*tp)) { /* Variable substitution need not be simple. In particular, the MEM_REF substitution above. Make sure that @@ -1354,7 +1354,7 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data) if (! *tp) { type = remap_type (type, id); - if (TREE_CODE (ptr) == ADDR_EXPR && !id->do_not_fold) + if (ADDR_EXPR_P (ptr) && !id->do_not_fold) { *tp = fold_indirect_ref_1 (EXPR_LOCATION (ptr), type, ptr); @@ -1448,7 +1448,7 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data) /* Variable substitution need not be simple. In particular, the INDIRECT_REF substitution above. Make sure that TREE_CONSTANT and friends are up-to-date. */ - else if (TREE_CODE (*tp) == ADDR_EXPR) + else if (ADDR_EXPR_P (*tp)) { int invariant = is_gimple_min_invariant (*tp); walk_tree (&TREE_OPERAND (*tp, 0), copy_tree_body_r, id, NULL); @@ -3304,7 +3304,7 @@ self_inlining_addr_expr (tree value, tree fn) { tree var; - if (TREE_CODE (value) != ADDR_EXPR) + if (!ADDR_EXPR_P (value)) return false; var = get_base_address (TREE_OPERAND (value, 0)); diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c index 9b61c74fabd..74fda944ea2 100644 --- a/gcc/tree-nested.c +++ b/gcc/tree-nested.c @@ -1209,7 +1209,7 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) if (TREE_CODE (*pdecl) == POINTER_PLUS_EXPR) pdecl = &TREE_OPERAND (*pdecl, 0); if (TREE_CODE (*pdecl) == INDIRECT_REF - || TREE_CODE (*pdecl) == ADDR_EXPR) + || ADDR_EXPR_P (*pdecl)) pdecl = &TREE_OPERAND (*pdecl, 0); } goto do_decl_clause; @@ -1907,7 +1907,7 @@ convert_local_reference_op (tree *tp, int *walk_subtrees, void *data) /* We need to re-fold the MEM_REF as component references as part of a ADDR_EXPR address are not allowed. But we cannot fold here, as the chain record type is not yet finalized. */ - if (TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR + if (ADDR_EXPR_P (TREE_OPERAND (t, 0)) && !DECL_P (TREE_OPERAND (TREE_OPERAND (t, 0), 0))) info->mem_refs->add (tp); wi->val_only = save_val_only; @@ -1967,7 +1967,7 @@ convert_local_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) if (TREE_CODE (*pdecl) == POINTER_PLUS_EXPR) pdecl = &TREE_OPERAND (*pdecl, 0); if (TREE_CODE (*pdecl) == INDIRECT_REF - || TREE_CODE (*pdecl) == ADDR_EXPR) + || ADDR_EXPR_P (*pdecl)) pdecl = &TREE_OPERAND (*pdecl, 0); } goto do_decl_clause; diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c index bc55b27cff0..a971bbc17d8 100644 --- a/gcc/tree-object-size.c +++ b/gcc/tree-object-size.c @@ -156,7 +156,7 @@ compute_object_offset (const_tree expr, const_tree var) break; case MEM_REF: - gcc_assert (TREE_CODE (TREE_OPERAND (expr, 0)) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (TREE_OPERAND (expr, 0))); return wide_int_to_tree (sizetype, mem_ref_offset (expr)); default: @@ -220,7 +220,7 @@ addr_object_size (struct object_size_info *osi, const_tree ptr, if (!poff) poff = &dummy_off; - gcc_assert (TREE_CODE (ptr) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (ptr)); /* Set to unknown and overwrite just before returning if the size could be determined. */ @@ -566,7 +566,7 @@ compute_builtin_object_size (tree ptr, int object_size_type, if (! offset_limit) init_offset_limit (); - if (TREE_CODE (ptr) == ADDR_EXPR) + if (ADDR_EXPR_P (ptr)) return addr_object_size (NULL, ptr, object_size_type, psize, pdecl, poff); if (TREE_CODE (ptr) != SSA_NAME @@ -743,7 +743,7 @@ expr_object_size (struct object_size_info *osi, tree ptr, tree value) gcc_assert (TREE_CODE (value) != SSA_NAME || !POINTER_TYPE_P (TREE_TYPE (value))); - if (TREE_CODE (value) == ADDR_EXPR) + if (ADDR_EXPR_P (value)) addr_object_size (osi, value, object_size_type, &bytes); else bytes = unknown[object_size_type]; @@ -899,7 +899,7 @@ plus_stmt_object_size (struct object_size_info *osi, tree var, gimple *stmt) /* Handle PTR + OFFSET here. */ if (TREE_CODE (op1) == INTEGER_CST && (TREE_CODE (op0) == SSA_NAME - || TREE_CODE (op0) == ADDR_EXPR)) + || ADDR_EXPR_P (op0))) { if (! tree_fits_uhwi_p (op1)) bytes = unknown[object_size_type]; @@ -1381,7 +1381,7 @@ pass_object_sizes::execute (function *fun) tree ptr = gimple_call_arg (call, 0); tree lhs = gimple_call_lhs (call); if ((object_size_type == 1 || object_size_type == 3) - && (TREE_CODE (ptr) == ADDR_EXPR + && (ADDR_EXPR_P (ptr) || TREE_CODE (ptr) == SSA_NAME) && lhs) { diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index 8cd50234a1c..73bf211f100 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -1359,7 +1359,7 @@ eliminate_local_variables_1 (tree *tp, int *walk_subtrees, void *data) return NULL_TREE; } - if (TREE_CODE (t) == ADDR_EXPR) + if (ADDR_EXPR_P (t)) { /* ADDR_EXPR may appear in two contexts: -- as a gimple operand, when the address taken is a function invariant @@ -3622,7 +3622,7 @@ loop_has_phi_with_address_arg (class loop *loop) for (j = 0; j < gimple_phi_num_args (phi); j++) { tree arg = gimple_phi_arg_def (phi, j); - if (TREE_CODE (arg) == ADDR_EXPR) + if (ADDR_EXPR_P (arg)) { /* This should be handled by eliminate_local_variables, but that function currently ignores phis. */ diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 8de10a4608e..02f91b108b6 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -1495,7 +1495,7 @@ dump_mem_ref (pretty_printer *pp, tree node, int spc, dump_flags_t flags) && (!(flags & TDF_ALIAS) || MR_DEPENDENCE_CLIQUE (node) == 0)) { - if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR) + if (!ADDR_EXPR_P (TREE_OPERAND (node, 0))) { /* Enclose pointers to arrays in parentheses. */ tree op0 = TREE_OPERAND (node, 0); @@ -1872,7 +1872,7 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, pp_string (pp, "MEM["); - if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR) + if (ADDR_EXPR_P (TMR_BASE (node))) { pp_string (pp, sep); sep = ", "; @@ -2232,7 +2232,7 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, if (op0 && (TREE_CODE (op0) == INDIRECT_REF || (TREE_CODE (op0) == MEM_REF - && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR + && !ADDR_EXPR_P (TREE_OPERAND (op0, 0)) && integer_zerop (TREE_OPERAND (op0, 1)) /* Dump the types of INTEGER_CSTs explicitly, for we can't infer them and MEM_ATTR caching will share @@ -2418,7 +2418,7 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, } if (is_array_init) curidx += 1; - if (val && TREE_CODE (val) == ADDR_EXPR) + if (val && ADDR_EXPR_P (val)) if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL) val = TREE_OPERAND (val, 0); if (val && TREE_CODE (val) == FUNCTION_DECL) @@ -2765,7 +2765,7 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, case PREDECREMENT_EXPR: case PREINCREMENT_EXPR: case INDIRECT_REF: - if (TREE_CODE (node) == ADDR_EXPR + if (ADDR_EXPR_P (node) && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL)) ; /* Do not output '&' for strings and function pointers. */ diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index f0ee25e0c9d..9427cba6851 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -1070,7 +1070,7 @@ contains_vce_or_bfcref_p (const_tree ref, bool *type_changing_p = NULL) if (!type_changing_p || TREE_CODE (ref) != MEM_REF - || TREE_CODE (TREE_OPERAND (ref, 0)) != ADDR_EXPR) + || !ADDR_EXPR_P (TREE_OPERAND (ref, 0))) return false; tree mem = TREE_OPERAND (TREE_OPERAND (ref, 0), 0); @@ -1140,7 +1140,7 @@ build_access_from_expr_1 (tree expr, gimple *stmt, bool write) switch (TREE_CODE (expr)) { case MEM_REF: - if (TREE_CODE (TREE_OPERAND (expr, 0)) != ADDR_EXPR) + if (!ADDR_EXPR_P (TREE_OPERAND (expr, 0))) return NULL; /* fall through */ case VAR_DECL: @@ -2246,7 +2246,7 @@ create_access_replacement (struct access *access, tree reg_type = NULL_TREE) fail = true; break; case MEM_REF: - if (TREE_CODE (TREE_OPERAND (d, 0)) != ADDR_EXPR) + if (!ADDR_EXPR_P (TREE_OPERAND (d, 0))) fail = true; else d = TREE_OPERAND (d, 0); diff --git a/gcc/tree-ssa-address.c b/gcc/tree-ssa-address.c index c6ba514a25f..2621f0b966e 100644 --- a/gcc/tree-ssa-address.c +++ b/gcc/tree-ssa-address.c @@ -401,7 +401,7 @@ create_mem_ref_raw (tree type, tree alias_ptr_type, struct mem_address *addr, ??? As IVOPTs does not follow restrictions to where the base pointer may point to create a MEM_REF only if we know that base is valid. */ - if ((TREE_CODE (base) == ADDR_EXPR || TREE_CODE (base) == INTEGER_CST) + if ((ADDR_EXPR_P (base) || TREE_CODE (base) == INTEGER_CST) && (!index2 || integer_zerop (index2)) && (!addr->index || integer_zerop (addr->index))) return fold_build2 (MEM_REF, type, base, addr->offset); @@ -435,7 +435,7 @@ move_fixed_address_to_symbol (struct mem_address *parts, aff_tree *addr) continue; val = addr->elts[i].val; - if (TREE_CODE (val) == ADDR_EXPR + if (ADDR_EXPR_P (val) && fixed_address_object_p (TREE_OPERAND (val, 0))) break; } @@ -1006,7 +1006,7 @@ create_mem_ref (gimple_stmt_iterator *gsi, tree type, aff_tree *addr, void get_address_description (tree op, struct mem_address *addr) { - if (TREE_CODE (TMR_BASE (op)) == ADDR_EXPR) + if (ADDR_EXPR_P (TMR_BASE (op))) { addr->symbol = TMR_BASE (op); addr->base = TMR_INDEX2 (op); diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index ede4f198342..dc5bae1f5a1 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -194,7 +194,7 @@ ptr_deref_may_alias_decl_p (tree ptr, tree decl) /* Anything we do not explicilty handle aliases. */ if ((TREE_CODE (ptr) != SSA_NAME - && TREE_CODE (ptr) != ADDR_EXPR + && !ADDR_EXPR_P (ptr) && TREE_CODE (ptr) != POINTER_PLUS_EXPR) || !POINTER_TYPE_P (TREE_TYPE (ptr)) || (!VAR_P (decl) @@ -215,7 +215,7 @@ ptr_deref_may_alias_decl_p (tree ptr, tree decl) /* ADDR_EXPR pointers either just offset another pointer or directly specify the pointed-to set. */ - if (TREE_CODE (ptr) == ADDR_EXPR) + if (ADDR_EXPR_P (ptr)) { tree base = get_base_address (TREE_OPERAND (ptr, 0)); if (base @@ -281,7 +281,7 @@ ptr_derefs_may_alias_p (tree ptr1, tree ptr2) /* ADDR_EXPR pointers either just offset another pointer or directly specify the pointed-to set. */ - if (TREE_CODE (ptr1) == ADDR_EXPR) + if (ADDR_EXPR_P (ptr1)) { tree base = get_base_address (TREE_OPERAND (ptr1, 0)); if (base @@ -294,7 +294,7 @@ ptr_derefs_may_alias_p (tree ptr1, tree ptr2) else return true; } - if (TREE_CODE (ptr2) == ADDR_EXPR) + if (ADDR_EXPR_P (ptr2)) { tree base = get_base_address (TREE_OPERAND (ptr2, 0)); if (base @@ -363,7 +363,7 @@ ptrs_compare_unequal (tree ptr1, tree ptr2) in the points-to sets. */ tree obj1 = NULL_TREE; tree obj2 = NULL_TREE; - if (TREE_CODE (ptr1) == ADDR_EXPR) + if (ADDR_EXPR_P (ptr1)) { tree tem = get_base_address (TREE_OPERAND (ptr1, 0)); if (! tem) @@ -375,7 +375,7 @@ ptrs_compare_unequal (tree ptr1, tree ptr2) else if (TREE_CODE (tem) == MEM_REF) ptr1 = TREE_OPERAND (tem, 0); } - if (TREE_CODE (ptr2) == ADDR_EXPR) + if (ADDR_EXPR_P (ptr2)) { tree tem = get_base_address (TREE_OPERAND (ptr2, 0)); if (! tem) @@ -728,7 +728,7 @@ ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size) } } - if (TREE_CODE (ptr) == ADDR_EXPR) + if (ADDR_EXPR_P (ptr)) { ref->base = get_addr_base_and_unit_offset (TREE_OPERAND (ptr, 0), &t); if (ref->base) @@ -2216,12 +2216,12 @@ refs_may_alias_p_2 (ao_ref *ref1, ao_ref *ref2, bool tbaa_p) if (TREE_CODE (base1) == SSA_NAME || TREE_CODE (base1) == CONST_DECL || TREE_CODE (base1) == CONSTRUCTOR - || TREE_CODE (base1) == ADDR_EXPR + || ADDR_EXPR_P (base1) || CONSTANT_CLASS_P (base1) || TREE_CODE (base2) == SSA_NAME || TREE_CODE (base2) == CONST_DECL || TREE_CODE (base2) == CONSTRUCTOR - || TREE_CODE (base2) == ADDR_EXPR + || ADDR_EXPR_P (base2) || CONSTANT_CLASS_P (base2)) return false; @@ -3426,7 +3426,7 @@ stmt_kills_ref_p (gimple *stmt, ao_ref *ref) case BUILT_IN_VA_END: { tree ptr = gimple_call_arg (stmt, 0); - if (TREE_CODE (ptr) == ADDR_EXPR) + if (ADDR_EXPR_P (ptr)) { tree base = ao_ref_base (ref); if (TREE_OPERAND (ptr, 0) == base) diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 5fb9a465928..eb17308ae0c 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -598,7 +598,7 @@ get_value_from_alignment (tree expr) unsigned HOST_WIDE_INT bitpos; unsigned int align; - gcc_assert (TREE_CODE (expr) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (expr)); get_pointer_alignment_1 (expr, &align, &bitpos); val.mask = wi::bit_and_not @@ -639,7 +639,7 @@ get_value_for_expr (tree expr, bool for_bits_p) if (for_bits_p && val.lattice_val == CONSTANT) { - if (TREE_CODE (val.value) == ADDR_EXPR) + if (ADDR_EXPR_P (val.value)) val = get_value_from_alignment (val.value); else if (TREE_CODE (val.value) != INTEGER_CST) { @@ -666,7 +666,7 @@ get_value_for_expr (tree expr, bool for_bits_p) val.mask = 0; canonicalize_value (&val); } - else if (TREE_CODE (expr) == ADDR_EXPR) + else if (ADDR_EXPR_P (expr)) val = get_value_from_alignment (expr); else { @@ -1096,15 +1096,15 @@ ccp_lattice_meet (ccp_prop_value_t *val1, ccp_prop_value_t *val2) } else if (val1->lattice_val == CONSTANT && val2->lattice_val == CONSTANT - && (TREE_CODE (val1->value) == ADDR_EXPR - || TREE_CODE (val2->value) == ADDR_EXPR)) + && (ADDR_EXPR_P (val1->value) + || ADDR_EXPR_P (val2->value))) { /* When not equal addresses are involved try meeting for alignment. */ ccp_prop_value_t tem = *val2; - if (TREE_CODE (val1->value) == ADDR_EXPR) + if (ADDR_EXPR_P (val1->value)) *val1 = get_value_for_expr (val1->value, true); - if (TREE_CODE (val2->value) == ADDR_EXPR) + if (ADDR_EXPR_P (val2->value)) tem = get_value_for_expr (val2->value, true); ccp_lattice_meet (val1, &tem); } @@ -3163,7 +3163,7 @@ optimize_memcpy (gimple_stmt_iterator *gsip, tree dest, tree src, tree len) && !gimple_clobber_p (defstmt)) src2 = gimple_assign_lhs (defstmt); else if (gimple_call_builtin_p (defstmt, BUILT_IN_MEMSET) - && TREE_CODE (gimple_call_arg (defstmt, 0)) == ADDR_EXPR + && ADDR_EXPR_P (gimple_call_arg (defstmt, 0)) && TREE_CODE (gimple_call_arg (defstmt, 1)) == INTEGER_CST) { src2 = TREE_OPERAND (gimple_call_arg (defstmt, 0), 0); @@ -3433,8 +3433,8 @@ pass_fold_builtins::execute (function *fun) case BUILT_IN_MEMCPY: if (gimple_call_builtin_p (stmt, BUILT_IN_NORMAL) - && TREE_CODE (gimple_call_arg (stmt, 0)) == ADDR_EXPR - && TREE_CODE (gimple_call_arg (stmt, 1)) == ADDR_EXPR + && ADDR_EXPR_P (gimple_call_arg (stmt, 0)) + && ADDR_EXPR_P (gimple_call_arg (stmt, 1)) && TREE_CODE (gimple_call_arg (stmt, 2)) == INTEGER_CST) { tree dest = TREE_OPERAND (gimple_call_arg (stmt, 0), 0); diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index fae5ae72340..009d54a20ab 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -465,7 +465,7 @@ ref_may_be_aliased (tree ref) while (handled_component_p (ref)) ref = TREE_OPERAND (ref, 0); if (TREE_CODE (ref) == MEM_REF - && TREE_CODE (TREE_OPERAND (ref, 0)) == ADDR_EXPR) + && ADDR_EXPR_P (TREE_OPERAND (ref, 0))) ref = TREE_OPERAND (TREE_OPERAND (ref, 0), 0); return !(DECL_P (ref) && !may_be_aliased (ref)); diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 33db64f61b1..3a75e5af7e9 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -1718,7 +1718,7 @@ record_equivalences_from_stmt (gimple *stmt, int may_optimize_p, /* Make sure we can propagate &x + CST. */ if (lhs_code == SSA_NAME && gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR - && TREE_CODE (gimple_assign_rhs1 (stmt)) == ADDR_EXPR + && ADDR_EXPR_P (gimple_assign_rhs1 (stmt)) && TREE_CODE (gimple_assign_rhs2 (stmt)) == INTEGER_CST) { tree op0 = gimple_assign_rhs1 (stmt); @@ -2045,7 +2045,7 @@ dom_opt_dom_walker::optimize_stmt (basic_block bb, gimple_stmt_iterator *si, /* This should never be an ADDR_EXPR. */ rhs = gimple_switch_index (swtch_stmt); - if (rhs && TREE_CODE (rhs) == ADDR_EXPR) + if (rhs && ADDR_EXPR_P (rhs)) recompute_tree_invariant_for_addr_expr (rhs); /* Indicate that maybe_clean_or_replace_eh_stmt needs to be called, diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index 3f2a992a774..8ad9a4f00ce 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -646,7 +646,7 @@ tidy_after_forward_propagate_addr (gimple *stmt) if (maybe_clean_or_replace_eh_stmt (stmt, stmt)) bitmap_set_bit (to_purge, gimple_bb (stmt)->index); - if (TREE_CODE (gimple_assign_rhs1 (stmt)) == ADDR_EXPR) + if (ADDR_EXPR_P (gimple_assign_rhs1 (stmt))) recompute_tree_invariant_for_addr_expr (gimple_assign_rhs1 (stmt)); } @@ -670,7 +670,7 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs, enum tree_code rhs_code; bool res = true; - gcc_assert (TREE_CODE (def_rhs) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (def_rhs)); lhs = gimple_assign_lhs (use_stmt); rhs_code = gimple_assign_rhs_code (use_stmt); @@ -848,7 +848,7 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs, /* Strip away any outer COMPONENT_REF, ARRAY_REF or ADDR_EXPR nodes from the RHS. */ tree *rhsp = gimple_assign_rhs1_ptr (use_stmt); - if (TREE_CODE (*rhsp) == ADDR_EXPR) + if (ADDR_EXPR_P (*rhsp)) rhsp = &TREE_OPERAND (*rhsp, 0); while (handled_component_p (*rhsp)) rhsp = &TREE_OPERAND (*rhsp, 0); @@ -1176,7 +1176,7 @@ constant_pointer_difference (tree p1, tree p2) { if (!POINTER_TYPE_P (TREE_TYPE (p))) break; - if (TREE_CODE (p) == ADDR_EXPR) + if (ADDR_EXPR_P (p)) { tree q = TREE_OPERAND (p, 0); poly_int64 offset; @@ -2777,7 +2777,7 @@ pass_forwprop::execute (function *fun) /* Handle pointer conversions on invariant addresses as well, as this is valid gimple. */ || (CONVERT_EXPR_CODE_P (code) - && TREE_CODE (rhs) == ADDR_EXPR + && ADDR_EXPR_P (rhs) && POINTER_TYPE_P (TREE_TYPE (lhs)))) && TREE_CODE (TREE_OPERAND (rhs, 0)) != TARGET_MEM_REF) { diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 582d17c73cc..8a62acd27b4 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -1191,7 +1191,7 @@ alloc_iv (struct ivopts_data *data, tree base, tree step, 2) Duplicate candidates won't be created for bases in different forms, like &a[0] and &a. */ STRIP_NOPS (expr); - if ((TREE_CODE (expr) == ADDR_EXPR && !DECL_P (TREE_OPERAND (expr, 0))) + if ((ADDR_EXPR_P (expr) && !DECL_P (TREE_OPERAND (expr, 0))) || contain_complex_addr_expr (expr)) { aff_tree comb; @@ -2381,7 +2381,7 @@ find_interesting_uses_address (struct ivopts_data *data, gimple *stmt, /* Substituting bases of IVs into the base expression might have caused folding opportunities. */ - if (TREE_CODE (base) == ADDR_EXPR) + if (ADDR_EXPR_P (base)) { tree *ref = &TREE_OPERAND (base, 0); while (handled_component_p (*ref)) @@ -4355,7 +4355,7 @@ force_expr_to_var_cost (tree expr, bool speed) if (poly_int_tree_p (expr)) return comp_cost (integer_cost [speed], 0); - if (TREE_CODE (expr) == ADDR_EXPR) + if (ADDR_EXPR_P (expr)) { tree obj = TREE_OPERAND (expr, 0); diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c index a2717a411a3..c9ba43be346 100644 --- a/gcc/tree-ssa-loop-manip.c +++ b/gcc/tree-ssa-loop-manip.c @@ -111,7 +111,7 @@ create_iv (tree base, tree step, tree var, class loop *loop, } if (POINTER_TYPE_P (TREE_TYPE (base))) { - if (TREE_CODE (base) == ADDR_EXPR) + if (ADDR_EXPR_P (base)) mark_addressable (TREE_OPERAND (base, 0)); step = convert_to_ptrofftype (step); if (incr_op == MINUS_EXPR) diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c index f4716d0e36f..b4be43b314b 100644 --- a/gcc/tree-ssa-operands.c +++ b/gcc/tree-ssa-operands.c @@ -631,7 +631,7 @@ mark_address_taken (tree ref) if (DECL_P (var)) TREE_ADDRESSABLE (var) = 1; else if (TREE_CODE (var) == MEM_REF - && TREE_CODE (TREE_OPERAND (var, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (var, 0)) && DECL_P (TREE_OPERAND (TREE_OPERAND (var, 0), 0))) TREE_ADDRESSABLE (TREE_OPERAND (TREE_OPERAND (var, 0), 0)) = 1; } diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c index 024da8c408c..1c3cc6bf7c1 100644 --- a/gcc/tree-ssa-phiprop.c +++ b/gcc/tree-ssa-phiprop.c @@ -189,7 +189,7 @@ phiprop_insert_phi (basic_block bb, gphi *phi, gimple *use_stmt, else { tree rhs = gimple_assign_rhs1 (use_stmt); - gcc_assert (TREE_CODE (old_arg) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (old_arg)); if (TREE_CODE (res) == SSA_NAME) new_var = make_ssa_name (TREE_TYPE (rhs)); else @@ -295,7 +295,7 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, return false; arg = gimple_assign_rhs1 (def_stmt); } - if (TREE_CODE (arg) != ADDR_EXPR + if (!ADDR_EXPR_P (arg) && !(TREE_CODE (arg) == SSA_NAME && SSA_NAME_VERSION (arg) < n && phivn[SSA_NAME_VERSION (arg)].value != NULL_TREE diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 0a94f4e3355..a448787ba31 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -2472,7 +2472,7 @@ create_component_ref_by_pieces_1 (basic_block block, vn_reference_t ref, if (!baseop) return NULL_TREE; tree offset = currop->op0; - if (TREE_CODE (baseop) == ADDR_EXPR + if (ADDR_EXPR_P (baseop) && handled_component_p (TREE_OPERAND (baseop, 0))) { poly_int64 off; diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index 1e057284154..abea16fe8d4 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -1213,7 +1213,7 @@ substitute_and_fold_dom_walker::before_dom_children (basic_block bb) { tree rhs = gimple_assign_rhs1 (stmt); - if (TREE_CODE (rhs) == ADDR_EXPR) + if (ADDR_EXPR_P (rhs)) recompute_tree_invariant_for_addr_expr (rhs); } diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 6f6efd9aae3..61ab91dfbda 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -872,7 +872,7 @@ copy_reference_ops_from_ref (tree ref, vec *result) __builtin_object_size had a chance to run (checking cfun->after_inlining does the trick here). */ - if (TREE_CODE (orig) != ADDR_EXPR + if (!ADDR_EXPR_P (orig) || maybe_ne (off, 0) || cfun->after_inlining) off.to_shwi (&temp.off); @@ -969,7 +969,7 @@ copy_reference_ops_from_ref (tree ref, vec *result) if (REFERENCE_CLASS_P (ref) || TREE_CODE (ref) == MODIFY_EXPR || TREE_CODE (ref) == WITH_SIZE_EXPR - || (TREE_CODE (ref) == ADDR_EXPR + || (ADDR_EXPR_P (ref) && !is_gimple_min_invariant (ref))) ref = TREE_OPERAND (ref, 0); else @@ -1364,7 +1364,7 @@ vn_reference_maybe_forwprop_address (vec *ops, while (TREE_CODE (op->op0) == SSA_NAME); /* Fold a remaining *&. */ - if (TREE_CODE (op->op0) == ADDR_EXPR) + if (ADDR_EXPR_P (op->op0)) vn_reference_fold_indirect (ops, i_p); return changed; @@ -1383,7 +1383,7 @@ fully_constant_vn_reference_p (vn_reference_t ref) a call to a builtin function with at most two arguments. */ op = &operands[0]; if (op->opcode == CALL_EXPR - && TREE_CODE (op->op0) == ADDR_EXPR + && ADDR_EXPR_P (op->op0) && TREE_CODE (TREE_OPERAND (op->op0, 0)) == FUNCTION_DECL && fndecl_built_in_p (TREE_OPERAND (op->op0, 0)) && operands.length () >= 2 @@ -1566,7 +1566,7 @@ valueize_refs_1 (vec orig, bool *valueized_anything, a preceding indirect reference. */ if (i > 0 && vro->op0 - && TREE_CODE (vro->op0) == ADDR_EXPR + && ADDR_EXPR_P (vro->op0) && orig[i - 1].opcode == MEM_REF) { if (vn_reference_fold_indirect (&orig, &i)) @@ -2627,7 +2627,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, && (poly_int_tree_p (gimple_call_arg (def_stmt, 2)) || (TREE_CODE (gimple_call_arg (def_stmt, 2)) == SSA_NAME && poly_int_tree_p (SSA_VAL (gimple_call_arg (def_stmt, 2))))) - && (TREE_CODE (gimple_call_arg (def_stmt, 0)) == ADDR_EXPR + && (ADDR_EXPR_P (gimple_call_arg (def_stmt, 0)) || TREE_CODE (gimple_call_arg (def_stmt, 0)) == SSA_NAME)) { tree base2; @@ -2647,7 +2647,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, ref2 = gimple_assign_rhs1 (def_stmt); } } - if (TREE_CODE (ref2) == ADDR_EXPR) + if (ADDR_EXPR_P (ref2)) { ref2 = TREE_OPERAND (ref2, 0); base2 = get_ref_base_and_extent (ref2, &offset2, &size2, &maxsize2, @@ -3237,9 +3237,9 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, || gimple_call_builtin_p (def_stmt, BUILT_IN_MEMPCPY_CHK) || gimple_call_builtin_p (def_stmt, BUILT_IN_MEMMOVE) || gimple_call_builtin_p (def_stmt, BUILT_IN_MEMMOVE_CHK)) - && (TREE_CODE (gimple_call_arg (def_stmt, 0)) == ADDR_EXPR + && (ADDR_EXPR_P (gimple_call_arg (def_stmt, 0)) || TREE_CODE (gimple_call_arg (def_stmt, 0)) == SSA_NAME) - && (TREE_CODE (gimple_call_arg (def_stmt, 1)) == ADDR_EXPR + && (ADDR_EXPR_P (gimple_call_arg (def_stmt, 1)) || TREE_CODE (gimple_call_arg (def_stmt, 1)) == SSA_NAME) && (poly_int_tree_p (gimple_call_arg (def_stmt, 2), ©_size) || (TREE_CODE (gimple_call_arg (def_stmt, 2)) == SSA_NAME @@ -3275,7 +3275,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, lhs = gimple_assign_rhs1 (def_stmt); } } - if (TREE_CODE (lhs) == ADDR_EXPR) + if (ADDR_EXPR_P (lhs)) { if (AGGREGATE_TYPE_P (TREE_TYPE (TREE_TYPE (lhs))) && TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (TREE_TYPE (lhs)))) @@ -3298,7 +3298,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, return (void *)-1; } if (TREE_CODE (lhs) != SSA_NAME - && TREE_CODE (lhs) != ADDR_EXPR) + && !ADDR_EXPR_P (lhs)) return (void *)-1; /* Extract a pointer base and an offset for the source. */ @@ -3306,7 +3306,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, rhs_offset = 0; if (TREE_CODE (rhs) == SSA_NAME) rhs = vn_valueize (rhs); - if (TREE_CODE (rhs) == ADDR_EXPR) + if (ADDR_EXPR_P (rhs)) { if (AGGREGATE_TYPE_P (TREE_TYPE (TREE_TYPE (rhs))) && TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (TREE_TYPE (rhs)))) @@ -3329,7 +3329,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, } if (TREE_CODE (rhs) == SSA_NAME) rhs = SSA_VAL (rhs); - else if (TREE_CODE (rhs) != ADDR_EXPR) + else if (!ADDR_EXPR_P (rhs)) return (void *)-1; /* The bases of the destination and the references have to agree. */ @@ -3341,7 +3341,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, at += mem_offset; } else if (!DECL_P (base) - || TREE_CODE (lhs) != ADDR_EXPR + || !ADDR_EXPR_P (lhs) || TREE_OPERAND (lhs, 0) != base) return (void *)-1; @@ -4591,8 +4591,8 @@ set_and_exit: does not reliably detect ADDR_EXPRs as equal. We know we are only getting invariant gimple addresses here, so can use get_addr_base_and_unit_offset to do this comparison. */ - && !(TREE_CODE (currval) == ADDR_EXPR - && TREE_CODE (to) == ADDR_EXPR + && !(ADDR_EXPR_P (currval) + && ADDR_EXPR_P (to) && (get_addr_base_and_unit_offset (TREE_OPERAND (currval, 0), &coff) == get_addr_base_and_unit_offset (TREE_OPERAND (to, 0), &toff)) && known_eq (coff, toff))) @@ -4879,7 +4879,7 @@ visit_reference_op_call (tree lhs, gcall *stmt) if (fn && TREE_CODE (fn) == SSA_NAME) { fn = SSA_VAL (fn); - if (TREE_CODE (fn) == ADDR_EXPR + if (ADDR_EXPR_P (fn) && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL && (flags_from_decl_or_type (TREE_OPERAND (fn, 0)) & (ECF_CONST | ECF_PURE))) @@ -5156,8 +5156,8 @@ visit_phi (gimple *phi, bool *inserted, bool backedges_varying_p) /* We know we're arriving only with invariant addresses here, try harder comparing them. We can do some caching here which we cannot do in expressions_equal_p. */ - if (TREE_CODE (def) == ADDR_EXPR - && TREE_CODE (sameval) == ADDR_EXPR + if (ADDR_EXPR_P (def) + && ADDR_EXPR_P (sameval) && sameval_base != (void *)-1) { if (!sameval_base) @@ -5436,7 +5436,7 @@ visit_stmt (gimple *stmt, bool backedges_varying_p = false) if (fn && TREE_CODE (fn) == SSA_NAME) { fn = SSA_VAL (fn); - if (TREE_CODE (fn) == ADDR_EXPR + if (ADDR_EXPR_P (fn) && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL) extra_fnflags = flags_from_decl_or_type (TREE_OPERAND (fn, 0)); } @@ -6210,7 +6210,7 @@ eliminate_dom_walker::eliminate_stmt (basic_block b, gimple_stmt_iterator *gsi) /* If a formerly non-invariant ADDR_EXPR is turned into an invariant one it was on a separate stmt. */ if (gimple_assign_single_p (stmt) - && TREE_CODE (gimple_assign_rhs1 (stmt)) == ADDR_EXPR) + && ADDR_EXPR_P (gimple_assign_rhs1 (stmt))) recompute_tree_invariant_for_addr_expr (gimple_assign_rhs1 (stmt)); gimple_stmt_iterator prev = *gsi; gsi_prev (&prev); diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index 0e14fc1ccb5..2e848366376 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -527,7 +527,7 @@ get_stridx (tree exp, wide_int offrng[2] = NULL, const vr_values *rvals = NULL) return last_idx; } - if (TREE_CODE (exp) == ADDR_EXPR) + if (ADDR_EXPR_P (exp)) { int idx = get_addr_stridx (TREE_OPERAND (exp, 0), exp, NULL); if (idx != 0) @@ -641,7 +641,7 @@ new_stridx (tree exp) ssa_ver_to_stridx[SSA_NAME_VERSION (exp)] = idx; return idx; } - if (TREE_CODE (exp) == ADDR_EXPR) + if (ADDR_EXPR_P (exp)) { int *pidx = addr_stridxptr (TREE_OPERAND (exp, 0)); if (pidx != NULL) @@ -1126,7 +1126,7 @@ get_range_strlen_dynamic (tree src, c_strlen_data *pdata, bitmap *visited, pdata->minlen = build_zero_cst (size_type_node); tree base = si->ptr; - if (TREE_CODE (base) == ADDR_EXPR) + if (ADDR_EXPR_P (base)) base = TREE_OPERAND (base, 0); HOST_WIDE_INT off; @@ -1565,7 +1565,7 @@ find_equal_ptrs (tree ptr, int idx) return; if (TREE_CODE (ptr) == SSA_NAME) break; - if (TREE_CODE (ptr) != ADDR_EXPR) + if (!ADDR_EXPR_P (ptr)) return; /* FALLTHRU */ case ADDR_EXPR: @@ -1849,7 +1849,7 @@ maybe_set_strlen_range (tree lhs, tree src, tree bound) one to its beginning is positive. */ wide_int max = wi::to_wide (TYPE_MAX_VALUE (ptrdiff_type_node)) - 2; - if (TREE_CODE (src) == ADDR_EXPR) + if (ADDR_EXPR_P (src)) { /* The last array member of a struct can be bigger than its size suggests if it's treated as a poor-man's flexible array member. */ @@ -3071,7 +3071,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt) tree dst = gimple_call_arg (stmt, 0); tree dstdecl = dst; - if (TREE_CODE (dstdecl) == ADDR_EXPR) + if (ADDR_EXPR_P (dstdecl)) dstdecl = TREE_OPERAND (dstdecl, 0); tree ref = NULL_TREE; @@ -3082,7 +3082,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt) for possible truncation (if the truncation is certain SIDX is non-zero). */ tree srcdecl = gimple_call_arg (stmt, 1); - if (TREE_CODE (srcdecl) == ADDR_EXPR) + if (ADDR_EXPR_P (srcdecl)) srcdecl = TREE_OPERAND (srcdecl, 0); if (get_attr_nonstring_decl (srcdecl, &ref)) return false; @@ -4899,7 +4899,7 @@ count_nonzero_bytes_addr (tree exp, unsigned HOST_WIDE_INT offset, return true; } - if (TREE_CODE (exp) == ADDR_EXPR) + if (ADDR_EXPR_P (exp)) return count_nonzero_bytes (TREE_OPERAND (exp, 0), offset, nbytes, lenrange, nulterm, allnul, allnonnul, rvals, snlim); diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 44fe52e0f65..3127aabadd6 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -3282,7 +3282,7 @@ get_constraint_for_component_ref (tree t, vec *results, VIEW_CONVERT_EXPR <>(&foobar) or things like a BIT_FIELD_REF <&MEM[(void *)&b + 4B], ...>. So for symbolic constants simply give up. */ - if (TREE_CODE (t) == ADDR_EXPR) + if (ADDR_EXPR_P (t)) { constraint_expr result; result.type = SCALAR; @@ -4647,7 +4647,7 @@ find_func_aliases_for_builtin_call (struct function *fn, gcall *t) if (in_ipa_mode) { varinfo_t nfi = NULL; - gcc_assert (TREE_CODE (nfunc) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (nfunc)); nfi = lookup_vi_for_tree (TREE_OPERAND (nfunc, 0)); if (nfi) { @@ -4800,7 +4800,7 @@ find_func_aliases_for_builtin_call (struct function *fn, gcall *t) } tree fnarg = gimple_call_arg (t, fnpos); - gcc_assert (TREE_CODE (fnarg) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (fnarg)); tree fndecl = TREE_OPERAND (fnarg, 0); if (fndecl_maybe_in_other_partition (fndecl)) /* Fallthru to general call handling. */ @@ -5202,7 +5202,7 @@ find_func_clobbers (struct function *fn, gimple *origt) && !auto_var_in_fn_p (tem, fn->decl)) || INDIRECT_REF_P (tem) || (TREE_CODE (tem) == MEM_REF - && !(TREE_CODE (TREE_OPERAND (tem, 0)) == ADDR_EXPR + && !(ADDR_EXPR_P (TREE_OPERAND (tem, 0)) && auto_var_in_fn_p (TREE_OPERAND (TREE_OPERAND (tem, 0), 0), fn->decl)))) { @@ -5231,7 +5231,7 @@ find_func_clobbers (struct function *fn, gimple *origt) && !auto_var_in_fn_p (tem, fn->decl)) || INDIRECT_REF_P (tem) || (TREE_CODE (tem) == MEM_REF - && !(TREE_CODE (TREE_OPERAND (tem, 0)) == ADDR_EXPR + && !(ADDR_EXPR_P (TREE_OPERAND (tem, 0)) && auto_var_in_fn_p (TREE_OPERAND (TREE_OPERAND (tem, 0), 0), fn->decl)))) { @@ -5382,7 +5382,7 @@ find_func_clobbers (struct function *fn, gimple *origt) } tree fnarg = gimple_call_arg (t, fnpos); - gcc_assert (TREE_CODE (fnarg) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (fnarg)); tree fndecl = TREE_OPERAND (fnarg, 0); if (fndecl_maybe_in_other_partition (fndecl)) /* Fallthru to general call handling. */ diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index e73cc6f4cf6..19b95276ed0 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -354,7 +354,7 @@ maybe_warn_operand (ao_ref &ref, gimple *stmt, tree lhs, tree rhs, break; base = gimple_assign_rhs1 (def_stmt); - if (TREE_CODE (base) == ADDR_EXPR) + if (ADDR_EXPR_P (base)) base = TREE_OPERAND (base, 0); if (DECL_P (base) @@ -390,7 +390,7 @@ maybe_warn_operand (ao_ref &ref, gimple *stmt, tree lhs, tree rhs, return NULL_TREE; /* Strip the address-of expression from arrays passed to functions. */ - if (TREE_CODE (rhs) == ADDR_EXPR) + if (ADDR_EXPR_P (rhs)) rhs = TREE_OPERAND (rhs, 0); /* Check again since RHS may have changed above. */ diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 421043edc75..be1a4f5bf50 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -994,7 +994,7 @@ verify_phi_args (gphi *phi, basic_block bb, basic_block *definition_block) op_p, phi, e->flags & EDGE_ABNORMAL, NULL); } - if (TREE_CODE (op) == ADDR_EXPR) + if (ADDR_EXPR_P (op)) { tree base = TREE_OPERAND (op, 0); while (handled_component_p (base)) @@ -1362,7 +1362,7 @@ maybe_rewrite_mem_ref_base (tree *tp, bitmap suitable_for_renaming) while (handled_component_p (*tp)) tp = &TREE_OPERAND (*tp, 0); if (TREE_CODE (*tp) == MEM_REF - && TREE_CODE (TREE_OPERAND (*tp, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (*tp, 0)) && (sym = TREE_OPERAND (TREE_OPERAND (*tp, 0), 0)) && DECL_P (sym) && !TREE_ADDRESSABLE (sym) @@ -1445,7 +1445,7 @@ non_rewritable_mem_ref_base (tree ref) /* But watch out for MEM_REFs we cannot lower to a VIEW_CONVERT_EXPR or a BIT_FIELD_REF. */ if (TREE_CODE (base) == MEM_REF - && TREE_CODE (TREE_OPERAND (base, 0)) == ADDR_EXPR) + && ADDR_EXPR_P (TREE_OPERAND (base, 0))) { tree decl = TREE_OPERAND (TREE_OPERAND (base, 0), 0); if (! DECL_P (decl)) @@ -1511,7 +1511,7 @@ non_rewritable_lvalue_p (tree lhs) /* ??? The following could be relaxed allowing component references that do not change the access size. */ if (TREE_CODE (lhs) == MEM_REF - && TREE_CODE (TREE_OPERAND (lhs, 0)) == ADDR_EXPR) + && ADDR_EXPR_P (TREE_OPERAND (lhs, 0))) { tree decl = TREE_OPERAND (TREE_OPERAND (lhs, 0), 0); @@ -1663,7 +1663,7 @@ is_asan_mark_p (gimple *stmt) return false; tree addr = get_base_address (gimple_call_arg (stmt, 1)); - if (TREE_CODE (addr) == ADDR_EXPR + if (ADDR_EXPR_P (addr) && VAR_P (TREE_OPERAND (addr, 0))) { tree var = TREE_OPERAND (addr, 0); @@ -1801,7 +1801,7 @@ execute_update_addresses_taken (void) for (i = 0; i < gimple_phi_num_args (phi); i++) { tree op = PHI_ARG_DEF (phi, i), var; - if (TREE_CODE (op) == ADDR_EXPR + if (ADDR_EXPR_P (op) && (var = get_base_address (TREE_OPERAND (op, 0))) != NULL && DECL_P (var)) bitmap_set_bit (addresses_taken, DECL_UID (var)); @@ -1909,7 +1909,7 @@ execute_update_addresses_taken (void) /* Rewrite a vector insert using a MEM_REF on the LHS into a BIT_INSERT_EXPR. */ if (TREE_CODE (lhs) == MEM_REF - && TREE_CODE (TREE_OPERAND (lhs, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (lhs, 0)) && (sym = TREE_OPERAND (TREE_OPERAND (lhs, 0), 0)) && DECL_P (sym) && bitmap_bit_p (suitable_for_renaming, DECL_UID (sym)) @@ -1970,7 +1970,7 @@ execute_update_addresses_taken (void) while (TREE_CODE (lhs) == VIEW_CONVERT_EXPR) lhs = TREE_OPERAND (lhs, 0); if (TREE_CODE (lhs) == MEM_REF - && TREE_CODE (TREE_OPERAND (lhs, 0)) == ADDR_EXPR + && ADDR_EXPR_P (TREE_OPERAND (lhs, 0)) && integer_zerop (TREE_OPERAND (lhs, 1)) && (sym = TREE_OPERAND (TREE_OPERAND (lhs, 0), 0)) && DECL_P (sym) @@ -2051,7 +2051,7 @@ execute_update_addresses_taken (void) tree *argp = gimple_call_arg_ptr (stmt, i); if (*argp == null_pointer_node) continue; - gcc_assert (TREE_CODE (*argp) == ADDR_EXPR + gcc_assert (ADDR_EXPR_P (*argp) && VAR_P (TREE_OPERAND (*argp, 0))); tree var = TREE_OPERAND (*argp, 0); if (bitmap_bit_p (suitable_for_renaming, DECL_UID (var))) diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c index 53bf6c3d7ee..c05fa3b2f00 100644 --- a/gcc/tree-stdarg.c +++ b/gcc/tree-stdarg.c @@ -466,7 +466,7 @@ check_va_list_escapes (struct stdarg_info *si, tree lhs, tree rhs) if (! bitmap_bit_p (si->va_list_escape_vars, SSA_NAME_VERSION (rhs))) return; } - else if (TREE_CODE (rhs) == ADDR_EXPR + else if (ADDR_EXPR_P (rhs) && TREE_CODE (TREE_OPERAND (rhs, 0)) == MEM_REF && TREE_CODE (TREE_OPERAND (TREE_OPERAND (rhs, 0), 0)) == SSA_NAME) { @@ -713,7 +713,7 @@ optimize_va_list_gpr_fpr_size (function *fun) si.va_start_count++; ap = gimple_call_arg (stmt, 0); - if (TREE_CODE (ap) != ADDR_EXPR) + if (!ADDR_EXPR_P (ap)) { va_list_escapes = true; break; diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 65e30bac424..c09d6d0058a 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -6203,7 +6203,7 @@ scan_operand_equal_p (tree ref1, tree ref2) gimple *def_stmt = SSA_NAME_DEF_STMT (TREE_OPERAND (base[i], 0)); if (is_gimple_assign (def_stmt) && gimple_assign_rhs_code (def_stmt) == POINTER_PLUS_EXPR - && TREE_CODE (gimple_assign_rhs1 (def_stmt)) == ADDR_EXPR + && ADDR_EXPR_P (gimple_assign_rhs1 (def_stmt)) && TREE_CODE (gimple_assign_rhs2 (def_stmt)) == SSA_NAME) { if (maybe_ne (mem_ref_offset (base[i]), 0)) @@ -6375,7 +6375,7 @@ check_scan_store (vec_info *vinfo, stmt_vec_info stmt_info, tree vectype, if (slp || mask || memory_access_type != VMAT_CONTIGUOUS - || TREE_CODE (DR_BASE_ADDRESS (dr_info->dr)) != ADDR_EXPR + || !ADDR_EXPR_P (DR_BASE_ADDRESS (dr_info->dr)) || !VAR_P (TREE_OPERAND (DR_BASE_ADDRESS (dr_info->dr), 0)) || loop_vinfo == NULL || LOOP_VINFO_FULLY_MASKED_P (loop_vinfo) @@ -6595,7 +6595,7 @@ check_scan_store (vec_info *vinfo, stmt_vec_info stmt_info, tree vectype, if (STMT_VINFO_SIMD_LANE_ACCESS_P (stmt_info) == 4 && inscan_var_store) { dr_vec_info *load1_dr_info = STMT_VINFO_DR_INFO (load1_stmt_info); - if (TREE_CODE (DR_BASE_ADDRESS (load1_dr_info->dr)) != ADDR_EXPR + if (!ADDR_EXPR_P (DR_BASE_ADDRESS (load1_dr_info->dr)) || !VAR_P (TREE_OPERAND (DR_BASE_ADDRESS (load1_dr_info->dr), 0))) goto fail; tree var1 = TREE_OPERAND (DR_BASE_ADDRESS (load1_dr_info->dr), 0); @@ -6653,7 +6653,7 @@ check_scan_store (vec_info *vinfo, stmt_vec_info stmt_info, tree vectype, else if (STMT_VINFO_SIMD_LANE_ACCESS_P (stmt_info) == 4) { dr_vec_info *load2_dr_info = STMT_VINFO_DR_INFO (load2_stmt_info); - if (TREE_CODE (DR_BASE_ADDRESS (load2_dr_info->dr)) != ADDR_EXPR + if (!ADDR_EXPR_P (DR_BASE_ADDRESS (load2_dr_info->dr)) || !VAR_P (TREE_OPERAND (DR_BASE_ADDRESS (load2_dr_info->dr), 0))) goto fail; var3 = TREE_OPERAND (DR_BASE_ADDRESS (load2_dr_info->dr), 0); @@ -6665,7 +6665,7 @@ check_scan_store (vec_info *vinfo, stmt_vec_info stmt_info, tree vectype, } dr_vec_info *other_dr_info = STMT_VINFO_DR_INFO (other_store_stmt_info); - if (TREE_CODE (DR_BASE_ADDRESS (other_dr_info->dr)) != ADDR_EXPR + if (!ADDR_EXPR_P (DR_BASE_ADDRESS (other_dr_info->dr)) || !VAR_P (TREE_OPERAND (DR_BASE_ADDRESS (other_dr_info->dr), 0))) goto fail; @@ -7883,7 +7883,7 @@ vectorizable_store (vec_info *vinfo, = STMT_VINFO_SIMD_LANE_ACCESS_P (stmt_info) != 0; if (simd_lane_access_p && !loop_masks - && TREE_CODE (DR_BASE_ADDRESS (first_dr_info->dr)) == ADDR_EXPR + && ADDR_EXPR_P (DR_BASE_ADDRESS (first_dr_info->dr)) && VAR_P (TREE_OPERAND (DR_BASE_ADDRESS (first_dr_info->dr), 0)) && integer_zerop (get_dr_vinfo_offset (vinfo, first_dr_info)) && integer_zerop (DR_INIT (first_dr_info->dr)) @@ -9143,7 +9143,7 @@ vectorizable_load (vec_info *vinfo, bool simd_lane_access_p = STMT_VINFO_SIMD_LANE_ACCESS_P (stmt_info) != 0; if (simd_lane_access_p - && TREE_CODE (DR_BASE_ADDRESS (first_dr_info->dr)) == ADDR_EXPR + && ADDR_EXPR_P (DR_BASE_ADDRESS (first_dr_info->dr)) && VAR_P (TREE_OPERAND (DR_BASE_ADDRESS (first_dr_info->dr), 0)) && integer_zerop (get_dr_vinfo_offset (vinfo, first_dr_info)) && integer_zerop (DR_INIT (first_dr_info->dr)) diff --git a/gcc/tree.c b/gcc/tree.c index 11dd9cc0276..42812849d94 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -4648,7 +4648,7 @@ recompute_tree_invariant_for_addr_expr (tree t) tree node; bool tc = true, se = false; - gcc_assert (TREE_CODE (t) == ADDR_EXPR); + gcc_assert (ADDR_EXPR_P (t)); /* We started out assuming this address is both invariant and constant, but does not have side effects. Now go down any handled components and see if @@ -4876,7 +4876,7 @@ build2 (enum tree_code code, tree tt, tree arg0, tree arg1 MEM_STAT_DECL) TREE_SIDE_EFFECTS (t) = side_effects; if (code == MEM_REF) { - if (arg0 && TREE_CODE (arg0) == ADDR_EXPR) + if (arg0 && ADDR_EXPR_P (arg0)) { tree o = TREE_OPERAND (arg0, 0); TREE_READONLY (t) = TREE_READONLY (o); @@ -4989,7 +4989,7 @@ build5 (enum tree_code code, tree tt, tree arg0, tree arg1, TREE_SIDE_EFFECTS (t) = side_effects; if (code == TARGET_MEM_REF) { - if (arg0 && TREE_CODE (arg0) == ADDR_EXPR) + if (arg0 && ADDR_EXPR_P (arg0)) { tree o = TREE_OPERAND (arg0, 0); TREE_READONLY (t) = TREE_READONLY (o); @@ -5015,7 +5015,7 @@ build_simple_mem_ref_loc (location_t loc, tree ptr) tree tem; /* For convenience allow addresses that collapse to a simple base and offset. */ - if (TREE_CODE (ptr) == ADDR_EXPR + if (ADDR_EXPR_P (ptr) && (handled_component_p (TREE_OPERAND (ptr, 0)) || TREE_CODE (TREE_OPERAND (ptr, 0)) == MEM_REF)) { @@ -9595,7 +9595,7 @@ get_callee_fndecl (const_tree call) /* If the address is just `&f' for some function `f', then we know that `f' is being called. */ - if (TREE_CODE (addr) == ADDR_EXPR + if (ADDR_EXPR_P (addr) && TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL) return TREE_OPERAND (addr, 0); @@ -11351,7 +11351,7 @@ initializer_zerop (const_tree init, bool *nonzero /* = NULL */) case MEM_REF: { tree arg = TREE_OPERAND (init, 0); - if (TREE_CODE (arg) != ADDR_EXPR) + if (!ADDR_EXPR_P (arg)) return false; tree offset = TREE_OPERAND (init, 1); if (TREE_CODE (offset) != INTEGER_CST @@ -13613,7 +13613,7 @@ get_base_address (tree t) if ((TREE_CODE (t) == MEM_REF || TREE_CODE (t) == TARGET_MEM_REF) - && TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR) + && ADDR_EXPR_P (TREE_OPERAND (t, 0))) t = TREE_OPERAND (TREE_OPERAND (t, 0), 0); /* ??? Either the alias oracle or all callers need to properly deal @@ -13714,7 +13714,7 @@ array_at_struct_end_p (tree ref) else if (TREE_CODE (ref) == MEM_REF) { tree arg = TREE_OPERAND (ref, 0); - if (TREE_CODE (arg) == ADDR_EXPR) + if (ADDR_EXPR_P (arg)) arg = TREE_OPERAND (arg, 0); tree argtype = TREE_TYPE (arg); if (TREE_CODE (argtype) == RECORD_TYPE) @@ -13784,7 +13784,7 @@ array_at_struct_end_p (tree ref) return true; if (TREE_CODE (ref) == MEM_REF - && TREE_CODE (TREE_OPERAND (ref, 0)) == ADDR_EXPR) + && ADDR_EXPR_P (TREE_OPERAND (ref, 0))) ref = TREE_OPERAND (TREE_OPERAND (ref, 0), 0); /* If the reference is based on a declared entity, the size of the array diff --git a/gcc/tree.h b/gcc/tree.h index 9c14bce5b1c..74921865526 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -477,6 +477,10 @@ ADDR_EXPR_CODE_P (tree_code code) return code == ADDR_EXPR; } +/* Test if EXP takes the address of an object. If so, the object + is TREE_OPERAND (EXP, 0). */ +#define ADDR_EXPR_P(EXP) ADDR_EXPR_CODE_P (TREE_CODE (EXP)) + /* Tests if CODE is a conversion expr (NOP_EXPR or CONVERT_EXPR). */ #define CONVERT_EXPR_CODE_P(CODE) \ ((CODE) == NOP_EXPR || (CODE) == CONVERT_EXPR) diff --git a/gcc/ubsan.c b/gcc/ubsan.c index f147bd8b792..4b6ce85e2e5 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -1392,7 +1392,7 @@ static void instrument_null (gimple_stmt_iterator gsi, tree t, bool is_lhs) { /* Handle also e.g. &s->i. */ - if (TREE_CODE (t) == ADDR_EXPR) + if (ADDR_EXPR_P (t)) t = TREE_OPERAND (t, 0); tree base = get_base_address (t); if (base != NULL_TREE @@ -1422,7 +1422,7 @@ maybe_instrument_pointer_overflow (gimple_stmt_iterator *gsi, tree t) return; /* Handle also e.g. &s->i. */ - if (TREE_CODE (t) == ADDR_EXPR) + if (ADDR_EXPR_P (t)) t = TREE_OPERAND (t, 0); if (!handled_component_p (t) && TREE_CODE (t) != MEM_REF) @@ -1460,7 +1460,7 @@ maybe_instrument_pointer_overflow (gimple_stmt_iterator *gsi, tree t) else if (TREE_CODE (inner) == MEM_REF) { base = TREE_OPERAND (inner, 0); - if (TREE_CODE (base) == ADDR_EXPR + if (ADDR_EXPR_P (base) && DECL_P (TREE_OPERAND (base, 0)) && !TREE_ADDRESSABLE (TREE_OPERAND (base, 0)) && !is_global_var (TREE_OPERAND (base, 0))) diff --git a/gcc/value-range.cc b/gcc/value-range.cc index 59ca01ae1fb..ea151b18a18 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -693,8 +693,8 @@ irange::normalize_addresses () if (!range_includes_zero_p (this)) { - gcc_checking_assert (TREE_CODE (min ()) == ADDR_EXPR - || TREE_CODE (max ()) == ADDR_EXPR); + gcc_checking_assert (ADDR_EXPR_P (min ()) + || ADDR_EXPR_P (max ())); set_nonzero (type ()); return; } diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index 03098b1486e..a164f5d1fd3 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -5233,7 +5233,7 @@ track_expr_p (tree expr, bool need_rtl) { if (handled_component_p (realdecl) || (TREE_CODE (realdecl) == MEM_REF - && TREE_CODE (TREE_OPERAND (realdecl, 0)) == ADDR_EXPR)) + && ADDR_EXPR_P (TREE_OPERAND (realdecl, 0)))) { HOST_WIDE_INT bitsize, bitpos; bool reverse; diff --git a/gcc/varasm.c b/gcc/varasm.c index b52b8ab6a5d..7189fba912c 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1564,7 +1564,7 @@ assemble_asm (tree string) const char *p; app_enable (); - if (TREE_CODE (string) == ADDR_EXPR) + if (ADDR_EXPR_P (string)) string = TREE_OPERAND (string, 0); p = TREE_STRING_POINTER (string); @@ -3009,15 +3009,14 @@ decode_addr_const (tree exp, class addr_const *value) target = TREE_OPERAND (target, 0); } else if (TREE_CODE (target) == MEM_REF - && TREE_CODE (TREE_OPERAND (target, 0)) == ADDR_EXPR) + && ADDR_EXPR_P (TREE_OPERAND (target, 0))) { offset += mem_ref_offset (target).force_shwi (); target = TREE_OPERAND (TREE_OPERAND (target, 0), 0); } else if (TREE_CODE (target) == INDIRECT_REF && TREE_CODE (TREE_OPERAND (target, 0)) == NOP_EXPR - && TREE_CODE (TREE_OPERAND (TREE_OPERAND (target, 0), 0)) - == ADDR_EXPR) + && ADDR_EXPR_P (TREE_OPERAND (TREE_OPERAND (target, 0), 0))) target = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (target, 0), 0), 0); else break; @@ -4385,7 +4384,7 @@ compute_reloc_for_constant (tree exp) ; if (TREE_CODE (tem) == MEM_REF - && TREE_CODE (TREE_OPERAND (tem, 0)) == ADDR_EXPR) + && ADDR_EXPR_P (TREE_OPERAND (tem, 0))) { reloc = compute_reloc_for_constant (TREE_OPERAND (tem, 0)); break; @@ -4677,7 +4676,7 @@ initializer_constant_valid_p_1 (tree value, tree endtype, tree *cache) with IR like: .REPLACE_ADDRESS_VALUE (&x, (long)&x + INTEGER_CST) which later get expanded to POINTER_PLUS. */ - if (TREE_CODE (base_cap) == ADDR_EXPR) + if (ADDR_EXPR_P (base_cap)) { tree av_addr = addr_value; if (TREE_CODE (av_addr) == PLUS_EXPR) @@ -5124,7 +5123,7 @@ output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align, /* If what we're left with is the address of something, we can convert the address to the final type and output it that way. */ - if (TREE_CODE (exp) == ADDR_EXPR) + if (ADDR_EXPR_P (exp)) exp = build1 (ADDR_EXPR, saved_type, TREE_OPERAND (exp, 0)); /* Likewise for constant ints. */ else if (TREE_CODE (exp) == INTEGER_CST) @@ -5188,7 +5187,7 @@ output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align, { rtx cap = expand_expr (exp, NULL_RTX, VOIDmode, EXPAND_INITIALIZER); - if (TREE_CODE (exp) == ADDR_EXPR + if (ADDR_EXPR_P (exp) && TREE_CODE (TREE_OPERAND (exp, 0)) == LABEL_DECL) { /* For a pointer to a label, we need to rewrite the expression diff --git a/gcc/vtable-verify.c b/gcc/vtable-verify.c index c44cd917b20..48613229460 100644 --- a/gcc/vtable-verify.c +++ b/gcc/vtable-verify.c @@ -596,7 +596,7 @@ var_is_used_for_virtual_call_p (tree lhs, int *mem_ref_depth, else if (is_gimple_assign (stmt2)) { tree rhs = gimple_assign_rhs1 (stmt2); - if (TREE_CODE (rhs) == ADDR_EXPR + if (ADDR_EXPR_P (rhs) || TREE_CODE (rhs) == MEM_REF) *mem_ref_depth = *mem_ref_depth + 1; @@ -605,7 +605,7 @@ var_is_used_for_virtual_call_p (tree lhs, int *mem_ref_depth, while (TREE_CODE (TREE_OPERAND (rhs, 0)) == COMPONENT_REF) rhs = TREE_OPERAND (rhs, 0); - if (TREE_CODE (TREE_OPERAND (rhs, 0)) == ADDR_EXPR + if (ADDR_EXPR_P (TREE_OPERAND (rhs, 0)) || TREE_CODE (TREE_OPERAND (rhs, 0)) == MEM_REF) *mem_ref_depth = *mem_ref_depth + 1; }