libabigail
Loading...
Searching...
No Matches
type_base Class Reference

An abstraction helper for type declarations. More...

#include <abg-ir.h>

Inheritance diagram for type_base:
[legend]

Classes

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

Public Member Functions

 type_base (const environment &e, size_t s, size_t a)
 The constructor of type_base.
 
virtual size_t get_alignment_in_bits () const
 Getter for the alignment of the type.
 
const interned_stringget_cached_pretty_representation (bool internal=false) const
 Get the pretty representation of the current type.
 
type_base_sptr get_canonical_type () const
 Getter of the canonical type of the current instance of type_base.
 
type_baseget_naked_canonical_type () const
 Getter of the canonical type pointer.
 
virtual size_t get_size_in_bits () const
 Getter for the size of the type.
 
virtual hash_t hash_value () const
 Return the hash value of the current IR node.
 
virtual bool operator!= (const type_base &) const
 Inequality operator.
 
virtual bool operator== (const type_base &) const
 Return true iff both type declarations are equal.
 
virtual void set_alignment_in_bits (size_t)
 Setter for the alignment of the type.
 
virtual void set_size_in_bits (size_t)
 Setter for the size of the type.
 
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.
 
- 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.
 
virtual ~type_or_decl_base ()
 The destructor of the type_or_decl_base type.
 
locationget_artificial_location () const
 Getter of the artificial location of the artifact.
 
corpusget_corpus ()
 Get the corpus this ABI artifact belongs to.
 
const corpusget_corpus () const
 Get the corpus this ABI artifact belongs to.
 
const environmentget_environment () const
 Getter of the environment of the current ABI artifact.
 
bool get_is_artificial () const
 Getter of the flag that says if the artefact is artificial.
 
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.
 
const translation_unitget_translation_unit () const
 Get the translation_unit this ABI artifact belongs to.
 
bool has_artificial_location () const
 Test if the current ABI artifact carries an artificial location.
 
enum type_or_decl_kind kind () const
 Getter for the "kind" property of type_or_decl_base type.
 
void set_artificial_location (const location &)
 Setter of the artificial location of the artificat.
 
void set_is_artificial (bool)
 Setter of the flag that says if the artefact is artificial.
 
void set_translation_unit (translation_unit *)
 Set the translation_unit this ABI artifact belongs to.
 
- Public Member Functions inherited from traversable_base
virtual ~traversable_base ()
 Destructor of the traversable_base type.
 

Public Attributes

privpriv_
 
- Public Attributes inherited from type_or_decl_base
std::unique_ptr< 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.
 
- Protected Member Functions inherited from type_or_decl_base
void kind (enum type_or_decl_kind)
 Setter for the "kind" property of type_or_decl_base type.
 
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.
 
const void * runtime_type_instance () const
 Getter of the pointer to the runtime type sub-object of the current instance.
 
void runtime_type_instance (void *)
 Setter of the pointer to the runtime type sub-object of the current instance.
 
void set_hash_value (hash_t) const
 
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.
 
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.
 
- Protected Member Functions inherited from traversable_base
 traversable_base ()
 Default constructor of the traversable_base type.
 
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.
 
void visiting (bool f)
 The traversing code should be responsible of calling this, not the user code.
 

Friends

type_base_sptr canonicalize (type_base_sptr t, bool do_log=false, bool show_stats=false)
 Compute the canonical type of a given type.
 

Additional Inherited Members

- Public 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 2002 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 16264 of file abg-ir.cc.

◆ ~type_base()

~type_base ( )
virtual

Definition at line 16448 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 16424 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.

Please note that if this function is called too early in the life cycle of the type (before the type is fully constructed), then the pretty representation that is cached is going to represent a non-complete (and thus wrong) representation of the type. Thus this function must be called only once the type is fully constructed.

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".
Returns
a reference to a cached interned_string holding the pretty representation of the current type.

Definition at line 16331 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 16291 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 16307 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, qualified_type_def, and typedef_decl.

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

◆ hash_value()

hash_t hash_value ( ) const
virtual

Return the hash value of the current IR node.

Note that upon the first invocation, this member functions computes the hash value and returns it. Subsequent invocations just return the hash value that was previously calculated.

Returns
the hash value of the current IR node.

Reimplemented from type_or_decl_base.

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

Definition at line 16277 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, pointer_type_def, qualified_type_def, and reference_type_def.

Definition at line 16010 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 16396 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 array_type_def, array_type_def::subrange_type, class_decl, class_or_union, enum_type_decl, function_type, pointer_type_def, ptr_to_mbr_type, qualified_type_def, reference_type_def, scope_type_decl, template_tparameter, type_decl, type_tparameter, typedef_decl, and union_decl.

Definition at line 16386 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 16417 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 16403 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 array_type_def::subrange_type, array_type_def, class_decl, class_or_union, enum_type_decl, function_type, pointer_type_def, ptr_to_mbr_type, qualified_type_def, reference_type_def, scope_type_decl, type_decl, typedef_decl, and union_decl.

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

Friends And Related Symbol Documentation

◆ canonicalize

type_base_sptr canonicalize ( type_base_sptr t,
bool do_log = false,
bool show_stats = false )
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.
do_logif true then logs are emitted about canonicalization progress.
show_statsif true and if do_log is true as well, then more detailed logs are emitted about canonicalization.
Returns
the canonical type computed for t.

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

Member Data Documentation

◆ priv_

priv* priv_

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


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