libabigail
|
This is the abstraction of the set of relevant artefacts (types, variable declarations, functions, templates, etc) bundled together into a translation unit. More...
#include <abg-ir.h>
Classes | |
struct | priv |
Private type to hold private members of translation_unit. More... | |
Public Types | |
typedef shared_ptr< scope_decl > | global_scope_sptr |
Convenience typedef for a shared pointer on a global_scope. More... | |
enum | language { LANG_UNKNOWN , LANG_Cobol74 , LANG_Cobol85 , LANG_C89 , LANG_C99 , LANG_C11 , LANG_C17 , LANG_C23 , LANG_C , LANG_C_plus_plus_03 , LANG_C_plus_plus_11 , LANG_C_plus_plus_14 , LANG_C_plus_plus_17 , LANG_C_plus_plus_20 , LANG_C_plus_plus_23 , LANG_C_plus_plus , LANG_ObjC , LANG_ObjC_plus_plus , LANG_OCaml , LANG_D , LANG_Go , LANG_Rust , LANG_Zig , LANG_Metal , LANG_Fortran77 , LANG_Fortran90 , LANG_Fortran95 , LANG_Fortran18 , LANG_Fortran23 , LANG_Ada83 , LANG_Ada95 , LANG_Ada2005 , LANG_Ada2012 , LANG_Pascal83 , LANG_Modula2 , LANG_Java , LANG_Kotlin , LANG_C_sharp , LANG_Python , LANG_Ruby , LANG_PLI , LANG_UPC , LANG_Mips_Assembler , LANG_Assembly , LANG_Crystal , LANG_HIP , LANG_Mojo , LANG_GLSL , LANG_GLSL_ES , LANG_HLSL , LANG_OpenCL_CPP , LANG_CPP_for_OpenCL , LANG_SYCL , LANG_Odin , LANG_P4 , LANG_Move , LANG_Hylo } |
The language of the translation unit. More... | |
Public Member Functions | |
translation_unit (const ir::environment &env, const std::string &path, char address_size=0) | |
Constructor of translation_unit. More... | |
void | bind_function_type_life_time (function_type_sptr) const |
Ensure that the life time of a function type is bound to the life time of the current translation unit. More... | |
const std::string & | get_absolute_path () const |
Get the concatenation of the build directory and the relative path of the translation unit. More... | |
char | get_address_size () const |
Getter of the address size in this translation unit. More... | |
const std::string & | get_compilation_dir_path () const |
Get the path of the directory that was 'current' when the translation unit was compiled. More... | |
corpus * | get_corpus () |
Get the corpus this translation unit is a member of. More... | |
const corpus * | get_corpus () const |
Get the corpus this translation unit is a member of. More... | |
const environment & | get_environment () const |
Getter of the environment of the current translation_unit. More... | |
scope_decl_sptr & | get_global_scope () |
Getter of the global scope of the translation unit. More... | |
const scope_decl_sptr & | get_global_scope () const |
Getter of the the global scope of the translation unit. More... | |
language | get_language () const |
Getter of the language of the source code of the translation unit. More... | |
const vector< function_type_sptr > & | get_live_fn_types () const |
Get the vector of function types that are used in the current translation unit. More... | |
location_manager & | get_loc_mgr () |
Getter of the location manager for the current translation unit. More... | |
const location_manager & | get_loc_mgr () const |
const Getter of the location manager. More... | |
const std::string & | get_path () const |
Get the path of the current translation unit. More... | |
type_maps & | get_types () |
Getter of the types of the current translation_unit. More... | |
const type_maps & | get_types () const |
Getter of the types of the current translation_unit. More... | |
bool | is_constructed () const |
Getter of the 'is_constructed" flag. It says if the translation unit is fully constructed or not. More... | |
bool | is_empty () const |
Tests whether if the current translation unit contains ABI artifacts or not. More... | |
bool | operator!= (const translation_unit &) const |
Inequality operator. More... | |
bool | operator== (const translation_unit &) const |
Compare the current translation unit against another one. More... | |
void | set_address_size (char) |
Setter of the address size in this translation unit. More... | |
void | set_compilation_dir_path (const std::string &) |
Set the path of the directory that was 'current' when the translation unit was compiled. More... | |
void | set_corpus (corpus *) |
Set the corpus this translation unit is a member of. More... | |
void | set_is_constructed (bool) |
Setter of the 'is_constructed" flag. It says if the translation unit is fully constructed or not. More... | |
void | set_language (language l) |
Setter of the language of the source code of the translation unit. More... | |
void | set_path (const string &) |
Set the path associated to the current instance of translation_unit. More... | |
virtual bool | traverse (ir_node_visitor &v) |
This implements the ir_traversable_base::traverse virtual function. More... | |
![]() | |
virtual | ~traversable_base () |
Destructor of the traversable_base type. More... | |
Friends | |
function_type_sptr | lookup_function_type_in_translation_unit (const function_type &t, const translation_unit &tu) |
function_type_sptr | synthesize_function_type_from_translation_unit (const function_type &fn_type, translation_unit &tu) |
In a translation unit, lookup the sub-types that make up a given function type and if the sub-types are all found, synthesize and return a function_type with them. More... | |
type_base_sptr | synthesize_type_from_translation_unit (const type_base_sptr &type, translation_unit &tu) |
In a translation unit, lookup a given type or synthesize it if it's a qualified type. More... | |
Additional Inherited Members | |
![]() | |
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... | |
This is the abstraction of the set of relevant artefacts (types, variable declarations, functions, templates, etc) bundled together into a translation unit.
typedef shared_ptr<scope_decl> global_scope_sptr |
Convenience typedef for a shared pointer on a global_scope.
translation_unit | ( | const ir::environment & | env, |
const std::string & | path, | ||
char | address_size = 0 |
||
) |
Constructor of translation_unit.
env | the environment of this translation unit. Please note that the life time of the environment must be greater than the life time of the translation unit because the translation uses resources that are allocated in the environment. |
path | the location of the translation unit. |
address_size | the size of addresses in the translation unit, in bits. |
|
virtual |
void bind_function_type_life_time | ( | function_type_sptr | ftype | ) | const |
Ensure that the life time of a function type is bound to the life time of the current translation unit.
ftype | the function time which life time to bind to the life time of the current instance of translation_unit. That is, it's onlyh when the translation unit is destroyed that the function type can be destroyed to. |
const std::string & get_absolute_path | ( | ) | const |
char get_address_size | ( | ) | const |
const std::string & get_compilation_dir_path | ( | ) | const |
Get the path of the directory that was 'current' when the translation unit was compiled.
Note that the path returned by translation_unit::get_path is relative to the path returned by this function.
corpus * get_corpus | ( | ) |
const corpus * get_corpus | ( | ) | const |
const environment & get_environment | ( | ) | const |
Getter of the environment of the current translation_unit.
scope_decl_sptr & get_global_scope | ( | ) |
const scope_decl_sptr & get_global_scope | ( | ) | const |
translation_unit::language get_language | ( | ) | const |
const vector< function_type_sptr > & get_live_fn_types | ( | ) | const |
location_manager & get_loc_mgr | ( | ) |
const location_manager & get_loc_mgr | ( | ) | const |
const std::string & get_path | ( | ) | const |
Get the path of the current translation unit.
This path is relative to the build directory of the translation unit as returned by translation_unit::get_compilation_dir_path.
type_maps & get_types | ( | ) |
Getter of the types of the current translation_unit.
const type_maps & get_types | ( | ) | const |
Getter of the types of the current translation_unit.
bool is_constructed | ( | ) | const |
Getter of the 'is_constructed" flag. It says if the translation unit is fully constructed or not.
This flag is important for cases when comparison might depend on if the translation unit is fully built or not. For instance, when reading types from DWARF, the virtual methods of a class are not necessarily fully constructed until we have reached the end of the translation unit. In that case, before we've reached the end of the translation unit, we might not take virtual functions into account when comparing classes.
bool is_empty | ( | ) | const |
bool operator!= | ( | const translation_unit & | o | ) | const |
Inequality operator.
o | the instance of translation_unit to compare the current instance against. |
o
. bool operator== | ( | const translation_unit & | other | ) | const |
void set_address_size | ( | char | a | ) |
void set_compilation_dir_path | ( | const std::string & | d | ) |
Set the path of the directory that was 'current' when the translation unit was compiled.
Note that the path returned by translation_unit::get_path is relative to the path returned by this function.
the | compilation directory for the current translation unit. |
void set_corpus | ( | corpus * | c | ) |
void set_is_constructed | ( | bool | f | ) |
Setter of the 'is_constructed" flag. It says if the translation unit is fully constructed or not.
This flag is important for cases when comparison might depend on if the translation unit is fully built or not. For instance, when reading types from DWARF, the virtual methods of a class are not necessarily fully constructed until we have reached the end of the translation unit. In that case, before we've reached the end of the translation unit, we might not take virtual functions into account when comparing classes.
f | true if the translation unit is constructed. |
void set_language | ( | language | l | ) |
void set_path | ( | const string & | a_path | ) |
Set the path associated to the current instance of translation_unit.
This path is relative to the build directory of the translation unit as returned by translation_unit::get_compilation_dir_path.
a_path | the new relative path to set. |
|
virtual |
This implements the ir_traversable_base::traverse virtual function.
v | the visitor used on the member nodes of the translation unit during the traversal. |
|
friend |
In a translation unit, lookup the sub-types that make up a given function type and if the sub-types are all found, synthesize and return a function_type with them.
This function is like lookup_function_type_in_translation_unit() execept that it constructs the function type from the sub-types found in the translation, rather than just looking for the function types held by the translation unit. This can be useful if the translation unit doesnt hold the function type we are looking for (i.e, lookup_function_type_in_translation_unit() returned NULL) but we still want to see if the sub-types of the function types are present in the translation unit.
fn_type | the function type to consider. |
tu | the translation unit to look into. |
|
friend |
In a translation unit, lookup a given type or synthesize it if it's a qualified type.
So this function first looks the type up in the translation unit. If it's found, then OK, it's returned. Otherwise, if it's a qualified, reference or pointer or function type (a composite type), lookup the underlying type, synthesize the type we want from it and return it.
If the underlying types is not not found, then give up and return nil.