GCC Middle and Back End API Reference
attribs.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "target.h"
#include "tree.h"
#include "stringpool.h"
#include "diagnostic-core.h"
#include "attribs.h"
#include "fold-const.h"
#include "ipa-strub.h"
#include "stor-layout.h"
#include "langhooks.h"
#include "plugin.h"
#include "selftest.h"
#include "hash-set.h"
#include "diagnostic.h"
#include "pretty-print.h"
#include "tree-pretty-print.h"
#include "intl.h"
#include "gt-attribs.h"
Include dependency graph for attribs.cc:

Data Structures

struct  substring
 
struct  attribute_hasher
 
struct  scoped_attributes
 

Macros

#define INCLUDE_STRING
 

Functions

static hashval_t substring_hash (const char *str, int l)
 
static scoped_attributesfind_attribute_namespace (const char *)
 
static void register_scoped_attribute (const struct attribute_spec *, scoped_attributes *)
 
static const struct attribute_speclookup_scoped_attribute_spec (const_tree, const_tree)
 
static tree get_gnu_namespace ()
 
scoped_attributesregister_scoped_attributes (const scoped_attribute_specs &specs, bool ignored_p)
 
static void check_attribute_tables (void)
 
void handle_ignored_attributes_option (vec< char * > *v)
 
void free_attr_data ()
 
void init_attributes (void)
 
void register_attribute (const struct attribute_spec *attr)
 
const struct attribute_speclookup_attribute_spec (const_tree name)
 
tree get_attribute_namespace (const_tree attr)
 
static bool diag_attr_exclusions (tree last_decl, tree node, tree attrname, const attribute_spec *spec)
 
static bool attr_namespace_ignored_p (tree ns)
 
bool attribute_ignored_p (tree attr)
 
bool attribute_ignored_p (const attribute_spec *const as)
 
bool any_nonignored_attribute_p (tree attrs)
 
static tree find_same_attribute (const_tree attr, tree list)
 
tree decl_attributes (tree *node, tree attributes, int flags, tree last_decl)
 
bool cxx11_attribute_p (const_tree attr)
 
tree get_attribute_name (const_tree attr)
 
void apply_tm_attr (tree fndecl, tree attr)
 
tree make_attribute (const char *name, const char *arg_name, tree chain)
 
static int attr_strcmp (const void *v1, const void *v2)
 
charsorted_attr_string (tree arglist)
 
bool common_function_versions (tree fn1, tree fn2)
 
tree make_dispatcher_decl (const tree decl)
 
bool is_function_default_version (const tree decl)
 
tree build_decl_attribute_variant (tree ddecl, tree attribute)
 
tree build_type_attribute_qual_variant (tree otype, tree attribute, int quals)
 
static bool cmp_attrib_identifiers (const_tree attr1, const_tree attr2)
 
bool simple_cst_list_equal (const_tree l1, const_tree l2)
 
static bool omp_declare_simd_clauses_equal (tree clauses1, tree clauses2)
 
bool attribute_value_equal (const_tree attr1, const_tree attr2)
 
int comp_type_attributes (const_tree type1, const_tree type2)
 
template<typename Predicate >
tree remove_attributes_matching (tree attrs, Predicate predicate)
 
tree affects_type_identity_attributes (tree attrs, bool value)
 
tree restrict_type_identity_attributes_to (tree attrs, tree ok_attrs)
 
tree build_type_attribute_variant (tree ttype, tree attribute)
 
static tree lookup_ident_attribute (tree attr_identifier, tree list)
 
tree remove_attribute (const char *attr_name, tree list)
 
tree remove_attribute (const char *attr_ns, const char *attr_name, tree list)
 
tree merge_attributes (tree a1, tree a2)
 
tree merge_type_attributes (tree t1, tree t2)
 
tree merge_decl_attributes (tree olddecl, tree newdecl)
 
void duplicate_one_attribute (tree *attrs, tree attr, const char *name)
 
void copy_attributes_to_builtin (tree decl)
 
int attribute_list_equal (const_tree l1, const_tree l2)
 
int attribute_list_contained (const_tree l1, const_tree l2)
 
tree private_lookup_attribute (const char *attr_name, size_t attr_len, tree list)
 
tree private_lookup_attribute (const char *attr_ns, const char *attr_name, size_t attr_ns_len, size_t attr_len, tree list)
 
static bool has_attribute (tree node, tree attrs, const char *aname)
 
unsigned decls_mismatched_attributes (tree tmpl, tree decl, tree attrlist, const char *const blacklist[], pretty_printer *attrstr)
 
void maybe_diag_alias_attributes (tree alias, tree target)
 
void init_attr_rdwr_indices (rdwr_map *rwm, tree attrs)
 
attr_accessget_parm_access (rdwr_map &rdwr_idx, tree parm, tree fndecl)
 

Variables

static array_slice< const scoped_attribute_specs *constattribute_tables [2]
 
static vec< scoped_attributesattributes_table
 
static bool attributes_initialized = false
 
static tree gnu_namespace_cache
 
static vec< attribute_spec * > ignored_attributes_table
 

Macro Definition Documentation

◆ INCLUDE_STRING

#define INCLUDE_STRING
Functions dealing with attribute handling, used by most front ends.
   Copyright (C) 1992-2024 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   

Function Documentation

◆ affects_type_identity_attributes()

tree affects_type_identity_attributes ( tree attrs,
bool value )
If VALUE is true, return the subset of ATTRS that affect type identity,
otherwise return the subset of ATTRS that don't affect type identity.   

References bool, ggc_alloc(), and remove_attributes_matching().

◆ any_nonignored_attribute_p()

bool any_nonignored_attribute_p ( tree attrs)
Return true if the ATTRS chain contains at least one attribute which
is not ignored.   

References attribute_ignored_p(), and TREE_CHAIN.

◆ apply_tm_attr()

void apply_tm_attr ( tree fndecl,
tree attr )
Subroutine of set_method_tm_attributes.  Apply TM attribute ATTR
to the method FNDECL.   

References decl_attributes(), NULL, tree_cons(), and TREE_TYPE.

Referenced by set_call_expr_flags().

◆ attr_namespace_ignored_p()

static bool attr_namespace_ignored_p ( tree ns)
static
Return true iff we should not complain about unknown attributes
coming from the attribute namespace NS.  This is the case for
the -Wno-attributes=ns:: command-line option.   

References find_attribute_namespace(), IDENTIFIER_POINTER, NULL_TREE, and r.

Referenced by attribute_ignored_p(), and decl_attributes().

◆ attr_strcmp()

static int attr_strcmp ( const void * v1,
const void * v2 )
static
Common functions used for target clone support.   
Comparator function to be used in qsort routine to sort attribute
specification strings to "target".   

References ggc_alloc().

Referenced by sorted_attr_string().

◆ attribute_ignored_p() [1/2]

bool attribute_ignored_p ( const attribute_spec *const as)
Like above, but takes an attribute_spec AS, which must be nonnull.   

◆ attribute_ignored_p() [2/2]

bool attribute_ignored_p ( tree attr)
Return true if the attribute ATTR should not be warned about.   

References attr_namespace_ignored_p(), cxx11_attribute_p(), get_attribute_namespace(), ggc_alloc(), lookup_attribute_spec(), NULL, and TREE_PURPOSE.

Referenced by any_nonignored_attribute_p(), and decl_attributes().

◆ attribute_list_contained()

int attribute_list_contained ( const_tree l1,
const_tree l2 )
Given two lists of attributes, return true if list L2 is
completely contained within L1.   
??? This would be faster if attribute names were stored in a canonicalized
form.  Otherwise, if L1 uses `foo' and L2 uses `__foo__', the long method
must be used to show these elements are equivalent (which they are).   
??? It's not clear that attributes with arguments will always be handled
correctly.   

References attribute_value_equal(), CONST_CAST_TREE, get_attribute_name(), ggc_alloc(), lookup_ident_attribute(), NULL_TREE, TREE_CHAIN, and TREE_VALUE.

Referenced by attribute_list_equal(), and merge_attributes().

◆ attribute_list_equal()

◆ attribute_value_equal()

bool attribute_value_equal ( const_tree attr1,
const_tree attr2 )

◆ build_decl_attribute_variant()

tree build_decl_attribute_variant ( tree ddecl,
tree attribute )
Return a declaration like DDECL except that its DECL_ATTRIBUTES
is ATTRIBUTE.   

References DECL_ATTRIBUTES, and ggc_alloc().

◆ build_type_attribute_qual_variant()

◆ build_type_attribute_variant()

tree build_type_attribute_variant ( tree ttype,
tree attribute )
Return a type like TTYPE except that its TYPE_ATTRIBUTE
is ATTRIBUTE.

Record such modified types already made so we don't make duplicates.   

References build_type_attribute_qual_variant(), ggc_alloc(), and TYPE_QUALS.

Referenced by decl_attributes().

◆ check_attribute_tables()

static void check_attribute_tables ( void )
static
Make some sanity checks on the attribute tables.   

References attribute_tables, scoped_attributes::attributes, gcc_assert, gcc_unreachable, ggc_alloc(), names, and scoped_attributes::ns.

Referenced by init_attributes().

◆ cmp_attrib_identifiers()

static bool cmp_attrib_identifiers ( const_tree attr1,
const_tree attr2 )
static
Compare two identifier nodes representing attributes.
Return true if they are the same, false otherwise.   

References cmp_attribs(), gcc_checking_assert, ggc_alloc(), IDENTIFIER_LENGTH, IDENTIFIER_POINTER, and TREE_CODE.

Referenced by attribute_value_equal(), and lookup_ident_attribute().

◆ common_function_versions()

bool common_function_versions ( tree fn1,
tree fn2 )
This function returns true if FN1 and FN2 are versions of the same function,
that is, the target strings of the function decls are different.  This assumes
that FN1 and FN2 have the same signature.   

References copy_node(), DECL_ATTRIBUTES, DECL_FUNCTION_VERSIONED, DECL_SOURCE_LOCATION, error_at(), get_identifier(), ggc_alloc(), inform(), lookup_attribute(), NULL_TREE, sorted_attr_string(), TREE_CODE, tree_cons(), and TREE_VALUE.

◆ comp_type_attributes()

◆ copy_attributes_to_builtin()

void copy_attributes_to_builtin ( tree decl)
Duplicate all attributes from user DECL to the corresponding
builtin that should be propagated.   

References b, builtin_decl_explicit(), DECL_ATTRIBUTES, DECL_FUNCTION_CODE(), and duplicate_one_attribute().

◆ cxx11_attribute_p()

bool cxx11_attribute_p ( const_tree attr)
Return TRUE iff ATTR has been parsed by the front-end as a C++-11
attribute.

When G++ parses a C++11 attribute, it is represented as
a TREE_LIST which TREE_PURPOSE is itself a TREE_LIST.  TREE_PURPOSE
(TREE_PURPOSE (ATTR)) is the namespace of the attribute, and the
TREE_VALUE (TREE_PURPOSE (ATTR)) is its non-qualified name.  Please
use get_attribute_namespace and get_attribute_name to retrieve the
namespace and name of the attribute, as these accessors work with
GNU attributes as well.   

References ggc_alloc(), NULL_TREE, TREE_CODE, and TREE_PURPOSE.

Referenced by attribute_ignored_p(), decl_attributes(), get_attribute_name(), and get_attribute_namespace().

◆ decl_attributes()

tree decl_attributes ( tree * node,
tree attributes,
int flags,
tree last_decl )
Process the attributes listed in ATTRIBUTES and install them in *NODE,
which is either a DECL (including a TYPE_DECL) or a TYPE.  If a DECL,
it should be modified in place; if a TYPE, a copy should be created
unless ATTR_FLAG_TYPE_IN_PLACE is set in FLAGS.  FLAGS gives further
information, in the form of a bitwise OR of flags in enum attribute_flags
from tree.h.  Depending on these flags, some attributes may be
returned to be applied at a later stage (for example, to apply
a decl attribute to the declaration rather than to its type).   

References a, ATTR_FLAG_ARRAY_NEXT, ATTR_FLAG_BUILT_IN, ATTR_FLAG_CXX11, ATTR_FLAG_DECL_NEXT, ATTR_FLAG_FUNCTION_NEXT, ATTR_FLAG_TYPE_IN_PLACE, attr_namespace_ignored_p(), attribute_ignored_p(), attributes_initialized, build_pointer_type(), build_qualified_type(), build_target_option_node(), build_tree_list(), build_type_attribute_variant(), build_variant_type_copy(), BUILT_IN_NORMAL, chainon(), COMPLETE_TYPE_P, copy_list(), current_optimize_pragma, current_target_pragma, cxx11_attribute_p(), DECL_ATTRIBUTES, DECL_BUILT_IN_CLASS, DECL_FUNCTION_CODE(), DECL_FUNCTION_SPECIFIC_OPTIMIZATION, DECL_FUNCTION_SPECIFIC_TARGET, DECL_ORIGINAL_TYPE, DECL_P, diag_attr_exclusions(), error(), error_mark_node, error_operand_p(), find_same_attribute(), FUNC_OR_METHOD_TYPE_P, gcc_assert, get_attribute_name(), get_attribute_namespace(), get_identifier(), ggc_alloc(), global_options, global_options_set, inform(), init_attributes(), input_location, is_attribute_p(), list_length(), lookup_attribute(), lookup_attribute_spec(), lookup_scoped_attribute_spec(), NULL, NULL_TREE, optimization_current_node, optimization_default_node, POINTER_TYPE_P, r, relayout_decl(), simple_cst_equal(), target_option_current_node, target_option_default_node, targetm, TREE_CHAIN, TREE_CODE, tree_cons(), TREE_TYPE, TREE_VALUE, TYPE_ATTRIBUTES, TYPE_MAIN_VARIANT, TYPE_NAME, TYPE_NEXT_VARIANT, TYPE_P, TYPE_QUALS, VAR_P, and warning().

Referenced by apply_tm_attr(), and build_builtin_function().

◆ decls_mismatched_attributes()

unsigned decls_mismatched_attributes ( tree tmpl,
tree decl,
tree attrlist,
const char *const blacklist[],
pretty_printer * attrstr )
Return the number of mismatched function or type attributes between
the "template" function declaration TMPL and DECL.  The word "template"
doesn't necessarily refer to a C++ template but rather a declaration
whose attributes should be matched by those on DECL.  For a non-zero
return value set *ATTRSTR to a string representation of the list of
mismatched attributes with quoted names.
ATTRLIST is a list of additional attributes that SPEC should be
taken to ultimately be declared with.   

References DECL_ATTRIBUTES, decls, ggc_alloc(), global_dc, has_attribute(), i, lookup_attribute(), pp_begin_quote(), pp_end_quote(), pp_show_color, pp_string(), diagnostic_context::printer, TREE_CODE, TREE_DEPRECATED, TREE_PUBLIC, TREE_TYPE, and TYPE_ATTRIBUTES.

Referenced by maybe_diag_alias_attributes().

◆ diag_attr_exclusions()

static bool diag_attr_exclusions ( tree last_decl,
tree node,
tree attrname,
const attribute_spec * spec )
static
Check LAST_DECL and NODE of the same symbol for attributes that are
recorded in SPEC to be mutually exclusive with ATTRNAME, diagnose
them, and return true if any have been found.  NODE can be a DECL
or a TYPE.   

References DECL_ATTRIBUTES, DECL_P, DECL_SOURCE_LOCATION, diag_attr_exclusions(), fndecl_built_in_p(), ggc_alloc(), i, inform(), is_attribute_p(), lookup_attribute(), NULL_TREE, RECORD_OR_UNION_TYPE_P, TREE_CODE, TREE_TYPE, TYPE_ATTRIBUTES, VAR_P, and warning().

Referenced by decl_attributes(), and diag_attr_exclusions().

◆ duplicate_one_attribute()

void duplicate_one_attribute ( tree * attrs,
tree attr,
const char * name )
Duplicate all attributes with name NAME in ATTR list to *ATTRS if
they are missing there.   

References a, attribute_value_equal(), attrs, copy_node(), ggc_alloc(), lookup_attribute(), and TREE_CHAIN.

Referenced by copy_attributes_to_builtin().

◆ find_attribute_namespace()

static scoped_attributes * find_attribute_namespace ( const char * ns)
static
Return the namespace which name is NS, NULL if none exist.   

References attributes_table, ggc_alloc(), and NULL.

Referenced by attr_namespace_ignored_p(), lookup_scoped_attribute_spec(), register_attribute(), and register_scoped_attributes().

◆ find_same_attribute()

static tree find_same_attribute ( const_tree attr,
tree list )
static
See whether LIST contains at least one instance of attribute ATTR
(possibly with different arguments).  Return the first such attribute
if so, otherwise return null.   

References get_attribute_name(), get_attribute_namespace(), IDENTIFIER_LENGTH, IDENTIFIER_POINTER, NULL_TREE, and private_lookup_attribute().

Referenced by comp_type_attributes(), and decl_attributes().

◆ free_attr_data()

void free_attr_data ( )
Free data we might have allocated when adding extra attributes.   

References ignored_attributes_table.

Referenced by compile_file().

◆ get_attribute_name()

◆ get_attribute_namespace()

tree get_attribute_namespace ( const_tree attr)
Return the namespace of the attribute ATTR.  This accessor works on
GNU and C++11 (scoped) attributes.  On GNU attributes,
it returns an identifier tree for the string "gnu".

Please read the comments of cxx11_attribute_p to understand the
format of attributes.   

References cxx11_attribute_p(), get_gnu_namespace(), and TREE_PURPOSE.

Referenced by attribute_ignored_p(), decl_attributes(), find_same_attribute(), is_attribute_namespace_p(), and private_lookup_attribute().

◆ get_gnu_namespace()

static tree get_gnu_namespace ( )
static
Return the IDENTIFIER_NODE for the gnu namespace.   

References get_identifier(), and gnu_namespace_cache.

Referenced by get_attribute_namespace(), and lookup_attribute_spec().

◆ get_parm_access()

attr_access * get_parm_access ( rdwr_map & rdwr_idx,
tree parm,
tree fndecl )
Return the access specification for a function parameter PARM
or null if the current function has no such specification.   

References DECL_ARGUMENTS, ggc_alloc(), init_attr_rdwr_indices(), NULL, TREE_CHAIN, TREE_TYPE, and TYPE_ATTRIBUTES.

Referenced by gimple_parm_array_size(), and parm_object_size().

◆ handle_ignored_attributes_option()

void handle_ignored_attributes_option ( vec< char * > * v)
Parse arguments V of -Wno-attributes=.
Currently we accept:
  vendor::attr
  vendor::
This functions also registers the parsed attributes so that we don't
warn that we don't recognize them.   

References attrs, canonicalize_attr_name(), error(), get_identifier_with_length(), ggc_alloc(), i, IDENTIFIER_POINTER, ignored_attributes_table, inform(), input_location, lookup_scoped_attribute_spec(), register_scoped_attributes(), and table.

Referenced by init_attributes().

◆ has_attribute()

static bool has_attribute ( tree node,
tree attrs,
const char * aname )
static
Return true if the function decl or type NODE has been declared
with attribute ANAME among attributes ATTRS.   

References DECL_IS_MALLOC, DECL_P, DECL_PURE_P, ggc_alloc(), lookup_attribute(), TREE_NOTHROW, TREE_READONLY, and TREE_THIS_VOLATILE.

Referenced by decls_mismatched_attributes().

◆ init_attr_rdwr_indices()

void init_attr_rdwr_indices ( rdwr_map * rwm,
tree attrs )
Initialize a mapping RWM for a call to a function declared with
attribute access in ATTRS.  Each attribute positional operand
inserts one entry into the mapping with the operand number as
the key.   

References copy_list(), end(), gcc_assert, ggc_alloc(), HOST_WIDE_INT_M1U, lookup_attribute(), nreverse(), NULL, TREE_CHAIN, TREE_CODE, TREE_STRING_POINTER, TREE_VALUE, and UINT_MAX.

Referenced by get_parm_access(), maybe_warn_pass_by_reference(), and maybe_warn_read_write_only().

◆ init_attributes()

void init_attributes ( void )

◆ is_function_default_version()

bool is_function_default_version ( const tree decl)
Returns true if DECL is multi-versioned using the target attribute, and this
is the default version.  This function can only be used for targets that do
not support the "target_version" attribute.   

References DECL_ATTRIBUTES, DECL_FUNCTION_VERSIONED, gcc_assert, ggc_alloc(), lookup_attribute(), TREE_CODE, TREE_STRING_POINTER, and TREE_VALUE.

◆ lookup_attribute_spec()

const struct attribute_spec * lookup_attribute_spec ( const_tree name)
Return the spec for the attribute named NAME.  If NAME is a TREE_LIST,
it also specifies the attribute namespace.   

References get_gnu_namespace(), ggc_alloc(), lookup_scoped_attribute_spec(), TREE_CODE, TREE_PURPOSE, and TREE_VALUE.

Referenced by attribute_ignored_p(), comp_type_attributes(), decl_attributes(), and remove_attributes_matching().

◆ lookup_ident_attribute()

static tree lookup_ident_attribute ( tree attr_identifier,
tree list )
static
A variant of lookup_attribute() that can be used with an identifier
as the first argument, and where the identifier can be either
'text' or '__text__'.

Given an attribute ATTR_IDENTIFIER, and a list of attributes LIST,
return a pointer to the attribute's list element if the attribute
is part of the list, or NULL_TREE if not found.  If the attribute
appears more than once, this only returns the first occurrence; the
TREE_CHAIN of the return value should be passed back in if further
occurrences are wanted.  ATTR_IDENTIFIER must be an identifier but
can be in the form 'text' or '__text__'.   

References cmp_attrib_identifiers(), gcc_checking_assert, get_attribute_name(), ggc_alloc(), TREE_CHAIN, and TREE_CODE.

Referenced by attribute_list_contained(), and merge_attributes().

◆ lookup_scoped_attribute_spec()

static const struct attribute_spec * lookup_scoped_attribute_spec ( const_tree ns,
const_tree name )
static

◆ make_attribute()

tree make_attribute ( const char * name,
const char * arg_name,
tree chain )
Makes a function attribute of the form NAME(ARG_NAME) and chains
it to CHAIN.   

References build_string(), get_identifier(), ggc_alloc(), NULL_TREE, and tree_cons().

Referenced by expand_target_clones().

◆ make_dispatcher_decl()

tree make_dispatcher_decl ( const tree decl)
Make a dispatcher declaration for the multi-versioned function DECL.
Calls to DECL function will be replaced with calls to the dispatcher
by the front-end.  Return the decl created.   

References build_fn_decl(), build_function_type(), DECL_ARTIFICIAL, DECL_ASSEMBLER_NAME, DECL_CONTEXT, DECL_EXTERNAL, DECL_INITIAL, error_mark_node, ggc_alloc(), IDENTIFIER_POINTER, NULL_TREE, TREE_PUBLIC, TREE_TYPE, TREE_USED, and TYPE_ARG_TYPES.

◆ maybe_diag_alias_attributes()

void maybe_diag_alias_attributes ( tree alias,
tree target )
Issue a warning for the declaration ALIAS for TARGET where ALIAS
specifies either attributes that are incompatible with those of
TARGET, or attributes that are missing and that declaring ALIAS
with would benefit.   

References DECL_ATTRIBUTES, DECL_SOURCE_LOCATION, decls_mismatched_attributes(), ggc_alloc(), inform(), lookup_attribute(), NULL, NULL_TREE, pp_formatted_text(), and warning_n().

Referenced by handle_alias_pairs().

◆ merge_attributes()

tree merge_attributes ( tree a1,
tree a2 )

◆ merge_decl_attributes()

tree merge_decl_attributes ( tree olddecl,
tree newdecl )
Given decls OLDDECL and NEWDECL, merge their attributes and return
the result.   

References DECL_ATTRIBUTES, ggc_alloc(), and merge_attributes().

◆ merge_type_attributes()

tree merge_type_attributes ( tree t1,
tree t2 )
Given types T1 and T2, merge their attributes and return
the result.   

References merge_attributes(), and TYPE_ATTRIBUTES.

◆ omp_declare_simd_clauses_equal()

static bool omp_declare_simd_clauses_equal ( tree clauses1,
tree clauses2 )
static

◆ private_lookup_attribute() [1/2]

tree private_lookup_attribute ( const char * attr_name,
size_t attr_len,
tree list )
The backbone of lookup_attribute().  ATTR_LEN is the string length
of ATTR_NAME, and LIST is not NULL_TREE.

The function is called from lookup_attribute in order to optimize
for size.   

References cmp_attribs(), get_attribute_name(), ggc_alloc(), IDENTIFIER_LENGTH, IDENTIFIER_POINTER, and TREE_CHAIN.

Referenced by find_same_attribute(), lookup_attribute(), and lookup_attribute().

◆ private_lookup_attribute() [2/2]

tree private_lookup_attribute ( const char * attr_ns,
const char * attr_name,
size_t attr_ns_len,
size_t attr_len,
tree list )

◆ register_attribute()

void register_attribute ( const struct attribute_spec * attr)
Insert a single ATTR into the attribute table.   

References find_attribute_namespace(), and register_scoped_attribute().

◆ register_scoped_attribute()

static void register_scoped_attribute ( const struct attribute_spec * attr,
scoped_attributes * name_space )
static
Insert a single attribute ATTR into a namespace of attributes.   

References canonicalize_attr_name(), CONST_CAST, gcc_assert, gcc_checking_assert, ggc_alloc(), NULL, substring::str, and substring_hash().

Referenced by register_attribute(), and register_scoped_attributes().

◆ register_scoped_attributes()

scoped_attributes * register_scoped_attributes ( const scoped_attribute_specs & specs,
bool ignored_p )
Insert SPECS into its namespace.  IGNORED_P is true iff all unknown
attributes in this namespace should be ignored for the purposes of
-Wattributes.  The function returns the namespace into which the
attributes have been registered.   

References scoped_attributes::attribute_hash, scoped_attributes::attributes, attributes_table, find_attribute_namespace(), gcc_assert, ggc_alloc(), scoped_attributes::ignored_p, NULL, register_scoped_attribute(), and specs.

Referenced by handle_ignored_attributes_option(), and init_attributes().

◆ remove_attribute() [1/2]

◆ remove_attribute() [2/2]

tree remove_attribute ( const char * attr_ns,
const char * attr_name,
tree list )
Similarly but also match namespace on the removed attributes.
ATTR_NS "" stands for NULL or "gnu" namespace.   

References gcc_checking_assert, get_attribute_name(), ggc_alloc(), is_attribute_namespace_p(), is_attribute_p(), NULL, and TREE_CHAIN.

◆ remove_attributes_matching()

template<typename Predicate >
tree remove_attributes_matching ( tree attrs,
Predicate predicate )
PREDICATE acts as a function of type:

  (const_tree attr, const attribute_spec *as) -> bool

where ATTR is an attribute and AS is its possibly-null specification.
Return a list of every attribute in attribute list ATTRS for which
PREDICATE is true.  Return ATTRS itself if PREDICATE returns true
for every attribute.   

References attrs, end(), gcc_assert, ggc_alloc(), lookup_attribute_spec(), NULL_TREE, TREE_CHAIN, tree_cons(), TREE_PURPOSE, and TREE_VALUE.

Referenced by affects_type_identity_attributes(), and restrict_type_identity_attributes_to().

◆ restrict_type_identity_attributes_to()

tree restrict_type_identity_attributes_to ( tree attrs,
tree ok_attrs )
Remove attributes that affect type identity from ATTRS unless the
same attributes occur in OK_ATTRS.   

References ggc_alloc(), lookup_attribute(), remove_attributes_matching(), simple_cst_equal(), TREE_CHAIN, and TREE_VALUE.

◆ simple_cst_list_equal()

bool simple_cst_list_equal ( const_tree l1,
const_tree l2 )
Compare two constructor-element-type constants.  Return 1 if the lists
are known to be equal; otherwise return 0.   

References ggc_alloc(), NULL_TREE, simple_cst_equal(), TREE_CHAIN, and TREE_VALUE.

Referenced by attribute_value_equal().

◆ sorted_attr_string()

char * sorted_attr_string ( tree arglist)
ARGLIST is the argument to target attribute.  This function tokenizes
the comma separated arguments, sorts them and returns a string which
is a unique identifier for the comma separated arguments.   It also
replaces non-identifier characters "=,-" with "_".   

References attr_strcmp(), ggc_alloc(), i, NULL, qsort, TREE_CHAIN, TREE_STRING_POINTER, and TREE_VALUE.

Referenced by common_function_versions().

◆ substring_hash()

static hashval_t substring_hash ( const char * str,
int l )
inlinestatic
Simple hash function to avoid need to scan whole string.   

Referenced by attribute_hasher::hash(), lookup_scoped_attribute_spec(), and register_scoped_attribute().

Variable Documentation

◆ attribute_tables

array_slice<const scoped_attribute_specs *const> attribute_tables[2]
static
Table of the tables of attributes (common, language, format, machine)
searched.   

Referenced by check_attribute_tables(), and init_attributes().

◆ attributes_initialized

bool attributes_initialized = false
static

Referenced by decl_attributes(), and init_attributes().

◆ attributes_table

vec<scoped_attributes> attributes_table
static
The table of scope attributes.   

Referenced by find_attribute_namespace(), and register_scoped_attributes().

◆ gnu_namespace_cache

tree gnu_namespace_cache
static
Do not use directly; go through get_gnu_namespace instead.   

Referenced by get_gnu_namespace().

◆ ignored_attributes_table

vec<attribute_spec *> ignored_attributes_table
static
Used to stash pointers to allocated memory so that we can free them at
the end of parsing of all TUs.  

Referenced by free_attr_data(), and handle_ignored_attributes_option().