On Fri, Sep 27, 2024 at 02:01:19PM +0000, Qing Zhao wrote: > + /* Currently, only when the array_ref is an indirect_ref to a call to the > + .ACCESS_WITH_SIZE, return true. > + More cases can be included later when the counted_by attribute is > + extended to other situations. */ > + if ((TREE_CODE (array_ref) == INDIRECT_REF)
The ()s around the == are useless. > + && is_access_with_size_p (TREE_OPERAND (array_ref, 0))) > + return true; > + return false; > +} > + > +/* Get the reference to the counted-by object associated with the ARRAY_REF. > */ > +static tree > +get_counted_by_ref (tree array_ref) > +{ > + /* Currently, only when the array_ref is an indirect_ref to a call to the > + .ACCESS_WITH_SIZE, get the corresponding counted_by ref. > + More cases can be included later when the counted_by attribute is > + extended to other situations. */ > + if ((TREE_CODE (array_ref) == INDIRECT_REF) Again. > + if (TREE_CODE (TREE_TYPE (ref)) != ARRAY_TYPE) > + { > + error_at (loc, "the argument must be an array" > + "%<__builtin_counted_by_ref%>"); > + expr.set_error (); > + break; > + } > + > + /* if the array ref is inside TYPEOF or ALIGNOF, the call to Comments should start with capital letter, i.e. If > + .ACCESS_WITH_SIZE was not genereated by the routine s/genereated/generated/ > + build_component_ref by default, we should generate it here. */ > + if ((in_typeof || in_alignof) && TREE_CODE (ref) == COMPONENT_REF) The above && ... fits on the same line as the rest of the condition. > + ref = handle_counted_by_for_component_ref (loc, ref); > + > + if (has_counted_by_object (ref)) > + expr.value > + = get_counted_by_ref (ref); This too. > + else > + expr.value > + = build_int_cst (build_pointer_type (void_type_node), 0); else expr.value = null_pointer_node; instead. > +/* > + * For the COMPONENT_REF ref, check whether it has a counted_by attribute, > + * if so, wrap this COMPONENT_REF with the corresponding CALL to the > + * function .ACCESS_WITH_SIZE. > + * Otherwise, return the ref itself. > + */ We don't use this style of comments. No *s at the start of each line, /* should be immediately followed after space with the first line and */ should be right after . and two spaces. Jakub