GCC Middle and Back End API Reference
attribs.c File Reference

Data Structures

struct  substring
struct  attribute_hasher
struct  scoped_attributes

Functions

static hashval_t substring_hash ()
static scoped_attributesfind_attribute_namespace (const char *)
static void register_scoped_attribute (const struct attribute_spec *, scoped_attributes *)
static void extract_attribute_substring ()
scoped_attributesregister_scoped_attributes (const struct attribute_spec *attributes, const char *ns)
static scoped_attributesfind_attribute_namespace ()
void init_attributes ()
void register_attribute ()
struct attribute_spec * lookup_scoped_attribute_spec ()
struct attribute_spec * lookup_attribute_spec ()
tree decl_attributes ()
bool cxx11_attribute_p ()
tree get_attribute_name ()
tree get_attribute_namespace ()
void apply_tm_attr ()

Variables

static struct attribute_spec * attribute_tables [4]
static vec< scoped_attributesattributes_table
static bool attributes_initialized = false
static struct attribute_spec empty_attribute_table []

Function Documentation

void apply_tm_attr ( )
   Subroutine of set_method_tm_attributes.  Apply TM attribute ATTR
   to the method FNDECL.  
bool cxx11_attribute_p ( )
   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.  
tree decl_attributes ( )
   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).  
     If this is a function and the user used #pragma GCC optimize, add the
     options to the attribute((optimize(...))) list.  
     If this is a function and the user used #pragma GCC target, add the
     options to the attribute((target(...))) list.  
     A "naked" function attribute implies "noinline" and "noclone" for
     those targets that support it.  
             This is a c++11 attribute that appertains to a
             type-specifier, outside of the definition of, a class
             type.  Ignore it.  
                 Pass on this attribute to be tried again.  
         If we require a type, but were passed a decl, set up to make a
         new type and update the one in the decl.  ATTR_FLAG_TYPE_IN_PLACE
         would have applied if we'd been passed a type, but we cannot modify
         the decl's type in place here.  
             Allow ATTR_FLAG_TYPE_IN_PLACE for the type's naming decl.  
                 OK, this is a bit convoluted.  We can't just make a copy
                 of the pointer type and modify its TREE_TYPE, because if
                 we change the attributes of the target type the pointer
                 type needs to have a different TYPE_MAIN_VARIANT.  So we
                 pull out the target type now, frob it as appropriate, and
                 rebuild the pointer type later.

                 This would all be simpler if attributes were part of the
                 declarator, grumble grumble.  
                 Pass on this attribute to be tried again.  
         Layout the decl in case anything changed.  
                 This attribute isn't already in the list.  
                     If this is the main variant, also push the attributes
                     out to the other variants.  
             Rebuild the function pointer type and put it in the
             appropriate place.  

References chainon(), copy_list(), get_identifier(), lookup_attribute(), and targetm.

static void extract_attribute_substring ( )
static
   Return base name of the attribute.  Ie '__attr__' is turned into 'attr'.
   To avoid need for copying, we simply return length of the string.  

References find_attribute_namespace().

Referenced by register_scoped_attribute().

static scoped_attributes* find_attribute_namespace ( const char *  )
static
static scoped_attributes* find_attribute_namespace ( )
static
tree get_attribute_name ( )
   Return the name of the attribute ATTR.  This accessor works on GNU
   and C++11 (scoped) attributes.

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

Referenced by assign_assembler_name_if_neeeded(), build_decl_attribute_variant(), find_decls_types_in_eh_region(), find_decls_types_in_node(), iterative_hash_hashval_t(), and print_value_expr_statistics().

tree get_attribute_namespace ( )
   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.  
void init_attributes ( void  )
   Initialize attribute tables, and make some sanity checks
   if --enable-checking.  
     Translate NULL pointers to pointers to the empty table.  
     Make some sanity checks on the attribute tables.  
             The name must not begin and end with __.  
             The minimum and maximum lengths must be consistent.  
             An attribute cannot require both a DECL and a TYPE.  
             If an attribute requires a function type, in particular
             it requires a type.  
     Check that each name occurs just once in each table.  
     Check that no name occurs in more than one table.  Names that
     begin with '*' are exempt, and may be overridden.  
       Put all the GNU attributes into the "gnu" namespace.  
struct attribute_spec* lookup_attribute_spec ( )
read
   Return the spec for the attribute named NAME.  If NAME is a TREE_LIST,
   it also specifies the attribute namespace.  

Referenced by build_decl_attribute_variant(), and iterative_hash_hashval_t().

struct attribute_spec* lookup_scoped_attribute_spec ( )
read
   Return the spec for the scoped attribute with namespace NS and
   name NAME.   
void register_attribute ( )
   Insert a single ATTR into the attribute table.  
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.  
     Attribute names in the table must be in the form 'text' and not
     in the form '__text__'.  

References extract_attribute_substring(), find_attribute_namespace(), substring::length, substring::str, and substring_hash().

scoped_attributes* register_scoped_attributes ( const struct attribute_spec *  attributes,
const char *  ns 
)
read
   Insert an array of attributes ATTRIBUTES into a namespace.  This
   array must be NULL terminated.  NS is the name of attribute
   namespace.  The function returns the namespace into which the
   attributes have been registered.  
     See if we already have attributes in the namespace NS.  
         We don't have any namespace NS yet.  Create one.  
     Really add the attributes to their namespace now.  
static hashval_t substring_hash ( )
inlinestatic
   Simple hash function to avoid need to scan whole string.  

References attribute_hasher::hash().

Referenced by register_scoped_attribute().


Variable Documentation

struct attribute_spec* attribute_tables[4]
static
@verbatim 

Functions dealing with attribute handling, used by most front ends. Copyright (C) 1992-2013 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/.

   Table of the tables of attributes (common, language, format, machine)
   searched.  

Referenced by find_attribute_namespace().

bool attributes_initialized = false
static
vec<scoped_attributes> attributes_table
static
   The table of scope attributes.  
struct attribute_spec empty_attribute_table[]
static
Initial value:
{
{ NULL, 0, 0, false, false, false, NULL, false }
}
   Default empty table of attributes.