libabigail
|
Abstraction of a function type. More...
#include <abg-ir.h>
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::parameter > | parameter_sptr |
Convenience typedef for a shared pointer on a function_decl::parameter. | |
typedef std::vector< parameter_sptr > | parameters |
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_string & | get_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 parameters & | get_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_string & | get_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_base * | get_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. | |
location & | get_artificial_location () const |
Getter of the artificial location of the artifact. | |
corpus * | get_corpus () |
Get the corpus this ABI artifact belongs to. | |
const corpus * | get_corpus () const |
Get the corpus this ABI artifact belongs to. | |
const environment & | get_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_unit * | get_translation_unit () |
Get the translation_unit this ABI artifact belongs to. | |
const translation_unit * | get_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< priv > | priv_ |
Public Attributes inherited from type_base | |
priv * | priv_ |
Public Attributes inherited from type_or_decl_base | |
std::unique_ptr< priv > | priv_ |
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_base & | operator= (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. | |
shared_ptr<function_decl::parameter> parameter_sptr |
Convenience typedef for a shared pointer on a function_decl::parameter.
std::vector<parameter_sptr> parameters |
Convenience typedef for a vector of parameter_sptr.
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.
return_type | the return type of the function type. |
parms | the 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_bits | the size of this type, in bits. |
alignment_in_bits | the alignment of this type, in bits. |
size_in_bits | the size of this type. |
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.
return_type | the return type of this function_type. |
size_in_bits | the size of this type, in bits. |
alignment_in_bits | the alignment of this type, in bits. |
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.
env | the environment we are operating from. |
size_in_bits | the size of this type, in bits. |
alignment_in_bits | the alignment of this type, in bits. |
|
virtual |
void append_parameter | ( | parameter_sptr | parm | ) |
Append a new parameter to the vector of parameters of the current instance of function_type.
parm | the parameter to append. |
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.
internal | if 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'. |
function_type::parameters::const_iterator get_first_non_implicit_parm | ( | ) | const |
function_type::parameters::const_iterator get_first_parm | ( | ) | const |
const function_decl::parameters & get_parameters | ( | ) | const |
Getter for the set of parameters of the current intance of function_type.
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.
i | the 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. |
i
th parameter that is not implicit.
|
virtual |
Return a copy of the pretty representation of the current function_type.
internal | set 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.
Implements type_or_decl_base.
Reimplemented in method_type.
type_base_sptr get_return_type | ( | ) | const |
Getter for the return type of the current instance of function_type.
|
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.
Reimplemented from type_base.
Reimplemented in method_type.
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.
|
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.
|
virtual |
Equality operator for function_type.
o | the other function_type to compare against. |
Reimplemented from type_base.
void set_parameters | ( | const parameters & | p | ) |
Setter for the parameters of the current instance of function_type.
p | the new vector of parameters to set. |
void set_return_type | ( | type_base_sptr | t | ) |
Setter of the return type of the current instance of function_type.
t | the new return type to set. |
|
virtual |
Traverses an instance of function_type, visiting all the sub-types and decls that it might contain.
v | the visitor that is used to visit every IR sub-node of the current node. |
Reimplemented from type_base.
|
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.
lhs | the first function type to consider |
rhs | the second function type to consider |
k | a 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.