libabigail
abg-corpus-priv.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2// -*- Mode: C++ -*-
3//
4// Copyright (C) 2016-2023 Red Hat, Inc.
5
6/// @file
7///
8/// The private data and functions of the @ref abigail::ir::corpus type.
9///
10/// Interfaces declared/defined in this file are to be used by parts
11/// of libabigail but *NOT* by clients of libabigail.
12///
13
14#ifndef __ABG_CORPUS_PRIV_H__
15#define __ABG_CORPUS_PRIV_H__
16
17#include "abg-internal.h"
18#include "abg-ir.h"
19#include "abg-regex.h"
20#include "abg-sptr-utils.h"
21#include "abg-symtab-reader.h"
22#include "abg-interned-str.h"
23
24namespace abigail
25{
26
27namespace sptr_utils
28{
29}// end namespace sptr_utils
30
31namespace ir
32{
33
35
36/// A convenience typedef for std::vector<regex_t_sptr>.
37typedef vector<regex_t_sptr> regex_t_sptrs_type;
38
39// <corpus::exported_decls_builder>
40
41/// Convenience typedef for a hash map which key is a string and which
42/// data is a vector of abigail::ir::function_decl*
43typedef unordered_map<string, vector<function_decl*> > str_fn_ptrs_map_type;
44
45/// Convenience typedef for a hash map which key is a string and which
46/// data is a set of abigail::ir::function_decl*
47typedef unordered_map<string, std::unordered_set<function_decl*> >
49
50/// Convenience typedef for a hash map which key is an interned_string
51/// and which data is a set of abigail::ir::function_decl*
52typedef unordered_map<interned_string,
53 std::unordered_set<function_decl*>,
55
56/// Convenience typedef for a hash map which key is a string and
57/// which data is an abigail::ir::var_decl*.
58typedef unordered_map<string, var_decl*> str_var_ptr_map_type;
59
60/// Convenience typedef for a hash map which key is an interned_string
61/// and which data is an abigail::ir::var_decl*.
62typedef unordered_map<interned_string,
63 var_decl*,
65
66/// The type of the private data of @ref
67/// corpus::exported_decls_builder type.
69{
71 friend class corpus;
72
73 priv();
74
75 functions& fns_;
76 variables& vars_;
77 // A map that associates a function ID (function symbol and its
78 // version) to to a vector of functions with that ID. Normally, one
79 // would think that in the corpus, there must only one function for
80 // a given ID. Actually, in c++, there can be two function template
81 // instantiations that produce the same function ID because the
82 // template parameters of the second instantiation are just typedefs
83 // of the first instantiation, for instance. So there can be cases
84 // where one ID appertains to more than one function.
85 istr_fn_ptr_set_map_type id_fns_map_;
86 istr_var_ptr_map_type id_var_map_;
87 strings_type& fns_suppress_regexps_;
88 regex_t_sptrs_type compiled_fns_suppress_regexp_;
89 strings_type& vars_suppress_regexps_;
90 regex_t_sptrs_type compiled_vars_suppress_regexp_;
91 strings_type& fns_keep_regexps_;
92 regex_t_sptrs_type compiled_fns_keep_regexps_;
93 strings_type& vars_keep_regexps_;
94 regex_t_sptrs_type compiled_vars_keep_regexps_;
95 strings_type& sym_id_of_fns_to_keep_;
96 strings_type& sym_id_of_vars_to_keep_;
97
98public:
99
100 priv(functions& fns,
101 variables& vars,
102 strings_type& fns_suppress_regexps,
103 strings_type& vars_suppress_regexps,
104 strings_type& fns_keep_regexps,
105 strings_type& vars_keep_regexps,
108 : fns_(fns),
109 vars_(vars),
110 fns_suppress_regexps_(fns_suppress_regexps),
111 vars_suppress_regexps_(vars_suppress_regexps),
112 fns_keep_regexps_(fns_keep_regexps),
113 vars_keep_regexps_(vars_keep_regexps),
114 sym_id_of_fns_to_keep_(sym_id_of_fns_to_keep),
115 sym_id_of_vars_to_keep_(sym_id_of_vars_to_keep)
116 {}
117
118 /// Getter for the compiled regular expressions that designate the
119 /// functions to suppress from the set of exported functions.
120 ///
121 /// @return a vector of the compiled regular expressions.
124 {
125 if (compiled_fns_suppress_regexp_.empty())
126 {
127 for (vector<string>::const_iterator i =
128 fns_suppress_regexps_.begin();
129 i != fns_suppress_regexps_.end();
130 ++i)
131 {
133 if (r)
134 compiled_fns_suppress_regexp_.push_back(r);
135 }
136 }
137 return compiled_fns_suppress_regexp_;
138 }
139
140 /// Getter for the compiled regular expressions that designates the
141 /// functions to keep in the set of exported functions.
142 ///
143 /// @return a vector of compiled regular expressions.
146 {
147 if (compiled_fns_keep_regexps_.empty())
148 {
149 for (vector<string>::const_iterator i =
150 fns_keep_regexps_.begin();
151 i != fns_keep_regexps_.end();
152 ++i)
153 {
155 if (r)
156 compiled_fns_keep_regexps_.push_back(r);
157 }
158 }
159 return compiled_fns_keep_regexps_;
160 }
161
162 /// Getter of the compiled regular expressions that designate the
163 /// variables to suppress from the set of exported variables.
164 ///
165 /// @return a vector of compiled regular expressions.
168 {
169 if (compiled_vars_suppress_regexp_.empty())
170 {
171 for (vector<string>::const_iterator i =
172 vars_suppress_regexps_.begin();
173 i != vars_suppress_regexps_.end();
174 ++i)
175 {
177 if (r)
178 compiled_vars_suppress_regexp_.push_back(r);
179 }
180 }
181 return compiled_vars_suppress_regexp_;
182 }
183
184 /// Getter for the compiled regular expressions that designate the
185 /// variables to keep in the set of exported variables.
186 ///
187 /// @return a vector of compiled regular expressions.
190 {
191 if (compiled_vars_keep_regexps_.empty())
192 {
193 for (vector<string>::const_iterator i =
194 vars_keep_regexps_.begin();
195 i != vars_keep_regexps_.end();
196 ++i)
197 {
199 if (r)
200 compiled_vars_keep_regexps_.push_back(r);
201 }
202 }
203 return compiled_vars_keep_regexps_;
204 }
205
206 /// Getter for a map of the IDs of the functions that are present in
207 /// the set of exported functions.
208 ///
209 /// This map is useful during the construction of the set of
210 /// exported functions, at least to ensure that every function is
211 /// present only once in that set. Actually, for each symbol ID,
212 /// there can be several functions, given that each of those have
213 /// different declaration names; this can happen with function
214 /// template instantiations which decl names differ because the type
215 /// parameters of the templates are typedefs of each other.
216 ///
217 /// @return a map which key is a string and which data is a pointer
218 /// to a function.
221 {return id_fns_map_;}
222
223 /// Getter for a map of the IDs of the functions that are present in
224 /// the set of exported functions.
225 ///
226 /// This map is useful during the construction of the set of
227 /// exported functions, at least to ensure that every function is
228 /// present only once in that set.
229 ///
230 /// @return a map which key is a string and which data is a pointer
231 /// to a function.
234 {return id_fns_map_;}
235
236 /// Getter for a map of the IDs of the variables that are present in
237 /// the set of exported variables.
238 ///
239 /// This map is useful during the construction of the set of
240 /// exported variables, at least to ensure that every function is
241 /// present only once in that set.
242 ///
243 /// @return a map which key is a string and which data is a pointer
244 /// to a function.
247 {return id_var_map_;}
248
249 /// Getter for a map of the IDs of the variables that are present in
250 /// the set of exported variables.
251 ///
252 /// This map is useful during the construction of the set of
253 /// exported variables, at least to ensure that every function is
254 /// present only once in that set.
255 ///
256 /// @return a map which key is a string and which data is a pointer
257 /// to a function.
260 {return id_var_map_;}
261
262 /// Returns an ID for a given function.
263 ///
264 /// @param fn the function to calculate the ID for.
265 ///
266 /// @return a reference to a string representing the function ID.
269 {return fn.get_id();}
270
271 /// Returns an ID for a given variable.
272 ///
273 /// @param var the variable to calculate the ID for.
274 ///
275 /// @return a reference to a string representing the variable ID.
277 get_id(const var_decl& var)
278 {return var.get_id();}
279
280 /// Test if a given function ID is in the id-functions map.
281 ///
282 /// If it is, then return a pointer to the vector of functions with
283 /// that ID. If not, just return nil.
284 ///
285 /// @param fn_id the ID to consider.
286 ///
287 /// @return the pointer to the vector of functions with ID @p fn_id,
288 /// or nil if no function with that ID exists.
289 std::unordered_set<function_decl*>*
291 {
293 auto i = m.find(fn_id);
294 if (i == m.end())
295 return 0;
296 return &i->second;
297 }
298
299 /// Test if a a function if the same ID as a given function is
300 /// present in the id-functions map.
301 ///
302 /// @param fn the function to consider.
303 ///
304 /// @return a pointer to the vector of functions with the same ID as
305 /// @p fn, that are present in the id-functions map, or nil if no
306 /// function with the same ID as @p fn is present in the
307 /// id-functions map.
308 std::unordered_set<function_decl*>*
310 {
311 interned_string fn_id = fn->get_id();
312 return fn_id_is_in_id_fns_map(fn_id);
313 }
314
315 /// Test if a given function is present in a set of functions.
316 ///
317 /// The function compares the ID and the qualified name of
318 /// functions.
319 ///
320 /// @param fn the function to consider.
321 ///
322 /// @parm fns the set of functions to consider.
323 static bool
325 const std::unordered_set<function_decl*>& fns)
326 {
327 if (fns.empty())
328 return false;
329
330 if (fns.find(fn) != fns.end())
331 return true;
332
333 const string fn_id = fn->get_id();
334 for (const auto f : fns)
335 if (f->get_id() == fn_id
336 && f->get_qualified_name() == fn->get_qualified_name())
337 return true;
338
339 return false;
340 }
341
342 /// Test if a given function is present in a set of functions,
343 /// by looking at the pretty representation of the function, in
344 /// addition to looking at its ID.
345 ///
346 /// This is useful because sometimes a given ELF symbol (alias)
347 /// might be for several different functions. In that case, using
348 /// the function pretty representation might be a way to
349 /// differentiate the functions having the same ELF symbol alias.
350 ///
351 /// The function compares the ID and the qualified name of
352 /// functions.
353 ///
354 /// @param fn the function to consider.
355 ///
356 /// @parm fns the set of functions to consider.
357 ///
358 /// @return true if @p fn is present in @p fns.
359 static bool
361 const std::unordered_set<function_decl*>& fns,
362 string& pretty_representation)
363 {
364 if (!fn_is_in_fns(fn, fns))
365 return false;
366
367 const string repr = fn->get_pretty_representation();
368 const string fn_id = fn->get_id();
369 for (const auto f : fns)
370 if (f->get_id() == fn_id
371 && f->get_pretty_representation() == repr)
372 {
373 pretty_representation = repr;
374 return true;
375 }
376
377 return false;
378 }
379
380 /// Test if a function is in the id-functions map.
381 ///
382 /// @param fn the function to consider.
383 ///
384 /// @return true iff the function is in the id-functions map.
385 bool
387 {
388 std::unordered_set<function_decl*>* fns = fn_id_is_in_id_fns_map(fn);
389 if (fns && fn_is_in_fns(fn, *fns))
390 return true;
391 return false;
392 }
393
394 /// Add a given function to the map of functions that are present in
395 /// the set of exported functions.
396 ///
397 /// @param fn the function to add to the map.
398 void
400 {
401 if (!fn)
402 return;
403
404 // First associate the function id to the function.
405 interned_string fn_id = fn->get_id();
406 std::unordered_set<function_decl*>* fns = fn_id_is_in_id_fns_map(fn_id);
407 if (!fns)
408 fns = &(id_fns_map()[fn_id] = std::unordered_set<function_decl*>());
409 fns->insert(fn);
410
411 // Now associate all aliases of the underlying symbol to the
412 // function too.
413 elf_symbol_sptr sym = fn->get_symbol();
414 ABG_ASSERT(sym);
415 string sym_id;
416 do
417 {
418 sym_id = sym->get_id_string();
419 if (sym_id == fn_id)
420 goto loop;
421 fns = fn_id_is_in_id_fns_map(fn_id);
422 if (!fns)
423 fns = &(id_fns_map()[fn_id] = std::unordered_set<function_decl*>());
424 fns->insert(fn);
425 loop:
426 sym = sym->get_next_alias();
427 }
428 while (sym && !sym->is_main_symbol());
429 }
430
431 /// Test if a given (ID of a) varialble is present in the variable
432 /// map. In other words, it tests if a given variable is present in
433 /// the set of exported variables.
434 ///
435 /// @param fn_id the ID of the variable to consider.
436 ///
437 /// @return true iff the variable designated by @p fn_id is present
438 /// in the set of exported variables.
439 bool
441 {
443 auto i = m.find(var_id);
444 return i != m.end();
445 }
446
447 /// Add a given variable to the map of functions that are present in
448 /// the set of exported functions.
449 ///
450 /// @param id the variable to add to the map.
451 void
453 {
454 if (var)
455 {
456 const interned_string& var_id = get_id(*var);
457 id_var_map()[var_id] = var;
458 }
459 }
460
461 /// Add a function to the set of exported functions.
462 ///
463 /// @param fn the function to add to the set of exported functions.
464 void
466 {
467 if (!fn_is_in_id_fns_map(fn))
468 {
469 fns_.push_back(fn);
471 }
472 }
473
474 /// Add a variable to the set of exported variables.
475 ///
476 /// @param fn the variable to add to the set of exported variables.
477 void
479 {
480 const interned_string& id = get_id(*var);
482 {
483 vars_.push_back(const_cast<var_decl*>(var));
484 add_var_to_map(const_cast<var_decl*>(var));
485 }
486 }
487
488 /// Getter for the set of ids of functions to keep in the set of
489 /// exported functions.
490 ///
491 /// @return the set of ids of functions to keep in the set of
492 /// exported functions.
493 const strings_type&
495 {return sym_id_of_fns_to_keep_;}
496
497 /// Getter for the set of ids of variables to keep in the set of
498 /// exported variables.
499 ///
500 /// @return the set of ids of variables to keep in the set of
501 /// exported variables.
502 const strings_type&
504 {return sym_id_of_vars_to_keep_;}
505
506 /// Look at the set of functions to keep and tell if if a given
507 /// function is to be kept, according to that set.
508 ///
509 /// @param fn the function to consider.
510 ///
511 /// @return true iff the function is to be kept.
512 bool
514 {
515 if (!fn)
516 return false;
517
518 bool keep = true;
519
520 if (elf_symbol_sptr sym = fn->get_symbol())
521 {
522 if (!sym_id_of_fns_to_keep().empty())
523 keep = false;
524 if (!keep)
525 {
526 for (vector<string>::const_iterator i =
527 sym_id_of_fns_to_keep().begin();
528 i != sym_id_of_fns_to_keep().end();
529 ++i)
530 {
531 string sym_name, sym_version;
533 sym_name,
534 sym_version));
535 if (sym_name == sym->get_name()
536 && sym_version == sym->get_version().str())
537 {
538 keep = true;
539 break;
540 }
541 }
542 }
543 }
544 else
545 keep = false;
546
547 return keep;
548 }
549
550 /// Look at the set of functions to suppress from the exported
551 /// functions set and tell if if a given function is to be kept,
552 /// according to that set.
553 ///
554 /// @param fn the function to consider.
555 ///
556 /// @return true iff the function is to be kept.
557 bool
559 {
560 if (!fn)
561 return false;
562
563 string frep = fn->get_qualified_name();
564 bool keep = true;
565
566 for (regex_t_sptrs_type::const_iterator i =
568 i != compiled_regex_fns_suppress().end();
569 ++i)
570 if (regex::match(*i, frep))
571 {
572 keep = false;
573 break;
574 }
575
576 return keep;
577 }
578
579 /// Look at the regular expressions of the functions to keep and
580 /// tell if if a given function is to be kept, according to that
581 /// set.
582 ///
583 /// @param fn the function to consider.
584 ///
585 /// @return true iff the function is to be kept.
586 bool
588 {
589 if (!fn)
590 return false;
591
592 string frep = fn->get_qualified_name();
593 bool keep = true;
594
595 if (!compiled_regex_fns_keep().empty())
596 keep = false;
597
598 if (!keep)
599 for (regex_t_sptrs_type::const_iterator i =
600 compiled_regex_fns_keep().begin();
601 i != compiled_regex_fns_keep().end();
602 ++i)
603 if (regex::match(*i, frep))
604 {
605 keep = true;
606 break;
607 }
608
609 return keep;
610 }
611
612 /// Look at the regular expressions of the variables to keep and
613 /// tell if if a given variable is to be kept, according to that
614 /// set.
615 ///
616 /// @param fn the variable to consider.
617 ///
618 /// @return true iff the variable is to be kept.
619 bool
621 {
622 if (!var)
623 return false;
624
625 bool keep = true;
626
627 if (elf_symbol_sptr sym = var->get_symbol())
628 {
629 if (!sym_id_of_vars_to_keep().empty())
630 keep = false;
631 if (!keep)
632 {
633 for (vector<string>::const_iterator i =
634 sym_id_of_vars_to_keep().begin();
635 i != sym_id_of_vars_to_keep().end();
636 ++i)
637 {
638 string sym_name, sym_version;
640 sym_name,
641 sym_version));
642 if (sym_name == sym->get_name()
643 && sym_version == sym->get_version().str())
644 {
645 keep = true;
646 break;
647 }
648 }
649 }
650 }
651 else
652 keep = false;
653
654 return keep;
655 }
656
657 /// Look at the set of variables to suppress from the exported
658 /// variables set and tell if if a given variable is to be kept,
659 /// according to that set.
660 ///
661 /// @param fn the variable to consider.
662 ///
663 /// @return true iff the variable is to be kept.
664 bool
666 {
667 if (!var)
668 return false;
669
670 string frep = var->get_qualified_name();
671 bool keep = true;
672
673 for (regex_t_sptrs_type::const_iterator i =
675 i != compiled_regex_vars_suppress().end();
676 ++i)
677 if (regex::match(*i, frep))
678 {
679 keep = false;
680 break;
681 }
682
683 return keep;
684 }
685
686 /// Look at the regular expressions of the variables to keep and
687 /// tell if if a given variable is to be kept, according to that
688 /// set.
689 ///
690 /// @param fn the variable to consider.
691 ///
692 /// @return true iff the variable is to be kept.
693 bool
695 {
696 if (!var)
697 return false;
698
699 string frep = var->get_qualified_name();
700 bool keep = true;
701
702 if (!compiled_regex_vars_keep().empty())
703 keep = false;
704
705 if (!keep)
706 {
707 for (regex_t_sptrs_type::const_iterator i =
708 compiled_regex_vars_keep().begin();
709 i != compiled_regex_vars_keep().end();
710 ++i)
711 if (regex::match(*i, frep))
712 {
713 keep = true;
714 break;
715 }
716 }
717
718 return keep;
719 }
720}; // end struct corpus::exported_decls_builder::priv
721
722
723/// The private data of the @ref corpus type.
725{
726 mutable unordered_map<string, type_base_sptr> canonical_types_;
727 string format_major_version_number_;
728 string format_minor_version_number_;
729 const environment& env;
730 corpus_group* group;
732 corpus::origin origin_;
733 vector<string> regex_patterns_fns_to_suppress;
734 vector<string> regex_patterns_vars_to_suppress;
735 vector<string> regex_patterns_fns_to_keep;
736 vector<string> regex_patterns_vars_to_keep;
737 vector<string> sym_id_fns_to_keep;
738 vector<string> sym_id_vars_to_keep;
739 string path;
740 vector<string> needed;
741 string soname;
742 string architecture_name;
743 translation_units members;
744 string_tu_map_type path_tu_map;
745 vector<const function_decl*> fns;
746 vector<const var_decl*> vars;
748 // The type maps contained in this data member are populated if the
749 // corpus follows the One Definition Rule and thus if there is only
750 // one copy of a type with a given name, per corpus. Otherwise, if
751 // there can be several *different* types with the same name, then
752 // the type maps are all empty. The types are then maintained in
753 // type maps that are in each translation units.
754 //
755 // In other words, to lookup a given type, if the corpus allows the
756 // One Definition Rule, then lookup can be done by looking into this
757 // data member. Otherwise, the lookup must be made by looking into
758 // the type maps of each translation unit.
759 type_maps types_;
760 type_maps type_per_loc_map_;
761 mutable vector<type_base_wptr> types_not_reachable_from_pub_ifaces_;
762 unordered_set<interned_string, hash_interned_string> *pub_type_pretty_reprs_;
763 bool do_log;
764
765private:
766 priv();
767
768 mutable abg_compat::optional<elf_symbols> sorted_var_symbols;
770 mutable abg_compat::optional<elf_symbols> sorted_undefined_var_symbols;
771 mutable abg_compat::optional<string_elf_symbols_map_type> undefined_var_symbol_map;
772 mutable abg_compat::optional<elf_symbols> unrefed_var_symbols;
773 mutable abg_compat::optional<elf_symbols> sorted_fun_symbols;
775 mutable abg_compat::optional<elf_symbols> sorted_undefined_fun_symbols;
776 mutable abg_compat::optional<string_elf_symbols_map_type> undefined_fun_symbol_map;
777 mutable abg_compat::optional<elf_symbols> unrefed_fun_symbols;
778
779public:
780 priv(const string & p,
781 const environment& e)
782 : env(e),
783 group(),
784 origin_(ARTIFICIAL_ORIGIN),
785 path(p),
786 pub_type_pretty_reprs_(),
787 do_log()
788 {}
789
790 type_maps&
791 get_types();
792
793 const type_maps&
794 get_types() const;
795
796 const elf_symbols&
798
800 get_fun_symbol_map() const;
801
802 const elf_symbols&
804
807
808 const elf_symbols&
810
811 const elf_symbols&
813
815 get_var_symbol_map() const;
816
817 const elf_symbols&
819
822
823 const elf_symbols&
825
826 unordered_set<interned_string, hash_interned_string>*
828
829 std::unordered_set<function_decl*>*
831
832 ~priv();
833}; // end struct corpus::priv
834
835void
836maybe_update_scope_lookup_map(const scope_decl_sptr& member_scope);
837
838void
839maybe_update_scope_lookup_map(const decl_base_sptr& member_scope);
840
841void
843
844void
846
847void
848maybe_update_types_lookup_map(const union_decl_sptr& union_type);
849
850void
852
853void
855
856void
857maybe_update_types_lookup_map(const qualified_type_def_sptr& qualified_type);
858
859void
861
862void
864
865void
867
868void
871
872void
873maybe_update_types_lookup_map(const decl_base_sptr& decl);
874
875void
876maybe_update_types_lookup_map(const type_base_sptr& type);
877
878}// end namespace ir
879
880}// end namespace abigail
881
882#endif // __ABG_CORPUS_PRIV_H__
std::shared_ptr< symtab > symtab_sptr
Convenience typedef for a shared pointer to a symtab.
Definition: abg-fwd.h:1648
#define ABG_ASSERT(cond)
This is a wrapper around the 'assert' glibc call. It allows for its argument to have side effects,...
Definition: abg-fwd.h:1695
Declaration of types pertaining to the interned string pool used throughout Libabigail,...
Types of the main internal representation of libabigail.
Wrappers around regex types and functions.
Utilities to ease the wrapping of C types into std::shared_ptr.
This contains the declarations for the symtab reader.
The abstraction of an interned string.
The type of the private data of corpus::exported_decls_builder type.
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,...
interned_string get_id(const var_decl &var)
Returns an ID for a given variable.
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...
bool keep_wrt_id_of_vars_to_keep(const var_decl *var)
Look at the regular expressions of the variables to keep and tell if if a given variable is to be kep...
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.
regex_t_sptrs_type & compiled_regex_fns_suppress()
Getter for the compiled regular expressions that designate the functions to suppress from the set of ...
void add_var_to_map(var_decl *var)
Add a given variable to the map of functions that are present in the set of exported functions.
istr_var_ptr_map_type & id_var_map()
Getter for a map of the IDs of the variables that are present in the set of exported variables.
interned_string get_id(const function_decl &fn)
Returns an ID for a given function.
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...
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.
bool keep_wrt_regex_of_vars_to_keep(const var_decl *var)
Look at the regular expressions of the variables to keep and tell if if a given variable is to be kep...
const istr_var_ptr_map_type & id_var_map() const
Getter for a map of the IDs of the variables that are present in the set of exported variables.
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.
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.
void add_var_to_exported(const var_decl *var)
Add a variable to the set of exported variables.
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.
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...
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...
bool var_id_is_in_id_var_map(const interned_string &var_id) const
Test if a given (ID of a) varialble is present in the variable map. In other words,...
bool keep_wrt_regex_of_vars_to_suppress(const var_decl *var)
Look at the set of variables to suppress from the exported variables set and tell if if a given varia...
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...
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_vars_suppress()
Getter of the compiled regular expressions that designate the variables to suppress from the set of e...
void add_fn_to_exported(function_decl *fn)
Add a function to the set of exported functions.
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.
bool fn_is_in_id_fns_map(function_decl *fn)
Test if a function is in the id-functions map.
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.
Abstracts the building of the set of exported variables and functions.
Definition: abg-corpus.h:307
Abstraction of a group of corpora.
Definition: abg-corpus.h:356
This is the abstraction of a set of translation units (themselves seen as bundles of unitary abi arte...
Definition: abg-corpus.h:25
origin
This abstracts where the corpus comes from. That is, either it has been read from the native xml form...
Definition: abg-corpus.h:45
vector< const var_decl * > variables
Convenience typedef for std::vector<abigail::ir::var_decl*>
Definition: abg-corpus.h:34
shared_ptr< exported_decls_builder > exported_decls_builder_sptr
Convenience typedef for shared_ptr<exported_decls_builder>.
Definition: abg-corpus.h:39
vector< const function_decl * > functions
Convenience typedef for std::vector<abigail::ir::function_decl*>
Definition: abg-corpus.h:31
vector< string > strings_type
A convenience typedef for std::vector<string>.
Definition: abg-corpus.h:28
virtual void get_qualified_name(interned_string &qualified_name, bool internal=false) const
Compute the qualified name of the decl.
Definition: abg-ir.cc:5056
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.
Definition: abg-ir.cc:2657
This is an abstraction of the set of resources necessary to manage several aspects of the internal re...
Definition: abg-ir.h:140
Abstraction for a function declaration.
Definition: abg-ir.h:3111
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...
Definition: abg-ir.cc:22189
virtual string get_pretty_representation(bool internal=false, bool qualified_name=true) const
Get the pretty representation of the current instance of function_decl.
Definition: abg-ir.cc:22012
interned_string get_id() const
Return an ID that tries to uniquely identify the function inside a program or a library.
Definition: abg-ir.cc:22473
Abstraction of a function type.
Definition: abg-ir.h:3387
A declaration that introduces a scope.
Definition: abg-ir.h:1809
This is a type that aggregates maps of all the kinds of types that are supported by libabigail.
Definition: abg-ir.h:593
Abstracts a variable declaration.
Definition: abg-ir.h:3008
virtual const interned_string & get_qualified_name(bool internal=false) const
Get the qualified name of a given variable or data member.
Definition: abg-ir.cc:20964
const elf_symbol_sptr & get_symbol() const
Gets the the underlying ELF symbol for the current variable, that was set using var_decl::set_symbol(...
Definition: abg-ir.cc:20694
interned_string get_id() const
Return an ID that tries to uniquely identify the variable inside a program or a library.
Definition: abg-ir.cc:20908
shared_ptr< reference_type_def > reference_type_def_sptr
Convenience typedef for a shared pointer on a reference_type_def.
Definition: abg-fwd.h:232
shared_ptr< elf_symbol > elf_symbol_sptr
A convenience typedef for a shared pointer to elf_symbol.
Definition: abg-ir.h:888
shared_ptr< array_type_def > array_type_def_sptr
Convenience typedef for a shared pointer on a array_type_def.
Definition: abg-fwd.h:241
std::vector< elf_symbol_sptr > elf_symbols
Convenience typedef for a vector of elf_symbol.
Definition: abg-ir.h:904
shared_ptr< class_decl > class_decl_sptr
Convenience typedef for a shared pointer on a class_decl.
Definition: abg-fwd.h:190
vector< regex_t_sptr > regex_t_sptrs_type
A convenience typedef for std::vector<regex_t_sptr>.
shared_ptr< function_type > function_type_sptr
Convenience typedef for a shared pointer on a function_type.
Definition: abg-fwd.h:207
shared_ptr< typedef_decl > typedef_decl_sptr
Convenience typedef for a shared pointer on a typedef_decl.
Definition: abg-fwd.h:164
shared_ptr< scope_decl > scope_decl_sptr
Convenience typedef for a shared pointer on a scope_decl.
Definition: abg-fwd.h:261
shared_ptr< pointer_type_def > pointer_type_def_sptr
Convenience typedef for a shared pointer on a pointer_type_def.
Definition: abg-fwd.h:223
unordered_map< string, translation_unit_sptr > string_tu_map_type
Convenience typedef for a map that associates a string to a translation unit.
Definition: abg-fwd.h:140
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.
Definition: abg-ir.cc:14386
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...
shared_ptr< enum_type_decl > enum_type_decl_sptr
Convenience typedef for shared pointer to a enum_type_decl.
Definition: abg-fwd.h:172
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...
std::set< translation_unit_sptr, shared_translation_unit_comp > translation_units
Convenience typedef for an ordered set of translation_unit_sptr.
Definition: abg-ir.h:851
shared_ptr< type_decl > type_decl_sptr
Convenience typedef for a shared pointer on a type_decl.
Definition: abg-fwd.h:158
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.
Definition: abg-ir.h:909
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...
unordered_map< string, var_decl * > 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*.
unordered_map< interned_string, var_decl *, 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::...
bool match(const regex_t_sptr &r, const std::string &str)
See if a string matches a regex.
Definition: abg-regex.cc:127
regex_t_sptr compile(const std::string &str)
Compile a regex from a string.
Definition: abg-regex.cc:111
std::shared_ptr< regex_t > regex_t_sptr
A convenience typedef for a shared pointer of regex_t.
Definition: abg-fwd.h:88
Toplevel namespace for libabigail.
A functor to hash instances of interned_string.
The private data of the corpus type.
const elf_symbols & get_sorted_var_symbols() const
Getter for the sorted vector of variable symbols for this corpus.
Definition: abg-corpus.cc:479
const string_elf_symbols_map_type & get_undefined_var_symbol_map() const
Return a map from name to undefined variable symbol for this corpus.
Definition: abg-corpus.cc:550
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...
Definition: abg-corpus.cc:622
const string_elf_symbols_map_type & get_var_symbol_map() const
Return a map from name to variable symbol for this corpus.
Definition: abg-corpus.cc:505
const elf_symbols & get_sorted_fun_symbols() const
Return a sorted vector of function symbols for this corpus.
Definition: abg-corpus.cc:335
type_maps & get_types()
Get the maps that associate a name to a certain kind of type.
Definition: abg-corpus.cc:319
const elf_symbols & get_sorted_undefined_fun_symbols() const
Getter for a sorted vector of the function symbols undefined in this corpus.
Definition: abg-corpus.cc:377
const string_elf_symbols_map_type & get_undefined_fun_symbol_map() const
Return a map from name to undefined function symbol for this corpus.
Definition: abg-corpus.cc:405
const string_elf_symbols_map_type & get_fun_symbol_map() const
Return a map from name to function symbol for this corpus.
Definition: abg-corpus.cc:360
const elf_symbols & get_unreferenced_function_symbols() const
Return a list of symbols that are not referenced by any function of corpus::get_functions().
Definition: abg-corpus.cc:427
const elf_symbols & get_unreferenced_variable_symbols() const
Return a list of symbols that are not referenced by any variable of corpus::get_variables().
Definition: abg-corpus.cc:572
const elf_symbols & get_sorted_undefined_var_symbols() const
Getter for a sorted vector of the variable symbols undefined in this corpus.
Definition: abg-corpus.cc:522
std::unordered_set< function_decl * > * lookup_functions(const interned_string &id)
Lookup the function which has a given function ID.
Definition: abg-corpus.cc:648
~priv()
Destructor of the corpus::priv type.
Definition: abg-corpus.cc:662