libabigail
Classes | Public Member Functions | Public Attributes | Protected Member Functions | Friends | List of all members
type_base Class Reference

An abstraction helper for type declarations. More...

#include <abg-ir.h>

Inheritance diagram for type_base:
[legend]

Classes

struct  dynamic_hash
 
struct  hash
 Hash functor for instances of type_base. More...
 
struct  priv
 Definition of the private data of type_base. More...
 
struct  shared_ptr_hash
 

Public Member Functions

 type_base (const environment &e, size_t s, size_t a)
 The constructor of type_base. More...
 
virtual size_t get_alignment_in_bits () const
 Getter for the alignment of the type. More...
 
const interned_stringget_cached_pretty_representation (bool internal=false) const
 Get the pretty representation of the current type. More...
 
type_base_sptr get_canonical_type () const
 Getter of the canonical type of the current instance of type_base. More...
 
type_baseget_naked_canonical_type () const
 Getter of the canonical type pointer. More...
 
virtual size_t get_size_in_bits () const
 Getter for the size of the type. More...
 
virtual bool operator!= (const type_base &) const
 Inequality operator. More...
 
virtual bool operator== (const type_base &) const
 Return true iff both type declarations are equal. More...
 
virtual void set_alignment_in_bits (size_t)
 Setter for the alignment of the type. More...
 
virtual void set_size_in_bits (size_t)
 Setter for the size of the type. More...
 
virtual bool traverse (ir_node_visitor &)
 Default implementation of traversal for types. This function does nothing. It must be implemented by every single new type that is written. More...
 
- Public Member Functions inherited from type_or_decl_base
 type_or_decl_base (const environment &, enum type_or_decl_kind k=ABSTRACT_TYPE_OR_DECL)
 Constructor of type_or_decl_base. More...
 
virtual ~type_or_decl_base ()
 The destructor of the type_or_decl_base type. More...
 
locationget_artificial_location () const
 Getter of the artificial location of the artifact. More...
 
corpusget_corpus ()
 Get the corpus this ABI artifact belongs to. More...
 
const corpusget_corpus () const
 Get the corpus this ABI artifact belongs to. More...
 
const environmentget_environment () const
 Getter of the environment of the current ABI artifact. More...
 
bool get_is_artificial () const
 Getter of the flag that says if the artefact is artificial. More...
 
virtual string get_pretty_representation (bool internal=false, bool qualified_name=true) const =0
 
translation_unitget_translation_unit ()
 Get the translation_unit this ABI artifact belongs to. More...
 
const translation_unitget_translation_unit () const
 Get the translation_unit this ABI artifact belongs to. More...
 
bool has_artificial_location () const
 Test if the current ABI artifact carries an artificial location. More...
 
void set_artificial_location (const location &)
 Setter of the artificial location of the artificat. More...
 
void set_is_artificial (bool)
 Setter of the flag that says if the artefact is artificial. More...
 
void set_translation_unit (translation_unit *)
 Set the translation_unit this ABI artifact belongs to. More...
 
- Public Member Functions inherited from traversable_base
virtual ~traversable_base ()
 Destructor of the traversable_base type. More...
 

Public Attributes

privpriv_
 

Protected Member Functions

virtual void on_canonical_type_set ()
 This method is invoked automatically right after the current instance of class_decl has been canonicalized. More...
 
- Protected Member Functions inherited from type_or_decl_base
bool hashing_started () const
 Getter for the 'hashing_started' property. More...
 
void hashing_started (bool) const
 Setter for the 'hashing_started' property. More...
 
enum type_or_decl_kind kind () const
 Getter for the "kind" property of type_or_decl_base type. More...
 
void kind (enum type_or_decl_kind)
 Setter for the "kind" property of type_or_decl_base type. More...
 
type_or_decl_baseoperator= (const type_or_decl_base &)
 
void * runtime_type_instance ()
 Getter of the pointer to the runtime type sub-object of the current instance. More...
 
const void * runtime_type_instance () const
 Getter of the pointer to the runtime type sub-object of the current instance. More...
 
void runtime_type_instance (void *)
 Setter of the pointer to the runtime type sub-object of the current instance. More...
 
void * type_or_decl_base_pointer ()
 Getter of the pointer to either the type_base sub-object of the current instance if it's a type, or to the decl_base sub-object of the current instance if it's a decl. More...
 
const void * type_or_decl_base_pointer () const
 Getter of the pointer to either the type_base sub-object of the current instance if it's a type, or to the decl_base sub-object of the current instance if it's a decl. More...
 
- Protected Member Functions inherited from traversable_base
 traversable_base ()
 Default constructor of the traversable_base type. More...
 
bool visiting () const
 This should returns false before and after the node has been visiting. During the visiting of the node (and of its children) this should return true. More...
 
void visiting (bool f)
 The traversing code should be responsible of calling this, not the user code. More...
 

Friends

type_base_sptr canonicalize (type_base_sptr)
 Compute the canonical type of a given type. More...
 

Additional Inherited Members

- Protected Types inherited from type_or_decl_base
enum  type_or_decl_kind {
  ABSTRACT_TYPE_OR_DECL , ABSTRACT_DECL_BASE , ABSTRACT_SCOPE_DECL , GLOBAL_SCOPE_DECL ,
  NAMESPACE_DECL , VAR_DECL , FUNCTION_DECL , FUNCTION_PARAMETER_DECL ,
  METHOD_DECL , TEMPLATE_DECL , ABSTRACT_TYPE_BASE , ABSTRACT_SCOPE_TYPE_DECL ,
  BASIC_TYPE , SUBRANGE_TYPE , QUALIFIED_TYPE , POINTER_TYPE ,
  REFERENCE_TYPE , POINTER_TO_MEMBER_TYPE , ARRAY_TYPE , ENUM_TYPE ,
  TYPEDEF_TYPE , CLASS_TYPE , UNION_TYPE , FUNCTION_TYPE ,
  METHOD_TYPE
}
 This is a bitmap type which instance is meant to contain the runtime type of a given ABI artifact. Bits of the identifiers of the type of a given artifact as well as the types it inherits from are to be set to 1. More...
 

Detailed Description

An abstraction helper for type declarations.

Definition at line 1972 of file abg-ir.h.

Constructor & Destructor Documentation

◆ type_base()

type_base ( const environment e,
size_t  s,
size_t  a 
)

The constructor of type_base.

Parameters
sthe size of the type, in bits.
athe alignment of the type, in bits.

Definition at line 15998 of file abg-ir.cc.

Member Function Documentation

◆ get_alignment_in_bits()

size_t get_alignment_in_bits ( ) const
virtual

Getter for the alignment of the type.

Returns
the alignment of the type in bits.

Reimplemented in class_or_union, and typedef_decl.

Definition at line 16137 of file abg-ir.cc.

◆ get_cached_pretty_representation()

const interned_string & get_cached_pretty_representation ( bool  internal = false) const

Get the pretty representation of the current type.

The pretty representation is retrieved from a cache. If the cache is empty, this function computes the pretty representation, put it in the cache and returns it.

Note that if the type is *NOT* canonicalized, the pretty representation is never cached.

Parameters
internalif true, then the pretty representation is to be used for purpuses that are internal to the libabigail library itself. If you don't know what this means, then you probably should set this parameter to "false".

Definition at line 16044 of file abg-ir.cc.

◆ get_canonical_type()

type_base_sptr get_canonical_type ( ) const

Getter of the canonical type of the current instance of type_base.

Returns
a smart pointer to the canonical type of the current intance of type_base, or an empty smart pointer if the current instance of type_base doesn't have any canonical type.

Definition at line 16011 of file abg-ir.cc.

◆ get_naked_canonical_type()

type_base * get_naked_canonical_type ( ) const

Getter of the canonical type pointer.

Note that this function doesn't return a smart pointer, but rather the underlying pointer managed by the smart pointer. So it's as fast as possible. This getter is to be used in code paths that are proven to be performance hot spots; especially, when comparing sensitive types like class, function, pointers and reference types. Those are compared extremely frequently and thus, their accessing the canonical type must be fast.

Returns
the canonical type pointer, not managed by a smart pointer.

Definition at line 16027 of file abg-ir.cc.

◆ get_size_in_bits()

size_t get_size_in_bits ( ) const
virtual

Getter for the size of the type.

Returns
the size in bits of the type.

Reimplemented in class_or_union, typedef_decl, and qualified_type_def.

Definition at line 16123 of file abg-ir.cc.

◆ on_canonical_type_set()

void on_canonical_type_set ( )
protectedvirtual

This method is invoked automatically right after the current instance of class_decl has been canonicalized.

Reimplemented in class_decl, function_type, reference_type_def, pointer_type_def, and qualified_type_def.

Definition at line 15754 of file abg-ir.cc.

◆ operator!=()

bool operator!= ( const type_base other) const
virtual

Inequality operator.

Parameters
otherthe instance of type_base to compare the current instance against.
Returns
true iff the current instance is different from other.

Reimplemented in array_type_def::subrange_type, and type_decl.

Definition at line 16109 of file abg-ir.cc.

◆ operator==()

bool operator== ( const type_base other) const
virtual

Return true iff both type declarations are equal.

Note that this doesn't test if the scopes of both types are equal.

Reimplemented in union_decl, class_decl, class_or_union, template_tparameter, type_tparameter, function_type, typedef_decl, enum_type_decl, array_type_def, array_type_def::subrange_type, ptr_to_mbr_type, reference_type_def, pointer_type_def, qualified_type_def, scope_type_decl, and type_decl.

Definition at line 16099 of file abg-ir.cc.

◆ set_alignment_in_bits()

void set_alignment_in_bits ( size_t  a)
virtual

Setter for the alignment of the type.

Parameters
athe new alignment – in bits.

Reimplemented in class_or_union.

Definition at line 16130 of file abg-ir.cc.

◆ set_size_in_bits()

void set_size_in_bits ( size_t  s)
virtual

Setter for the size of the type.

Parameters
sthe new size – in bits.

Reimplemented in class_or_union.

Definition at line 16116 of file abg-ir.cc.

◆ traverse()

bool traverse ( ir_node_visitor v)
virtual

Default implementation of traversal for types. This function does nothing. It must be implemented by every single new type that is written.

Please look at e.g, class_decl::traverse() for an example of how to implement this.

Parameters
vthe visitor used to visit the type.

Reimplemented from type_or_decl_base.

Reimplemented in union_decl, class_decl, class_or_union, enum_type_decl, array_type_def, ptr_to_mbr_type, reference_type_def, pointer_type_def, qualified_type_def, function_type, typedef_decl, array_type_def::subrange_type, scope_type_decl, and type_decl.

Definition at line 16149 of file abg-ir.cc.

Friends And Related Function Documentation

◆ canonicalize

type_base_sptr canonicalize ( type_base_sptr  )
friend

Compute the canonical type of a given type.

It means that after invoking this function, comparing the intance instance type_base and another one (on which type_base::enable_canonical_equality() would have been invoked as well) is performed by just comparing the pointer values of the canonical types of both types. That equality comparison is supposedly faster than structural comparison of the types.

Parameters
ta smart pointer to the instance of type_base for which to compute the canonical type. After this call, t->get_canonical_type() will return the newly computed canonical type.
Returns
the canonical type computed for t.

Definition at line 15880 of file abg-ir.cc.


The documentation for this class was generated from the following files: