libabigail
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
environment Class Reference

This is an abstraction of the set of resources necessary to manage several aspects of the internal representations of the Abigail library. More...

#include <abg-ir.h>

Classes

struct  priv
 The private data of the environment type. More...
 

Public Types

typedef std::unordered_map< string, std::vector< type_base_sptr > > canonical_types_map_type
 A convenience typedef for a map of canonical types. The key is the pretty representation string of a particular type and the value is the vector of canonical types that have the same pretty representation string. More...
 

Public Member Functions

 environment ()
 Default constructor of the environment type. More...
 
virtual ~environment ()
 Destructor for the environment type. More...
 
bool analyze_exported_interfaces_only () const
 Getter for the property that controls if we are to restrict the analysis to the types that are only reachable from the exported interfaces only, or if the set of types should be more broad than that. Typically, we'd restrict the analysis to types reachable from exported interfaces only (stricto sensu, that would really be only the types that are part of the ABI of well designed libraries) for performance reasons. More...
 
void analyze_exported_interfaces_only (bool f)
 Setter for the property that controls if we are to restrict the analysis to the types that are only reachable from the exported interfaces only, or if the set of types should be more broad than that. Typically, we'd restrict the analysis to types reachable from exported interfaces only (stricto sensu, that would really be only the types that are part of the ABI of well designed libraries) for performance reasons. More...
 
bool canonicalization_is_done () const
 Test if the canonicalization of types created out of the current environment is done. More...
 
void canonicalization_is_done (bool)
 Set a flag saying if the canonicalization of types created out of the current environment is done or not. More...
 
bool decl_only_class_equals_definition () const
 Getter of the "decl-only-class-equals-definition" flag. More...
 
void decl_only_class_equals_definition (bool f) const
 Setter of the "decl-only-class-equals-definition" flag. More...
 
bool do_on_the_fly_canonicalization () const
 Getter for the "on-the-fly-canonicalization" flag. More...
 
void do_on_the_fly_canonicalization (bool f)
 Setter for the "on-the-fly-canonicalization" flag. More...
 
type_baseget_canonical_type (const char *name, unsigned index)
 Get a given canonical type which has a given "string representation". More...
 
vector< type_base_sptr > * get_canonical_types (const char *name)
 Get the vector of canonical types which have a given "string representation". More...
 
canonical_types_map_typeget_canonical_types_map ()
 Getter the map of canonical types. More...
 
const canonical_types_map_typeget_canonical_types_map () const
 Getter the map of canonical types. More...
 
const configget_config () const
 Getter of the general configuration object. More...
 
const type_base_sptr & get_variadic_parameter_type () const
 Get a type_decl instance that represents a the type of a variadic function parameter. This node must be the only one representing a variadic parameter type in the system. More...
 
const type_base_sptr & get_void_pointer_type () const
 Getter of the "pointer-to-void" IR node that is shared across the ABI corpus. This node must be the only one representing a void pointer type in the system. More...
 
const type_base_sptr & get_void_type () const
 Get the unique type_decl that represents a "void" type for the current environment. This node must be the only one representing a void type in the system. More...
 
interned_string intern (const string &) const
 Do intern a string. More...
 
bool is_variadic_parameter_type (const type_base *) const
 Test if a type is a variadic parameter type as defined in the current environment. More...
 
bool is_variadic_parameter_type (const type_base_sptr &) const
 Test if a type is a variadic parameter type as defined in the current environment. More...
 
bool is_void_pointer_type (const type_base *) const
 Test if a given type is the same as the void pointer type of the environment. More...
 
bool is_void_pointer_type (const type_base_sptr &) const
 Test if a given type is the same as the void pointer type of the environment. More...
 
bool is_void_type (const type_base *) const
 Test if a given type is a void type as defined in the current environment. More...
 
bool is_void_type (const type_base_sptr &) const
 Test if a given type is a void type as defined in the current environment. More...
 
bool user_set_analyze_exported_interfaces_only () const
 Getter for a property that says if the user actually did set the analyze_exported_interfaces_only() property. If not, it means the default behaviour prevails. More...
 

Static Public Member Functions

static string & get_variadic_parameter_type_name ()
 Getter of the name of the variadic parameter type. More...
 

Public Attributes

std::unique_ptr< privpriv_
 

Friends

class class_decl
 
class class_or_union
 
class function_type
 
void keep_type_alive (type_base_sptr)
 Make sure that the life time of a given (smart pointer to a) type is the same as the life time of the libabigail library. More...
 

Detailed Description

This is an abstraction of the set of resources necessary to manage several aspects of the internal representations of the Abigail library.

An environment can be seen as the boundaries in which all related Abigail artifacts live. So before doing anything using this library, the first thing to create is, well, you know it now, an environment.

Note that the lifetime of environment objects must be longer than the lifetime of any other type in the Abigail system. So a given instance of environment must stay around as long as you are using libabigail. It's only when you are done using the library that you can de-allocate the environment instance.

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

Member Typedef Documentation

◆ canonical_types_map_type

typedef std::unordered_map<string, std::vector<type_base_sptr> > canonical_types_map_type

A convenience typedef for a map of canonical types. The key is the pretty representation string of a particular type and the value is the vector of canonical types that have the same pretty representation string.

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

Constructor & Destructor Documentation

◆ environment()

Default constructor of the environment type.

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

◆ ~environment()

~environment ( )
virtual

Destructor for the environment type.

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

Member Function Documentation

◆ analyze_exported_interfaces_only() [1/2]

bool analyze_exported_interfaces_only ( ) const

Getter for the property that controls if we are to restrict the analysis to the types that are only reachable from the exported interfaces only, or if the set of types should be more broad than that. Typically, we'd restrict the analysis to types reachable from exported interfaces only (stricto sensu, that would really be only the types that are part of the ABI of well designed libraries) for performance reasons.

Parameters
fthe value of the flag.

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

◆ analyze_exported_interfaces_only() [2/2]

void analyze_exported_interfaces_only ( bool  f)

Setter for the property that controls if we are to restrict the analysis to the types that are only reachable from the exported interfaces only, or if the set of types should be more broad than that. Typically, we'd restrict the analysis to types reachable from exported interfaces only (stricto sensu, that would really be only the types that are part of the ABI of well designed libraries) for performance reasons.

Parameters
fthe value of the flag.

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

◆ canonicalization_is_done() [1/2]

bool canonicalization_is_done ( ) const

Test if the canonicalization of types created out of the current environment is done.

Returns
true iff the canonicalization of types created out of the current environment is done.

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

◆ canonicalization_is_done() [2/2]

void canonicalization_is_done ( bool  f)

Set a flag saying if the canonicalization of types created out of the current environment is done or not.

Note that this function must only be called by internal code of the library that creates ABI artifacts (e.g, read an abi corpus from elf or from our own xml format and creates representations of types out of it) and thus needs to canonicalize types to speed-up further type comparison.

Parameters
fthe new value of the flag.

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

◆ decl_only_class_equals_definition() [1/2]

bool decl_only_class_equals_definition ( ) const

Getter of the "decl-only-class-equals-definition" flag.

Usually, a declaration-only class named 'struct foo' compares equal to any class definition named "struct foo'. This is at least true for C++.

In C, though, because there can be multiple definitions of 'struct foo' in the binary, a declaration-only "struct foo" might be considered to *NOT* resolve to any of the struct foo defined. In that case, the declaration-only "struct foo" is considered different from the definitions.

This flag controls the behaviour of the comparison of an unresolved decl-only class against a definition of the same name.

If set to false, the the declaration equals the definition. If set to false, then the decalration is considered different from the declaration.

Returns
the value of the "decl-only-class-equals-definition" flag.

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

◆ decl_only_class_equals_definition() [2/2]

void decl_only_class_equals_definition ( bool  f) const

Setter of the "decl-only-class-equals-definition" flag.

Usually, a declaration-only class named 'struct foo' compares equal to any class definition named "struct foo'. This is at least true for C++.

In C, though, because there can be multiple definitions of 'struct foo' in the binary, a declaration-only "struct foo" might be considered to *NOT* resolve to any of the struct foo defined. In that case, the declaration-only "struct foo" is considered different from the definitions.

This flag controls the behaviour of the comparison of an unresolved decl-only class against a definition of the same name.

If set to false, the the declaration equals the definition. If set to false, then the decalration is considered different from the declaration.

Parameters
thenew value of the "decl-only-class-equals-definition" flag.

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

◆ do_on_the_fly_canonicalization() [1/2]

bool do_on_the_fly_canonicalization ( ) const

Getter for the "on-the-fly-canonicalization" flag.

Returns
true iff on-the-fly-canonicalization is to be performed during comparison.

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

◆ do_on_the_fly_canonicalization() [2/2]

void do_on_the_fly_canonicalization ( bool  f)

Setter for the "on-the-fly-canonicalization" flag.

Parameters
fIf this is true then on-the-fly-canonicalization is to be performed during comparison.

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

◆ get_canonical_type()

type_base * get_canonical_type ( const char *  name,
unsigned  index 
)

Get a given canonical type which has a given "string representation".

Parameters
'name',thetextual representation of the type as returned by type_or_decl_base::get_pretty_representation(/*internal=*‍/true, /*qualified=*‍/true).
index,theindex of the type in the vector of types that all have the same textual representation 'name'. That vector is returned by the function environment::get_canonical_types().
Returns
the canonical type which has the representation name, and which is at index index in the vector of canonical types having that same textual representation.

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

◆ get_canonical_types()

vector< type_base_sptr > * get_canonical_types ( const char *  name)

Get the vector of canonical types which have a given "string representation".

Parameters
'name',thetextual representation of the type as returned by type_or_decl_base::get_pretty_representation(/*internal=*‍/true, /*qualified=*‍/true)

This is useful to for debugging purposes as it's handy to use from inside a debugger like GDB.

Returns
a pointer to the vector of canonical types having the representation name, or nullptr if no type with that representation exists.

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

◆ get_canonical_types_map() [1/2]

environment::canonical_types_map_type & get_canonical_types_map ( )

Getter the map of canonical types.

Returns
the map of canonical types. The key of the map is the hash of the canonical type and its value if the canonical type.

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

◆ get_canonical_types_map() [2/2]

const environment::canonical_types_map_type & get_canonical_types_map ( ) const

Getter the map of canonical types.

Returns
the map of canonical types. The key of the map is the hash of the canonical type and its value if the canonical type.

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

◆ get_config()

const config & get_config ( ) const

Getter of the general configuration object.

Returns
the configuration object.

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

◆ get_variadic_parameter_type()

const type_base_sptr & get_variadic_parameter_type ( ) const

Get a type_decl instance that represents a the type of a variadic function parameter. This node must be the only one representing a variadic parameter type in the system.

Note that upon first use of this IR node (by the relevant front-end, for instance) it must be added to a scope using e.g, the add_decl_to_scope() function.

Returns
the Get a type_decl instance that represents a the type of a variadic function parameter.

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

◆ get_variadic_parameter_type_name()

string & get_variadic_parameter_type_name ( )
static

Getter of the name of the variadic parameter type.

Returns
the name of the variadic parameter type.

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

◆ get_void_pointer_type()

const type_base_sptr & get_void_pointer_type ( ) const

Getter of the "pointer-to-void" IR node that is shared across the ABI corpus. This node must be the only one representing a void pointer type in the system.

Note that upon first use of this IR node (by the relevant front-end, for instance) it must be added to a scope using e.g, the add_decl_to_scope() function.

Returns
the "pointer-to-void" IR node.

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

◆ get_void_type()

const type_base_sptr & get_void_type ( ) const

Get the unique type_decl that represents a "void" type for the current environment. This node must be the only one representing a void type in the system.

Note that upon first use of this IR node (by the relevant front-end, for instance) it must be added to a scope using e.g, the add_decl_to_scope() function.

Returns
the type_decl that represents a "void" type.

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

◆ intern()

interned_string intern ( const string &  s) const

Do intern a string.

If a value of this string already exists in the interned string pool of the current environment, then this function returns a new interned_string pointing to that already existing string. Otherwise, a new string is created, stored in the interned string pool and a new interned_string instance is created to point to that new intrerned string, and it's return.

Parameters
sthe value of the string to intern.
Returns
the interned string.

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

◆ is_variadic_parameter_type() [1/2]

bool is_variadic_parameter_type ( const type_base t) const

Test if a type is a variadic parameter type as defined in the current environment.

Parameters
tthe type to consider.
Returns
true iff t is a variadic parameter type as defined in the current environment.

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

◆ is_variadic_parameter_type() [2/2]

bool is_variadic_parameter_type ( const type_base_sptr &  t) const

Test if a type is a variadic parameter type as defined in the current environment.

Parameters
tthe type to consider.
Returns
true iff t is a variadic parameter type as defined in the current environment.

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

◆ is_void_pointer_type() [1/2]

bool is_void_pointer_type ( const type_base t) const

Test if a given type is the same as the void pointer type of the environment.

Parameters
tthe IR type to test.
Returns
true iff t is the void pointer returned by environment::get_void_pointer_type().

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

◆ is_void_pointer_type() [2/2]

bool is_void_pointer_type ( const type_base_sptr &  t) const

Test if a given type is the same as the void pointer type of the environment.

Parameters
tthe IR type to test.
Returns
true iff t is the void pointer returned by environment::get_void_pointer_type().

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

◆ is_void_type() [1/2]

bool is_void_type ( const type_base t) const

Test if a given type is a void type as defined in the current environment.

Parameters
tthe type to consider.
Returns
true iff t is a void type as defined in the current environment.

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

◆ is_void_type() [2/2]

bool is_void_type ( const type_base_sptr &  t) const

Test if a given type is a void type as defined in the current environment.

Parameters
tthe type to consider.
Returns
true iff t is a void type as defined in the current environment.

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

◆ user_set_analyze_exported_interfaces_only()

bool user_set_analyze_exported_interfaces_only ( ) const

Getter for a property that says if the user actually did set the analyze_exported_interfaces_only() property. If not, it means the default behaviour prevails.

Returns
tru iff the user did set the analyze_exported_interfaces_only() property.

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

Friends And Related Function Documentation

◆ keep_type_alive

void keep_type_alive ( type_base_sptr  )
friend

Make sure that the life time of a given (smart pointer to a) type is the same as the life time of the libabigail library.

Parameters
tthe type to consider.

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


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