libabigail
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Friends | List of all members
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. More...
 
typedef std::vector< parameter_sptrparameters
 Convenience typedef for a vector of parameter_sptr. More...
 

Public Member Functions

 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. More...
 
 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. More...
 
 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. More...
 
void append_parameter (parameter_sptr parm)
 Append a new parameter to the vector of parameters of the current instance of function_type. More...
 
const interned_stringget_cached_name (bool internal=false) const
 Get the name of the current function_type. More...
 
parameters::const_iterator get_first_non_implicit_parm () const
 Get the first parameter of the function. More...
 
parameters::const_iterator get_first_parm () const
 Get the first parameter of the function. More...
 
const parametersget_parameters () const
 Getter for the set of parameters of the current intance of function_type. More...
 
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. More...
 
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. More...
 
type_base_sptr get_return_type () const
 Getter for the return type of the current instance of function_type. More...
 
bool is_variadic () const
 Test if the current instance of function_type is for a variadic function. More...
 
virtual bool operator== (const type_base &) const
 Equality operator for function_type. More...
 
void set_parameters (const parameters &p)
 Setter for the parameters of the current instance of function_type. More...
 
void set_return_type (type_base_sptr t)
 Setter of the return type of the current instance of function_type. More...
 
virtual bool traverse (ir_node_visitor &)
 Traverses an instance of function_type, visiting all the sub-types and decls that it might contain. More...
 
- Public Member Functions inherited from type_base
 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 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...
 
- 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...
 
const corpusget_corpus () const
 Get the corpus this ABI artifact belongs to. More...
 
corpusget_corpus ()
 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...
 
const translation_unitget_translation_unit () const
 Get the translation_unit this ABI artifact belongs to. More...
 
translation_unitget_translation_unit ()
 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

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

Protected Member Functions

virtual void on_canonical_type_set ()
 This function is automatically invoked whenever an instance of this type is 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 &)
 
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 ()
 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...
 
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...
 
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...
 
- 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

bool equals (const function_type &, const function_type &, change_kind *)
 Compare two function types. 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, QUALIFIED_TYPE, POINTER_TYPE, REFERENCE_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

Abstraction of a function type.

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

Member Typedef Documentation

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

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

typedef std::vector<parameter_sptr> parameters

Convenience typedef for a vector of parameter_sptr.

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

Constructor & Destructor Documentation

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 20488 of file abg-ir.cc.

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 20521 of file abg-ir.cc.

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 20540 of file abg-ir.cc.

Member Function Documentation

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 20636 of file abg-ir.cc.

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 20882 of file abg-ir.cc.

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 20840 of file abg-ir.cc.

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 20862 of file abg-ir.cc.

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 20572 of file abg-ir.cc.

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 20592 of file abg-ir.cc.

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 20949 of file abg-ir.cc.

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 20555 of file abg-ir.cc.

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 20651 of file abg-ir.cc.

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 20465 of file abg-ir.cc.

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 20925 of file abg-ir.cc.

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 20613 of file abg-ir.cc.

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 20563 of file abg-ir.cc.

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 20966 of file abg-ir.cc.

Friends And Related Function Documentation

bool equals ( const function_type ,
const function_type ,
change_kind  
)
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 20684 of file abg-ir.cc.


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