libabigail
Loading...
Searching...
No Matches
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-2024 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_sptr> 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,
65
66/// Convenience typedef for a hash map which key is an interned_string
67/// and which data is a set of abigail::ir::var_decl_sptr
68typedef unordered_map<interned_string,
69 std::unordered_set<var_decl_sptr>,
71
72/// The type of the private data of @ref
73/// corpus::exported_decls_builder type.
75{
77 friend class corpus;
78
79 priv();
80
81 functions& fns_;
82 variables& vars_;
83 // A map that associates a function ID (function symbol and its
84 // version) to a vector of functions with that ID. Normally, one
85 // would think that in the corpus, there must only one function for
86 // a given ID. Actually, in c++, there can be two function template
87 // instantiations that produce the same function ID because the
88 // template parameters of the second instantiation are just typedefs
89 // of the first instantiation, for instance. So there can be cases
90 // where one ID appertains to more than one function.
91 istr_fn_ptr_set_map_type id_fns_map_;
92 istr_var_ptr_set_map_type id_vars_map_;
93 strings_type& fns_suppress_regexps_;
94 regex_t_sptrs_type compiled_fns_suppress_regexp_;
95 strings_type& vars_suppress_regexps_;
96 regex_t_sptrs_type compiled_vars_suppress_regexp_;
97 strings_type& fns_keep_regexps_;
98 regex_t_sptrs_type compiled_fns_keep_regexps_;
99 strings_type& vars_keep_regexps_;
100 regex_t_sptrs_type compiled_vars_keep_regexps_;
101 strings_type& sym_id_of_fns_to_keep_;
102 strings_type& sym_id_of_vars_to_keep_;
103
104public:
105
106 priv(functions& fns,
107 variables& vars,
108 strings_type& fns_suppress_regexps,
109 strings_type& vars_suppress_regexps,
110 strings_type& fns_keep_regexps,
111 strings_type& vars_keep_regexps,
114 : fns_(fns),
115 vars_(vars),
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)
122 {}
123
124 /// Getter for the compiled regular expressions that designate the
125 /// functions to suppress from the set of exported functions.
126 ///
127 /// @return a vector of the compiled regular expressions.
130 {
131 if (compiled_fns_suppress_regexp_.empty())
132 {
133 for (vector<string>::const_iterator i =
134 fns_suppress_regexps_.begin();
135 i != fns_suppress_regexps_.end();
136 ++i)
137 {
139 if (r)
140 compiled_fns_suppress_regexp_.push_back(r);
141 }
142 }
143 return compiled_fns_suppress_regexp_;
144 }
145
146 /// Getter for the compiled regular expressions that designates the
147 /// functions to keep in the set of exported functions.
148 ///
149 /// @return a vector of compiled regular expressions.
152 {
153 if (compiled_fns_keep_regexps_.empty())
154 {
155 for (vector<string>::const_iterator i =
156 fns_keep_regexps_.begin();
157 i != fns_keep_regexps_.end();
158 ++i)
159 {
161 if (r)
162 compiled_fns_keep_regexps_.push_back(r);
163 }
164 }
165 return compiled_fns_keep_regexps_;
166 }
167
168 /// Getter of the compiled regular expressions that designate the
169 /// variables to suppress from the set of exported variables.
170 ///
171 /// @return a vector of compiled regular expressions.
174 {
175 if (compiled_vars_suppress_regexp_.empty())
176 {
177 for (vector<string>::const_iterator i =
178 vars_suppress_regexps_.begin();
179 i != vars_suppress_regexps_.end();
180 ++i)
181 {
183 if (r)
184 compiled_vars_suppress_regexp_.push_back(r);
185 }
186 }
187 return compiled_vars_suppress_regexp_;
188 }
189
190 /// Getter for the compiled regular expressions that designate the
191 /// variables to keep in the set of exported variables.
192 ///
193 /// @return a vector of compiled regular expressions.
196 {
197 if (compiled_vars_keep_regexps_.empty())
198 {
199 for (vector<string>::const_iterator i =
200 vars_keep_regexps_.begin();
201 i != vars_keep_regexps_.end();
202 ++i)
203 {
205 if (r)
206 compiled_vars_keep_regexps_.push_back(r);
207 }
208 }
209 return compiled_vars_keep_regexps_;
210 }
211
212 /// Getter for a map of the IDs of the functions that are present in
213 /// the set of exported functions.
214 ///
215 /// This map is useful during the construction of the set of
216 /// exported functions, at least to ensure that every function is
217 /// present only once in that set. Actually, for each symbol ID,
218 /// there can be several functions, given that each of those have
219 /// different declaration names; this can happen with function
220 /// template instantiations which decl names differ because the type
221 /// parameters of the templates are typedefs of each other.
222 ///
223 /// @return a map which key is a string and which data is a pointer
224 /// to a function.
227 {return id_fns_map_;}
228
229 /// Getter for a map of the IDs of the functions that are present in
230 /// the set of exported functions.
231 ///
232 /// The map associates the ID of a function with the set of
233 /// functions having the symbol that matches the ID.
234 ///
235 /// @return a map which key is a string and which data is a set of
236 /// functions.
239 {return id_fns_map_;}
240
241 /// Getter for a map of the IDs of the variables that are present in
242 /// the set of exported variables.
243 ///
244 /// The map associates the ID of a variable with the set of variables
245 /// having the symbol that matches the ID.
246 ///
247 /// @return a map which key is a string and which data is a set of
248 /// variables.
251 {return id_vars_map_;}
252
253 /// Getter for a map of the IDs of the variables that are present in
254 /// the set of exported variables.
255 ///
256 /// The map associates the ID of a variable with the set of variables
257 /// having the symbol that matches the ID.
258 ///
259 /// @return a map which key is a string and which data is a set of
260 /// variables.
263 {return id_vars_map_;}
264
265 /// Returns an ID for a given function.
266 ///
267 /// @param fn the function to calculate the ID for.
268 ///
269 /// @return a reference to a string representing the function ID.
272 {return fn.get_id();}
273
274 /// Returns an ID for a given variable.
275 ///
276 /// @param var the variable to calculate the ID for.
277 ///
278 /// @return a reference to a string representing the variable ID.
280 get_id(const var_decl& var)
281 {return var.get_id();}
282
283 /// Test if a given function ID is in the id-functions map.
284 ///
285 /// If it is, then return a pointer to the vector of functions with
286 /// that ID. If not, just return nil.
287 ///
288 /// @param fn_id the ID to consider.
289 ///
290 /// @return the pointer to the vector of functions with ID @p fn_id,
291 /// or nil if no function with that ID exists.
292 std::unordered_set<function_decl*>*
294 {
296 auto i = m.find(fn_id);
297 if (i == m.end())
298 return 0;
299 return &i->second;
300 }
301
302 /// Test if a a function if the same ID as a given function is
303 /// present in the id-functions map.
304 ///
305 /// @param fn the function to consider.
306 ///
307 /// @return a pointer to the vector of functions with the same ID as
308 /// @p fn, that are present in the id-functions map, or nil if no
309 /// function with the same ID as @p fn is present in the
310 /// id-functions map.
311 std::unordered_set<function_decl*>*
313 {
314 interned_string fn_id = fn->get_id();
315 return fn_id_is_in_id_fns_map(fn_id);
316 }
317
318 /// Test if a given function is present in a set of functions.
319 ///
320 /// The function compares the ID and the qualified name of
321 /// functions.
322 ///
323 /// @param fn the function to consider.
324 ///
325 /// @parm fns the set of functions to consider.
326 static bool
328 const std::unordered_set<function_decl*>& fns)
329 {
330 if (fns.empty())
331 return false;
332
333 if (fns.find(fn) != fns.end())
334 return true;
335
336 const string fn_id = fn->get_id();
337 for (const auto f : fns)
338 if (f->get_id() == fn_id
339 && f->get_qualified_name() == fn->get_qualified_name())
340 return true;
341
342 return false;
343 }
344
345 /// Test if a given function is present in a set of functions,
346 /// by looking at the pretty representation of the function, in
347 /// addition to looking at its ID.
348 ///
349 /// This is useful because sometimes a given ELF symbol (alias)
350 /// might be for several different functions. In that case, using
351 /// the function pretty representation might be a way to
352 /// differentiate the functions having the same ELF symbol alias.
353 ///
354 /// The function compares the ID and the qualified name of
355 /// functions.
356 ///
357 /// @param fn the function to consider.
358 ///
359 /// @parm fns the set of functions to consider.
360 ///
361 /// @return true if @p fn is present in @p fns.
362 static bool
364 const std::unordered_set<function_decl*>& fns,
365 string& pretty_representation)
366 {
367 if (!fn_is_in_fns(fn, fns))
368 return false;
369
370 const string repr = fn->get_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)
375 {
376 pretty_representation = repr;
377 return true;
378 }
379
380 return false;
381 }
382
383 /// Test if a function is in the id-functions map.
384 ///
385 /// @param fn the function to consider.
386 ///
387 /// @return true iff the function is in the id-functions map.
388 bool
390 {
391 std::unordered_set<function_decl*>* fns = fn_id_is_in_id_fns_map(fn);
392 if (fns && fn_is_in_fns(fn, *fns))
393 return true;
394 return false;
395 }
396
397 /// Add a given function to the map of functions that are present in
398 /// the set of exported functions.
399 ///
400 /// @param fn the function to add to the map.
401 void
403 {
404 if (!fn)
405 return;
406
407 // First associate the function id to the function.
408 interned_string fn_id = fn->get_id();
409 std::unordered_set<function_decl*>* fns = fn_id_is_in_id_fns_map(fn_id);
410 if (!fns)
411 fns = &(id_fns_map()[fn_id] = std::unordered_set<function_decl*>());
412 fns->insert(fn);
413
414 // Now associate all aliases of the underlying symbol to the
415 // function too.
416 elf_symbol_sptr sym = fn->get_symbol();
417 ABG_ASSERT(sym);
418 string sym_id;
419 do
420 {
421 sym_id = sym->get_id_string();
422 if (sym_id == fn_id)
423 goto loop;
424 fns = fn_id_is_in_id_fns_map(fn_id);
425 if (!fns)
426 fns = &(id_fns_map()[fn_id] = std::unordered_set<function_decl*>());
427 fns->insert(fn);
428 loop:
429 sym = sym->get_next_alias();
430 }
431 while (sym && !sym->is_main_symbol());
432 }
433
434 /// Test if a given (ID of a) variable is present in the variable
435 /// map. In other words, it tests if a given variable is present in
436 /// the set of exported variables.
437 ///
438 /// @param fn_id the ID of the variable to consider.
439 ///
440 /// @return a pointer to the set of variables that have the same ID
441 /// as @p var_id.
442 std::unordered_set<var_decl_sptr>*
444 {
446 auto i = m.find(var_id);
447 if (i != m.end())
448 return &i->second;
449 return nullptr;
450 }
451
452 /// Test if a given (ID of a) variable is present in the variable
453 /// map. In other words, it tests if a given variable is present in
454 /// the set of exported variables.
455 ///
456 /// @param fn_id the ID of the variable to consider.
457 ///
458 /// @return a pointer to the set of variables that have the same ID
459 /// as @p var_id.
460 const std::unordered_set<var_decl_sptr>*
462 {
463 return const_cast<corpus::exported_decls_builder::priv*>(this)->
465 }
466
467 /// Test if a given variable is present in a set of variables.
468 ///
469 /// The variable compares the ID and the qualified name of
470 /// variables.
471 ///
472 /// @param fn the variable to consider.
473 ///
474 /// @parm fns the set of variables to consider.
475 static bool
477 const std::unordered_set<var_decl_sptr>& vars)
478 {
479 if (vars.empty())
480 return false;
481
482 if (vars.find(var) != vars.end())
483 return true;
484
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())
489 return true;
490
491 return false;
492 }
493
494 /// Test if a given variable is present in a set of variables.
495 ///
496 /// The variable compares the ID and the qualified name of
497 /// variables.
498 ///
499 /// @param fn the variable to consider.
500 ///
501 /// @parm fns the set of variables to consider.
502 bool
504 {
505 if (!var)
506 return false;
507
508 interned_string var_id = var->get_id();
509 const std::unordered_set<var_decl_sptr>* vars =
511 if (vars && var_is_in_vars(var, *vars))
512 return true;
513 return false;
514 }
515
516 /// Add a given variable to the map of variables that are present in
517 /// the set of exported variables.
518 ///
519 /// @param fn the variable to add to the map.
520 void
522 {
523 if (!var)
524 return;
525
526 // First associate the var id to the variable.
527 interned_string var_id = var->get_id();
528 std::unordered_set<var_decl_sptr>* vars = var_id_is_in_id_vars_map(var_id);
529 if (!vars)
530 vars = &(id_vars_map()[var_id] = std::unordered_set<var_decl_sptr>());
531 vars->insert(var);
532
533 // Now associate all aliases of th underlying symbol to the
534 // variable too.
535 elf_symbol_sptr sym = var->get_symbol();
536 ABG_ASSERT(sym);
537 string sym_id;
538 do
539 {
540 sym_id = sym->get_id_string();
541 if (sym_id == var_id)
542 goto loop;
543 vars = var_id_is_in_id_vars_map(var_id);
544 if (!vars)
545 vars = &(id_vars_map()[var_id] = std::unordered_set<var_decl_sptr>());
546 vars->insert(var);
547 loop:
548 sym = sym->get_next_alias();
549 }
550 while (sym && !sym->is_main_symbol());
551 }
552
553 /// Add a function to the set of exported functions.
554 ///
555 /// @param fn the function to add to the set of exported functions.
556 void
558 {
559 if (!fn_is_in_id_fns_map(fn))
560 {
561 fns_.push_back(fn);
563 }
564 }
565
566 /// Add a variable to the set of exported variables.
567 ///
568 /// @param fn the variable to add to the set of exported variables.
569 void
571 {
572 if (!var_is_in_id_vars_map(var))
573 {
574 vars_.push_back(var);
576 }
577 }
578
579 /// Getter for the set of ids of functions to keep in the set of
580 /// exported functions.
581 ///
582 /// @return the set of ids of functions to keep in the set of
583 /// exported functions.
584 const strings_type&
586 {return sym_id_of_fns_to_keep_;}
587
588 /// Getter for the set of ids of variables to keep in the set of
589 /// exported variables.
590 ///
591 /// @return the set of ids of variables to keep in the set of
592 /// exported variables.
593 const strings_type&
595 {return sym_id_of_vars_to_keep_;}
596
597 /// Look at the set of functions to keep and tell if if a given
598 /// function is to be kept, according to that set.
599 ///
600 /// @param fn the function to consider.
601 ///
602 /// @return true iff the function is to be kept.
603 bool
605 {
606 if (!fn)
607 return false;
608
609 bool keep = true;
610
611 if (elf_symbol_sptr sym = fn->get_symbol())
612 {
613 if (!sym_id_of_fns_to_keep().empty())
614 keep = false;
615 if (!keep)
616 {
617 for (vector<string>::const_iterator i =
618 sym_id_of_fns_to_keep().begin();
619 i != sym_id_of_fns_to_keep().end();
620 ++i)
621 {
622 string sym_name, sym_version;
624 sym_name,
625 sym_version));
626 if (sym_name == sym->get_name()
627 && sym_version == sym->get_version().str())
628 {
629 keep = true;
630 break;
631 }
632 }
633 }
634 }
635 else
636 keep = false;
637
638 return keep;
639 }
640
641 /// Look at the set of functions to suppress from the exported
642 /// functions set and tell if if a given function is to be kept,
643 /// according to that set.
644 ///
645 /// @param fn the function to consider.
646 ///
647 /// @return true iff the function is to be kept.
648 bool
650 {
651 if (!fn)
652 return false;
653
654 string frep = fn->get_qualified_name();
655 bool keep = true;
656
657 for (regex_t_sptrs_type::const_iterator i =
659 i != compiled_regex_fns_suppress().end();
660 ++i)
661 if (regex::match(*i, frep))
662 {
663 keep = false;
664 break;
665 }
666
667 return keep;
668 }
669
670 /// Look at the regular expressions of the functions to keep and
671 /// tell if if a given function is to be kept, according to that
672 /// set.
673 ///
674 /// @param fn the function to consider.
675 ///
676 /// @return true iff the function is to be kept.
677 bool
679 {
680 if (!fn)
681 return false;
682
683 string frep = fn->get_qualified_name();
684 bool keep = true;
685
686 if (!compiled_regex_fns_keep().empty())
687 keep = false;
688
689 if (!keep)
690 for (regex_t_sptrs_type::const_iterator i =
691 compiled_regex_fns_keep().begin();
692 i != compiled_regex_fns_keep().end();
693 ++i)
694 if (regex::match(*i, frep))
695 {
696 keep = true;
697 break;
698 }
699
700 return keep;
701 }
702
703 /// Look at the regular expressions of the variables to keep and
704 /// tell if if a given variable is to be kept, according to that
705 /// set.
706 ///
707 /// @param fn the variable to consider.
708 ///
709 /// @return true iff the variable is to be kept.
710 bool
712 {
713 if (!var)
714 return false;
715
716 bool keep = true;
717
718 if (elf_symbol_sptr sym = var->get_symbol())
719 {
720 if (!sym_id_of_vars_to_keep().empty())
721 keep = false;
722 if (!keep)
723 {
724 for (vector<string>::const_iterator i =
725 sym_id_of_vars_to_keep().begin();
726 i != sym_id_of_vars_to_keep().end();
727 ++i)
728 {
729 string sym_name, sym_version;
731 sym_name,
732 sym_version));
733 if (sym_name == sym->get_name()
734 && sym_version == sym->get_version().str())
735 {
736 keep = true;
737 break;
738 }
739 }
740 }
741 }
742 else
743 keep = false;
744
745 return keep;
746 }
747
748 /// Look at the set of variables to suppress from the exported
749 /// variables set and tell if if a given variable is to be kept,
750 /// according to that set.
751 ///
752 /// @param fn the variable to consider.
753 ///
754 /// @return true iff the variable is to be kept.
755 bool
757 {
758 if (!var)
759 return false;
760
761 string frep = var->get_qualified_name();
762 bool keep = true;
763
764 for (regex_t_sptrs_type::const_iterator i =
766 i != compiled_regex_vars_suppress().end();
767 ++i)
768 if (regex::match(*i, frep))
769 {
770 keep = false;
771 break;
772 }
773
774 return keep;
775 }
776
777 /// Look at the regular expressions of the variables to keep and
778 /// tell if if a given variable is to be kept, according to that
779 /// set.
780 ///
781 /// @param fn the variable to consider.
782 ///
783 /// @return true iff the variable is to be kept.
784 bool
786 {
787 if (!var)
788 return false;
789
790 string frep = var->get_qualified_name();
791 bool keep = true;
792
793 if (!compiled_regex_vars_keep().empty())
794 keep = false;
795
796 if (!keep)
797 {
798 for (regex_t_sptrs_type::const_iterator i =
799 compiled_regex_vars_keep().begin();
800 i != compiled_regex_vars_keep().end();
801 ++i)
802 if (regex::match(*i, frep))
803 {
804 keep = true;
805 break;
806 }
807 }
808
809 return keep;
810 }
811}; // end struct corpus::exported_decls_builder::priv
812
813
814/// The private data of the @ref corpus type.
816{
817 mutable unordered_map<string, type_base_sptr> canonical_types_;
818 string format_major_version_number_;
819 string format_minor_version_number_;
820 const environment& env;
821 corpus_group* group;
823 corpus::origin origin_;
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;
830 string path;
831 vector<string> needed;
832 string soname;
833 string architecture_name;
834 translation_units members;
835 string_tu_map_type path_tu_map;
836 vector<const function_decl*> fns;
837 vector<var_decl_sptr> vars;
838 functions_set undefined_fns;
839 functions sorted_undefined_fns;
840 variables_set undefined_vars;
841 variables sorted_undefined_vars;
843 // The type maps contained in this data member are populated if the
844 // corpus follows the One Definition Rule and thus if there is only
845 // one copy of a type with a given name, per corpus. Otherwise, if
846 // there can be several *different* types with the same name, then
847 // the type maps are all empty. The types are then maintained in
848 // type maps that are in each translation units.
849 //
850 // In other words, to lookup a given type, if the corpus allows the
851 // One Definition Rule, then lookup can be done by looking into this
852 // data member. Otherwise, the lookup must be made by looking into
853 // the type maps of each translation unit.
854 type_maps types_;
855 type_maps type_per_loc_map_;
856 mutable vector<type_base_wptr> types_not_reachable_from_pub_ifaces_;
857 unordered_set<interned_string, hash_interned_string> *pub_type_pretty_reprs_;
858 bool do_log;
859
860private:
861 priv();
862
863 mutable abg_compat::optional<elf_symbols> sorted_var_symbols;
865 mutable abg_compat::optional<elf_symbols> sorted_undefined_var_symbols;
866 mutable abg_compat::optional<string_elf_symbols_map_type> undefined_var_symbol_map;
867 mutable abg_compat::optional<elf_symbols> unrefed_var_symbols;
868 mutable abg_compat::optional<elf_symbols> sorted_fun_symbols;
870 mutable abg_compat::optional<elf_symbols> sorted_undefined_fun_symbols;
871 mutable abg_compat::optional<string_elf_symbols_map_type> undefined_fun_symbol_map;
872 mutable abg_compat::optional<elf_symbols> unrefed_fun_symbols;
873
874public:
875 priv(const string & p,
876 const environment& e)
877 : env(e),
878 group(),
879 origin_(ARTIFICIAL_ORIGIN),
880 path(p),
881 pub_type_pretty_reprs_(),
882 do_log()
883 {}
884
885 type_maps&
886 get_types();
887
888 const type_maps&
889 get_types() const;
890
891 const elf_symbols&
893
895 get_fun_symbol_map() const;
896
897 const elf_symbols&
899
902
903 const elf_symbols&
905
906 const elf_symbols&
908
910 get_var_symbol_map() const;
911
912 const elf_symbols&
914
917
918 const elf_symbols&
920
921 unordered_set<interned_string, hash_interned_string>*
923
924 std::unordered_set<function_decl*>*
926
927 ~priv();
928}; // end struct corpus::priv
929
930void
931maybe_update_scope_lookup_map(const scope_decl_sptr& member_scope);
932
933void
934maybe_update_scope_lookup_map(const decl_base_sptr& member_scope);
935
936void
938
939void
941
942void
943maybe_update_types_lookup_map(const union_decl_sptr& union_type);
944
945void
947
948void
950
951void
952maybe_update_types_lookup_map(const qualified_type_def_sptr& qualified_type);
953
954void
956
957void
959
960void
962
963void
966
967void
968maybe_update_types_lookup_map(const decl_base_sptr& decl);
969
970void
971maybe_update_types_lookup_map(const type_base_sptr& type);
972
973}// end namespace ir
974
975}// end namespace abigail
976
977#endif // __ABG_CORPUS_PRIV_H__
std::shared_ptr< symtab > symtab_sptr
Convenience typedef for a shared pointer to a symtab.
Definition abg-fwd.h:1671
#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:1718
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.
Simplified implementation of std::optional just enough to be used as a replacement for our purposes a...
The abstraction of an interned string.
The type of the private data of corpus::exported_decls_builder type.
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...
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,...
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.
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,...
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...
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.
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.
void add_var_to_exported(const var_decl_sptr &var)
Add a variable to 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 ...
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.
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.
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...
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...
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.
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 var_is_in_id_vars_map(const var_decl_sptr &var)
Test if a given variable is present in a set of variables.
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...
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...
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,...
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:337
Abstraction of a group of corpora.
Definition abg-corpus.h:386
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:51
std::unordered_set< const function_decl * > functions_set
Convenience typedef for std::unordered_set<const function_decl*>
Definition abg-corpus.h:34
std::unordered_set< var_decl_sptr > variables_set
Convenience typedef for std::unordered_set<const var_decl*>.
Definition abg-corpus.h:40
vector< const function_decl * > functions
Convenience typedef for std::vector<abigail::ir::function_decl*>
Definition abg-corpus.h:31
shared_ptr< exported_decls_builder > exported_decls_builder_sptr
Convenience typedef for shared_ptr<exported_decls_builder>.
Definition abg-corpus.h:45
vector< string > strings_type
A convenience typedef for std::vector<string>.
Definition abg-corpus.h:28
vector< var_decl_sptr > variables
Convenience typedef for std::vector<abigail::ir::var_decl*>
Definition abg-corpus.h:37
virtual void get_qualified_name(interned_string &qualified_name, bool internal=false) const
Compute the qualified name of the decl.
Definition abg-ir.cc:4678
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:2607
This is an abstraction of the set of resources necessary to manage several aspects of the internal re...
Definition abg-ir.h:148
Abstraction for a function declaration.
Definition abg-ir.h:3117
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:22533
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:22356
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:22816
Abstraction of a function type.
Definition abg-ir.h:3372
A declaration that introduces a scope.
Definition abg-ir.h:1824
This is a type that aggregates maps of all the kinds of types that are supported by libabigail.
Definition abg-ir.h:602
Abstracts a variable declaration.
Definition abg-ir.h:3020
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:21200
shared_ptr< reference_type_def > reference_type_def_sptr
Convenience typedef for a shared pointer on a reference_type_def.
Definition abg-fwd.h:235
shared_ptr< elf_symbol > elf_symbol_sptr
A convenience typedef for a shared pointer to elf_symbol.
Definition abg-ir.h:897
shared_ptr< array_type_def > array_type_def_sptr
Convenience typedef for a shared pointer on a array_type_def.
Definition abg-fwd.h:244
std::vector< elf_symbol_sptr > elf_symbols
Convenience typedef for a vector of elf_symbol.
Definition abg-ir.h:913
shared_ptr< class_decl > class_decl_sptr
Convenience typedef for a shared pointer on a class_decl.
Definition abg-fwd.h:193
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:210
shared_ptr< typedef_decl > typedef_decl_sptr
Convenience typedef for a shared pointer on a typedef_decl.
Definition abg-fwd.h:167
shared_ptr< var_decl > var_decl_sptr
Convenience typedef for a shared pointer on a var_decl.
Definition abg-fwd.h:256
shared_ptr< scope_decl > scope_decl_sptr
Convenience typedef for a shared pointer on a scope_decl.
Definition abg-fwd.h:264
shared_ptr< pointer_type_def > pointer_type_def_sptr
Convenience typedef for a shared pointer on a pointer_type_def.
Definition abg-fwd.h:226
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:139
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:14354
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*.
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:175
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:860
shared_ptr< type_decl > type_decl_sptr
Convenience typedef for a shared pointer on a type_decl.
Definition abg-fwd.h:161
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:918
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::...
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< 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...
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:87
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.
const string_elf_symbols_map_type & get_undefined_var_symbol_map() const
Return a map from name to undefined variable symbol for this corpus.
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...
const string_elf_symbols_map_type & get_var_symbol_map() const
Return a map from name to variable symbol for this corpus.
const elf_symbols & get_sorted_fun_symbols() const
Return a sorted vector of function symbols for this corpus.
type_maps & get_types()
Get the maps that associate a name to a certain kind of type.
const elf_symbols & get_sorted_undefined_fun_symbols() const
Getter for a sorted vector of the function symbols undefined in 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.
const string_elf_symbols_map_type & get_fun_symbol_map() const
Return a map from name to function symbol for this corpus.
const elf_symbols & get_unreferenced_function_symbols() const
Return a list of symbols that are not referenced by any function of corpus::get_functions().
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 elf_symbols & get_sorted_undefined_var_symbols() const
Getter for a sorted vector of the variable symbols undefined in this corpus.
std::unordered_set< function_decl * > * lookup_functions(const interned_string &id)
Lookup the function which has a given function ID.
~priv()
Destructor of the corpus::priv type.