14 #ifndef __ABG_CORPUS_PRIV_H__
15 #define __ABG_CORPUS_PRIV_H__
17 #include "abg-internal.h"
47 typedef unordered_map<string, std::unordered_set<function_decl*> >
53 std::unordered_set<function_decl*>,
62 typedef unordered_map<interned_string,
68 typedef unordered_map<interned_string,
69 std::unordered_set<var_decl_sptr>,
91 istr_fn_ptr_set_map_type id_fns_map_;
92 istr_var_ptr_set_map_type id_vars_map_;
94 regex_t_sptrs_type compiled_fns_suppress_regexp_;
96 regex_t_sptrs_type compiled_vars_suppress_regexp_;
98 regex_t_sptrs_type compiled_fns_keep_regexps_;
100 regex_t_sptrs_type compiled_vars_keep_regexps_;
116 fns_suppress_regexps_(fns_suppress_regexps),
117 vars_suppress_regexps_(vars_suppress_regexps),
118 fns_keep_regexps_(fns_keep_regexps),
119 vars_keep_regexps_(vars_keep_regexps),
120 sym_id_of_fns_to_keep_(sym_id_of_fns_to_keep),
121 sym_id_of_vars_to_keep_(sym_id_of_vars_to_keep)
131 if (compiled_fns_suppress_regexp_.empty())
133 for (vector<string>::const_iterator i =
134 fns_suppress_regexps_.begin();
135 i != fns_suppress_regexps_.end();
140 compiled_fns_suppress_regexp_.push_back(r);
143 return compiled_fns_suppress_regexp_;
153 if (compiled_fns_keep_regexps_.empty())
155 for (vector<string>::const_iterator i =
156 fns_keep_regexps_.begin();
157 i != fns_keep_regexps_.end();
162 compiled_fns_keep_regexps_.push_back(r);
165 return compiled_fns_keep_regexps_;
175 if (compiled_vars_suppress_regexp_.empty())
177 for (vector<string>::const_iterator i =
178 vars_suppress_regexps_.begin();
179 i != vars_suppress_regexps_.end();
184 compiled_vars_suppress_regexp_.push_back(r);
187 return compiled_vars_suppress_regexp_;
197 if (compiled_vars_keep_regexps_.empty())
199 for (vector<string>::const_iterator i =
200 vars_keep_regexps_.begin();
201 i != vars_keep_regexps_.end();
206 compiled_vars_keep_regexps_.push_back(r);
209 return compiled_vars_keep_regexps_;
225 const istr_fn_ptr_set_map_type&
227 {
return id_fns_map_;}
237 istr_fn_ptr_set_map_type&
239 {
return id_fns_map_;}
249 istr_var_ptr_set_map_type&
251 {
return id_vars_map_;}
261 const istr_var_ptr_set_map_type&
263 {
return id_vars_map_;}
292 std::unordered_set<function_decl*>*
296 auto i = m.find(fn_id);
311 std::unordered_set<function_decl*>*
314 interned_string fn_id = fn->
get_id();
328 const std::unordered_set<function_decl*>& fns)
333 if (fns.find(fn) != fns.end())
336 const string fn_id = fn->
get_id();
337 for (
const auto f : fns)
338 if (f->get_id() == fn_id
364 const std::unordered_set<function_decl*>& fns,
365 string& pretty_representation)
371 const string fn_id = fn->
get_id();
372 for (
const auto f : fns)
373 if (f->get_id() == fn_id
374 && f->get_pretty_representation() == repr)
376 pretty_representation = repr;
408 interned_string fn_id = fn->
get_id();
411 fns = &(
id_fns_map()[fn_id] = std::unordered_set<function_decl*>());
421 sym_id = sym->get_id_string();
426 fns = &(
id_fns_map()[fn_id] = std::unordered_set<function_decl*>());
429 sym = sym->get_next_alias();
431 while (sym && !sym->is_main_symbol());
442 std::unordered_set<var_decl_sptr>*
446 auto i = m.find(var_id);
460 const std::unordered_set<var_decl_sptr>*
477 const std::unordered_set<var_decl_sptr>& vars)
482 if (vars.find(var) != vars.end())
485 const string var_id = var->get_id();
486 for (
const auto& v: vars)
487 if (v->get_id() == var_id
488 && v->get_qualified_name() == var->get_qualified_name())
508 interned_string var_id = var->get_id();
509 const std::unordered_set<var_decl_sptr>* vars =
527 interned_string var_id = var->get_id();
530 vars = &(
id_vars_map()[var_id] = std::unordered_set<var_decl_sptr>());
540 sym_id = sym->get_id_string();
541 if (sym_id == var_id)
545 vars = &(
id_vars_map()[var_id] = std::unordered_set<var_decl_sptr>());
548 sym = sym->get_next_alias();
550 while (sym && !sym->is_main_symbol());
574 vars_.push_back(var);
586 {
return sym_id_of_fns_to_keep_;}
595 {
return sym_id_of_vars_to_keep_;}
617 for (vector<string>::const_iterator i =
622 string sym_name, sym_version;
626 if (sym_name == sym->get_name()
627 && sym_version == sym->get_version().str())
657 for (regex_t_sptrs_type::const_iterator i =
690 for (regex_t_sptrs_type::const_iterator i =
724 for (vector<string>::const_iterator i =
729 string sym_name, sym_version;
733 if (sym_name == sym->get_name()
734 && sym_version == sym->get_version().str())
761 string frep = var->get_qualified_name();
764 for (regex_t_sptrs_type::const_iterator i =
790 string frep = var->get_qualified_name();
798 for (regex_t_sptrs_type::const_iterator i =
817 mutable unordered_map<string, type_base_sptr> canonical_types_;
818 string format_major_version_number_;
819 string format_minor_version_number_;
824 vector<string> regex_patterns_fns_to_suppress;
825 vector<string> regex_patterns_vars_to_suppress;
826 vector<string> regex_patterns_fns_to_keep;
827 vector<string> regex_patterns_vars_to_keep;
828 vector<string> sym_id_fns_to_keep;
829 vector<string> sym_id_vars_to_keep;
831 vector<string> needed;
833 string architecture_name;
836 vector<const function_decl*> fns;
837 vector<var_decl_sptr> vars;
842 symtab_reader::symtab_sptr symtab_;
856 mutable vector<type_base_wptr> types_not_reachable_from_pub_ifaces_;
857 unordered_set<interned_string, hash_interned_string> *pub_type_pretty_reprs_;
875 priv(
const string & p,
879 origin_(ARTIFICIAL_ORIGIN),
881 pub_type_pretty_reprs_(),
921 unordered_set<interned_string, hash_interned_string>*
924 std::unordered_set<function_decl*>*
934 maybe_update_scope_lookup_map(
const decl_base_sptr& member_scope);
977 #endif // __ABG_CORPUS_PRIV_H__
const istr_fn_ptr_set_map_type & id_fns_map() const
Getter for a map of the IDs of the functions that are present in the set of exported functions...
istr_var_ptr_set_map_type & id_vars_map()
Getter for a map of the IDs of the variables that are present in the set of exported variables...
type_maps & get_types()
Get the maps that associate a name to a certain kind of type.
unordered_set< interned_string, hash_interned_string > * get_public_types_pretty_representations()
Getter of the set of pretty representation of types that are reachable from public interfaces (global...
unordered_map< string, translation_unit_sptr > string_tu_map_type
Convenience typedef for a map that associates a string to a translation unit.
unordered_map< interned_string, std::unordered_set< function_decl * >, hash_interned_string > istr_fn_ptr_set_map_type
Convenience typedef for a hash map which key is an interned_string and which data is a set of abigail...
Utilities to ease the wrapping of C types into std::shared_ptr.
bool var_is_in_id_vars_map(const var_decl_sptr &var)
Test if a given variable is present in a set of variables.
interned_string get_id() const
Return an ID that tries to uniquely identify the function inside a program or a library.
shared_ptr< function_type > function_type_sptr
Convenience typedef for a shared pointer on a function_type.
regex_t_sptrs_type & compiled_regex_vars_suppress()
Getter of the compiled regular expressions that designate the variables to suppress from the set of e...
const strings_type & sym_id_of_fns_to_keep() const
Getter for the set of ids of functions to keep in the set of exported functions.
regex_t_sptr compile(const std::string &str)
Compile a regex from a string.
const elf_symbols & get_unreferenced_function_symbols() const
Return a list of symbols that are not referenced by any function of corpus::get_functions().
This is the abstraction of a set of translation units (themselves seen as bundles of unitary abi arte...
A declaration that introduces a scope.
bool keep_wrt_id_of_fns_to_keep(const function_decl *fn)
Look at the set of functions to keep and tell if if a given function is to be kept, according to that set.
const elf_symbol_sptr & get_symbol() const
Gets the the underlying ELF symbol for the current variable, that was set using function_decl::set_sy...
unordered_map< string, vector< function_decl * > > str_fn_ptrs_map_type
Convenience typedef for a hash map which key is a string and which data is a vector of abigail::ir::f...
std::set< translation_unit_sptr, shared_translation_unit_comp > translation_units
Convenience typedef for an ordered set of translation_unit_sptr.
const std::unordered_set< var_decl_sptr > * var_id_is_in_id_vars_map(const interned_string &var_id) const
Test if a given (ID of a) variable is present in the variable map. In other words, it tests if a given variable is present in the set of exported variables.
A functor to hash instances of interned_string.
const elf_symbols & get_sorted_var_symbols() const
Getter for the sorted vector of variable symbols for this corpus.
shared_ptr< var_decl > var_decl_sptr
Convenience typedef for a shared pointer on a var_decl.
const string_elf_symbols_map_type & get_undefined_var_symbol_map() const
Return a map from name to undefined variable symbol for this corpus.
shared_ptr< typedef_decl > typedef_decl_sptr
Convenience typedef for a shared pointer on a typedef_decl.
This contains the declarations for the symtab reader.
std::unordered_set< var_decl_sptr > * var_id_is_in_id_vars_map(const interned_string &var_id)
Test if a given (ID of a) variable is present in the variable map. In other words, it tests if a given variable is present in the set of exported variables.
virtual string get_pretty_representation(bool internal=false, bool qualified_name=true) const
Get the pretty representation of the current instance of function_decl.
Declaration of types pertaining to the interned string pool used throughout Libabigail, for performance reasons.
void add_fn_to_id_fns_map(function_decl *fn)
Add a given function to the map of functions that are present in the set of exported functions...
static bool var_is_in_vars(const var_decl_sptr &var, const std::unordered_set< var_decl_sptr > &vars)
Test if a given variable is present in a set of variables.
Abstracts a variable declaration.
std::vector< elf_symbol_sptr > elf_symbols
Convenience typedef for a vector of elf_symbol.
interned_string get_id() const
Return an ID that tries to uniquely identify the variable inside a program or a library.
vector< var_decl_sptr > variables
Convenience typedef for std::vector
bool keep_wrt_regex_of_fns_to_keep(const function_decl *fn)
Look at the regular expressions of the functions to keep and tell if if a given function is to be kep...
void maybe_update_types_lookup_map(const type_decl_sptr &basic_type)
Update the map that associates the fully qualified name of a basic type with the type itself...
regex_t_sptrs_type & compiled_regex_vars_keep()
Getter for the compiled regular expressions that designate the variables to keep in the set of export...
Toplevel namespace for libabigail.
unordered_map< string, var_decl_sptr > str_var_ptr_map_type
Convenience typedef for a hash map which key is a string and which data is an abigail::ir::var_decl*...
shared_ptr< scope_decl > scope_decl_sptr
Convenience typedef for a shared pointer on a scope_decl.
regex_t_sptrs_type & compiled_regex_fns_suppress()
Getter for the compiled regular expressions that designate the functions to suppress from the set of ...
std::unordered_map< string, elf_symbols > string_elf_symbols_map_type
Convenience typedef for a map which key is a string and which value is a vector of elf_symbol...
origin
This abstracts where the corpus comes from. That is, either it has been read from the native xml form...
~priv()
Destructor of the corpus::priv type.
Abstraction for a function declaration.
Types of the main internal representation of libabigail.
static bool get_name_and_version_from_id(const string &id, string &name, string &ver)
Given the ID of a symbol, get the name and the version of said symbol.
bool keep_wrt_id_of_vars_to_keep(const var_decl_sptr &var)
Look at the regular expressions of the variables to keep and tell if if a given variable is to be kep...
vector< string > strings_type
A convenience typedef for std::vector.
const elf_symbols & get_sorted_undefined_fun_symbols() const
Getter for a sorted vector of the function symbols undefined in this corpus.
The type of the private data of corpus::exported_decls_builder type.
shared_ptr< type_decl > type_decl_sptr
Convenience typedef for a shared pointer on a type_decl.
std::unordered_set< function_decl * > * fn_id_is_in_id_fns_map(const interned_string &fn_id)
Test if a given function ID is in the id-functions map.
This is a type that aggregates maps of all the kinds of types that are supported by libabigail...
This is an abstraction of the set of resources necessary to manage several aspects of the internal re...
void add_var_to_exported(const var_decl_sptr &var)
Add a variable to the set of exported variables.
static bool fn_is_in_fns_by_repr(function_decl *fn, const std::unordered_set< function_decl * > &fns, string &pretty_representation)
Test if a given function is present in a set of functions, by looking at the pretty representation of...
std::unordered_set< function_decl * > * fn_id_is_in_id_fns_map(const function_decl *fn)
Test if a a function if the same ID as a given function is present in the id-functions map...
shared_ptr< reference_type_def > reference_type_def_sptr
Convenience typedef for a shared pointer on a reference_type_def.
unordered_map< interned_string, std::unordered_set< var_decl_sptr >, hash_interned_string > istr_var_ptr_set_map_type
Convenience typedef for a hash map which key is an interned_string and which data is a set of abigail...
unordered_map< interned_string, var_decl_sptr, hash_interned_string > istr_var_ptr_map_type
Convenience typedef for a hash map which key is an interned_string and which data is an abigail::ir::...
shared_ptr< elf_symbol > elf_symbol_sptr
A convenience typedef for a shared pointer to elf_symbol.
const elf_symbols & get_sorted_fun_symbols() const
Return a sorted vector of function symbols for this corpus.
std::shared_ptr< regex_t > regex_t_sptr
A convenience typedef for a shared pointer of regex_t.
#define ABG_ASSERT(cond)
This is a wrapper around the 'assert' glibc call. It allows for its argument to have side effects...
const string_elf_symbols_map_type & get_fun_symbol_map() const
Return a map from name to function symbol for this corpus.
const string_elf_symbols_map_type & get_undefined_fun_symbol_map() const
Return a map from name to undefined function symbol for this corpus.
Abstracts the building of the set of exported variables and functions.
unordered_map< string, std::unordered_set< function_decl * > > str_fn_ptr_set_map_type
Convenience typedef for a hash map which key is a string and which data is a set of abigail::ir::func...
vector< regex_t_sptr > regex_t_sptrs_type
A convenience typedef for std::vector.
const elf_symbols & get_unreferenced_variable_symbols() const
Return a list of symbols that are not referenced by any variable of corpus::get_variables().
const string_elf_symbols_map_type & get_var_symbol_map() const
Return a map from name to variable symbol for this corpus.
interned_string get_id(const function_decl &fn)
Returns an ID for a given function.
const strings_type & sym_id_of_vars_to_keep() const
Getter for the set of ids of variables to keep in the set of exported variables.
shared_ptr< enum_type_decl > enum_type_decl_sptr
Convenience typedef for shared pointer to a enum_type_decl.
shared_ptr< class_decl > class_decl_sptr
Convenience typedef for a shared pointer on a class_decl.
virtual void get_qualified_name(interned_string &qualified_name, bool internal=false) const
Compute the qualified name of the decl.
const istr_var_ptr_set_map_type & id_vars_map() const
Getter for a map of the IDs of the variables that are present in the set of exported variables...
bool match(const regex_t_sptr &r, const std::string &str)
See if a string matches a regex.
bool keep_wrt_regex_of_vars_to_keep(const var_decl_sptr &var)
Look at the regular expressions of the variables to keep and tell if if a given variable is to be kep...
bool fn_is_in_id_fns_map(function_decl *fn)
Test if a function is in the id-functions map.
The abstraction of an interned string.
std::unordered_set< function_decl * > * lookup_functions(const interned_string &id)
Lookup the function which has a given function ID.
std::unordered_set< var_decl_sptr > variables_set
Convenience typedef for std::unordered_set.
istr_fn_ptr_set_map_type & id_fns_map()
Getter for a map of the IDs of the functions that are present in the set of exported functions...
interned_string get_id(const var_decl &var)
Returns an ID for a given variable.
void add_var_to_id_vars_map(const var_decl_sptr &var)
Add a given variable to the map of variables that are present in the set of exported variables...
The private data of the corpus type.
bool keep_wrt_regex_of_fns_to_suppress(const function_decl *fn)
Look at the set of functions to suppress from the exported functions set and tell if if a given funct...
Abstraction of a group of corpora.
void add_fn_to_exported(function_decl *fn)
Add a function to the set of exported functions.
Wrappers around regex types and functions.
const elf_symbols & get_sorted_undefined_var_symbols() const
Getter for a sorted vector of the variable symbols undefined in this corpus.
bool keep_wrt_regex_of_vars_to_suppress(const var_decl_sptr var)
Look at the set of variables to suppress from the exported variables set and tell if if a given varia...
shared_ptr< array_type_def > array_type_def_sptr
Convenience typedef for a shared pointer on a array_type_def.
shared_ptr< pointer_type_def > pointer_type_def_sptr
Convenience typedef for a shared pointer on a pointer_type_def.
static bool fn_is_in_fns(function_decl *fn, const std::unordered_set< function_decl * > &fns)
Test if a given function is present in a set of functions.
regex_t_sptrs_type & compiled_regex_fns_keep()
Getter for the compiled regular expressions that designates the functions to keep in the set of expor...
std::unordered_set< const function_decl * > functions_set
Convenience typedef for std::unordered_set
Abstraction of a function type.
vector< const function_decl * > functions
Convenience typedef for std::vector
shared_ptr< exported_decls_builder > exported_decls_builder_sptr
Convenience typedef for shared_ptr.