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

Abstraction of a function type. More...

#include <abg-ir.h>

Inheritance diagram for function_type:
[legend]

Classes

struct  hash
 The hashing functor for function_type. More...
 
struct  priv
 The type of the private data of the function_type type. More...
 

Public Types

typedef shared_ptr< function_decl::parameterparameter_sptr
 Convenience typedef for a shared pointer on a function_decl::parameter.
 
typedef std::vector< parameter_sptrparameters
 Convenience typedef for a vector of parameter_sptr.
 
- 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...
 

Public Member Functions

 function_type (const environment &env, size_t size_in_bits, size_t alignment_in_bits)
 A constructor for a function_type that takes no parameter and that has no return_type yet. These missing parts can (and must) be added later.
 
 function_type (type_base_sptr return_type, const parameters &parms, size_t size_in_bits, size_t alignment_in_bits)
 The most straightforward constructor for the function_type class.
 
 function_type (type_base_sptr return_type, size_t size_in_bits, size_t alignment_in_bits)
 A constructor for a function_type that takes no parameters.
 
void append_parameter (parameter_sptr parm)
 Append a new parameter to the vector of parameters of the current instance of function_type.
 
const interned_stringget_cached_name (bool internal=false) const
 Get the name of the current function_type.
 
parameters::const_iterator get_first_non_implicit_parm () const
 Get the first parameter of the function.
 
parameters::const_iterator get_first_parm () const
 Get the first parameter of the function.
 
const parametersget_parameters () const
 Getter for the set of parameters of the current intance of function_type.
 
const parameter_sptr get_parm_at_index_from_first_non_implicit_parm (size_t) const
 Get the Ith parameter of the vector of parameters of the current instance of function_type.
 
virtual string get_pretty_representation (bool internal=false, bool qualified_name=true) const
 Return a copy of the pretty representation of the current function_type.
 
type_base_sptr get_return_type () const
 Getter for the return type of the current instance of function_type.
 
virtual hash_t hash_value () const
 Return the hash value of the current IR node.
 
bool is_variadic () const
 Test if the current instance of function_type is for a variadic function.
 
virtual bool operator== (const type_base &) const
 Equality operator for function_type.
 
void set_parameters (const parameters &p)
 Setter for the parameters of the current instance of function_type.
 
void set_return_type (type_base_sptr t)
 Setter of the return type of the current instance of function_type.
 
virtual bool traverse (ir_node_visitor &)
 Traverses an instance of function_type, visiting all the sub-types and decls that it might contain.
 
- Public Member Functions inherited from type_base
 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 bool operator!= (const type_base &) const
 Inequality operator.
 
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.
 
- 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.
 
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 ir_traversable_base
- Public Member Functions inherited from traversable_base
virtual ~traversable_base ()
 Destructor of the traversable_base type.
 

Public Attributes

std::unique_ptr< privpriv_
 
- Public Attributes inherited from type_base
privpriv_
 
- Public Attributes inherited from type_or_decl_base
std::unique_ptr< privpriv_
 

Protected Member Functions

virtual void on_canonical_type_set ()
 This function is automatically invoked whenever an instance of this type is canonicalized.
 
- Protected Member Functions inherited from type_base
- 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

bool equals (const function_type &l, const function_type &r, change_kind *k)
 Compare two function types.
 

Detailed Description

Abstraction of a function type.

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

Member Typedef Documentation

◆ parameter_sptr

Convenience typedef for a shared pointer on a function_decl::parameter.

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

◆ parameters

std::vector<parameter_sptr> parameters

Convenience typedef for a vector of parameter_sptr.

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

Constructor & Destructor Documentation

◆ function_type() [1/3]

function_type ( type_base_sptr return_type,
const parameters & parms,
size_t size_in_bits,
size_t alignment_in_bits )

The most straightforward constructor for the function_type class.

Parameters
return_typethe return type of the function type.
parmsthe list of parameters of the function type. Stricto sensu, we just need a list of types; we are using a list of parameters (where each parameter also carries the name of the parameter and its source location) to try and provide better diagnostics whenever it makes sense. If it appears that this wasts too many resources, we can fall back to taking just a vector of types here.
size_in_bitsthe size of this type, in bits.
alignment_in_bitsthe alignment of this type, in bits.
size_in_bitsthe size of this type.

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

◆ function_type() [2/3]

function_type ( type_base_sptr return_type,
size_t size_in_bits,
size_t alignment_in_bits )

A constructor for a function_type that takes no parameters.

Parameters
return_typethe return type of this function_type.
size_in_bitsthe size of this type, in bits.
alignment_in_bitsthe alignment of this type, in bits.

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

◆ function_type() [3/3]

function_type ( const environment & env,
size_t size_in_bits,
size_t alignment_in_bits )

A constructor for a function_type that takes no parameter and that has no return_type yet. These missing parts can (and must) be added later.

Parameters
envthe environment we are operating from.
size_in_bitsthe size of this type, in bits.
alignment_in_bitsthe alignment of this type, in bits.

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

◆ ~function_type()

~function_type ( )
virtual

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

Member Function Documentation

◆ append_parameter()

void append_parameter ( parameter_sptr parm)

Append a new parameter to the vector of parameters of the current instance of function_type.

Parameters
parmthe parameter to append.

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

◆ get_cached_name()

const interned_string & get_cached_name ( bool internal = false) const

Get the name of the current function_type.

The name is retrieved from a cache. If the cache is empty, this function computes the name of the type, stores it in the cache and returns it. Subsequent invocation of the function are going to just hit the cache.

Note that if the type is *NOT* canonicalized then function type name is never cached.

Parameters
internalif true then it means the function type name is going to be used for purposes that are internal to libabigail itself. If you don't know what this is then you probably should set this parameter to 'false'.
Returns
the name of the function type.

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

◆ get_first_non_implicit_parm()

function_type::parameters::const_iterator get_first_non_implicit_parm ( ) const

Get the first parameter of the function.

If the function is a non-static member function, the parameter returned is the first one following the implicit 'this' parameter.

Returns
the first non implicit parameter of the function.

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

◆ get_first_parm()

function_type::parameters::const_iterator get_first_parm ( ) const

Get the first parameter of the function.

Note that if the function is a non-static member function, the parameter returned is the implicit 'this' parameter.

Returns
the first parameter of the function.

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

◆ get_parameters()

const function_decl::parameters & get_parameters ( ) const

Getter for the set of parameters of the current intance of function_type.

Returns
the parameters of the current instance of function_type.

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

◆ get_parm_at_index_from_first_non_implicit_parm()

const function_decl::parameter_sptr get_parm_at_index_from_first_non_implicit_parm ( size_t i) const

Get the Ith parameter of the vector of parameters of the current instance of function_type.

Note that the first parameter is at index 0. That parameter is the first parameter that comes after the possible implicit "this" parameter, when the current instance function_type is for a member function. Otherwise, if the current instance of function_type is for a non-member function, the parameter at index 0 is the first parameter of the function.

Parameters
ithe index of the parameter to return. If i is greater than the index of the last parameter, then this function returns an empty parameter (smart) pointer.
Returns
the i th parameter that is not implicit.

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

◆ get_pretty_representation()

string get_pretty_representation ( bool internal = false,
bool qualified_name = true ) const
virtual

Return a copy of the pretty representation of the current function_type.

Parameters
internalset to true if the call is intended to get a representation of the decl (or type) for the purpose of canonical type comparison. This is mainly used in the function type_base::get_canonical_type_for().

In other words if the argument for this parameter is true then the call is meant for internal use (for technical use inside the library itself), false otherwise. If you don't know what this is for, then set it to false.

Returns
a copy of the pretty representation of the current function_type.

Implements type_or_decl_base.

Reimplemented in method_type.

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

◆ get_return_type()

type_base_sptr get_return_type ( ) const

Getter for the return type of the current instance of function_type.

Returns
the return type.

Definition at line 21540 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_base.

Reimplemented in method_type.

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

◆ is_variadic()

bool is_variadic ( ) const

Test if the current instance of function_type is for a variadic function.

A variadic function is a function that takes a variable number of arguments.

Returns
true iff the current instance of function_type is for a variadic function.

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

◆ on_canonical_type_set()

void on_canonical_type_set ( )
protectedvirtual

This function is automatically invoked whenever an instance of this type is canonicalized.

It's an overload of the virtual type_base::on_canonical_type_set.

We put here what is thus meant to be executed only at the point of type canonicalization.

Reimplemented from type_base.

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

◆ operator==()

bool operator== ( const type_base & other) const
virtual

Equality operator for function_type.

Parameters
othe other function_type to compare against.
Returns
true iff the two function_type are equal.

Reimplemented from type_base.

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

◆ set_parameters()

void set_parameters ( const parameters & p)

Setter for the parameters of the current instance of function_type.

Parameters
pthe new vector of parameters to set.

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

◆ set_return_type()

void set_return_type ( type_base_sptr t)

Setter of the return type of the current instance of function_type.

Parameters
tthe new return type to set.

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

◆ traverse()

bool traverse ( ir_node_visitor & v)
virtual

Traverses an instance of function_type, visiting all the sub-types and decls that it might contain.

Parameters
vthe visitor that is used to visit every IR sub-node of the current node.
Returns
true if either
  • all the children nodes of the current IR node were traversed and the calling code should keep going with the traversing.
  • or the current IR node is already being traversed. Otherwise, returning false means that the calling code should not keep traversing the tree.

Reimplemented from type_base.

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

Friends And Related Symbol Documentation

◆ equals

bool equals ( const function_type & l,
const function_type & r,
change_kind * k )
friend

Compare two function types.

In case these function types are actually method types, this function avoids comparing two parameters (of the function types) if the types of the parameters are actually the types of the classes of the method types. This prevents infinite recursion during the comparison of two classes that are structurally identical.

This is a subroutine of the equality operator of function_type.

Parameters
lhsthe first function type to consider
rhsthe second function type to consider
ka pointer to a bitfield set by the function to give information about the kind of changes carried by lhs and rhs. It is set iff k is non-null and the function returns false.

Please note that setting k to a non-null value does have a negative performance impact because even if l and r are not equal, the function keeps up the comparison in order to determine the different kinds of ways in which they are different.

Returns
true if lhs == rhs, false otherwise.

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

Member Data Documentation

◆ priv_

std::unique_ptr<priv> priv_

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


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