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 
24 namespace abigail
25 {
26 
27 namespace sptr_utils
28 {
29 }// end namespace sptr_utils
30 
31 namespace ir
32 {
33 
35 
36 /// A convenience typedef for std::vector<regex_t_sptr>.
37 typedef 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*
43 typedef 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*
47 typedef 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*
52 typedef 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*.
58 typedef 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*.
62 typedef unordered_map<interned_string,
63  var_decl*,
65 
66 /// The type of the private data of @ref
67 /// corpus::exported_decls_builder type.
69 {
70  friend class corpus::exported_decls_builder;
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 
98 public:
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.
122  regex_t_sptrs_type&
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.
144  regex_t_sptrs_type&
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.
166  regex_t_sptrs_type&
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.
188  regex_t_sptrs_type&
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.
219  const istr_fn_ptr_set_map_type&
220  id_fns_map() const
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.
232  istr_fn_ptr_set_map_type&
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.
245  const istr_var_ptr_map_type&
246  id_var_map() const
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.
258  istr_var_ptr_map_type&
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.
267  interned_string
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.
276  interned_string
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*>*
290  fn_id_is_in_id_fns_map(const interned_string& fn_id)
291  {
292  istr_fn_ptr_set_map_type& m = id_fns_map();
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
440  var_id_is_in_id_var_map(const interned_string& var_id) const
441  {
442  const istr_var_ptr_map_type& m = id_var_map();
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
452  add_var_to_map(var_decl* var)
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
478  add_var_to_exported(const var_decl* var)
479  {
480  const interned_string& id = get_id(*var);
481  if (!var_id_is_in_id_var_map(id))
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 =
567  compiled_regex_fns_suppress().begin();
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
620  keep_wrt_id_of_vars_to_keep(const var_decl* var)
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
694  keep_wrt_regex_of_vars_to_keep(const var_decl *var)
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;
747  functions_set undefined_fns;
748  functions sorted_undefined_fns;
749  variables_set undefined_vars;
750  variables sorted_undefined_vars;
751  symtab_reader::symtab_sptr symtab_;
752  // The type maps contained in this data member are populated if the
753  // corpus follows the One Definition Rule and thus if there is only
754  // one copy of a type with a given name, per corpus. Otherwise, if
755  // there can be several *different* types with the same name, then
756  // the type maps are all empty. The types are then maintained in
757  // type maps that are in each translation units.
758  //
759  // In other words, to lookup a given type, if the corpus allows the
760  // One Definition Rule, then lookup can be done by looking into this
761  // data member. Otherwise, the lookup must be made by looking into
762  // the type maps of each translation unit.
763  type_maps types_;
764  type_maps type_per_loc_map_;
765  mutable vector<type_base_wptr> types_not_reachable_from_pub_ifaces_;
766  unordered_set<interned_string, hash_interned_string> *pub_type_pretty_reprs_;
767  bool do_log;
768 
769 private:
770  priv();
771 
772  mutable abg_compat::optional<elf_symbols> sorted_var_symbols;
774  mutable abg_compat::optional<elf_symbols> sorted_undefined_var_symbols;
775  mutable abg_compat::optional<string_elf_symbols_map_type> undefined_var_symbol_map;
776  mutable abg_compat::optional<elf_symbols> unrefed_var_symbols;
777  mutable abg_compat::optional<elf_symbols> sorted_fun_symbols;
779  mutable abg_compat::optional<elf_symbols> sorted_undefined_fun_symbols;
780  mutable abg_compat::optional<string_elf_symbols_map_type> undefined_fun_symbol_map;
781  mutable abg_compat::optional<elf_symbols> unrefed_fun_symbols;
782 
783 public:
784  priv(const string & p,
785  const environment& e)
786  : env(e),
787  group(),
788  origin_(ARTIFICIAL_ORIGIN),
789  path(p),
790  pub_type_pretty_reprs_(),
791  do_log()
792  {}
793 
794  type_maps&
795  get_types();
796 
797  const type_maps&
798  get_types() const;
799 
800  const elf_symbols&
801  get_sorted_fun_symbols() const;
802 
804  get_fun_symbol_map() const;
805 
806  const elf_symbols&
808 
811 
812  const elf_symbols&
814 
815  const elf_symbols&
816  get_sorted_var_symbols() const;
817 
819  get_var_symbol_map() const;
820 
821  const elf_symbols&
823 
826 
827  const elf_symbols&
829 
830  unordered_set<interned_string, hash_interned_string>*
832 
833  std::unordered_set<function_decl*>*
834  lookup_functions(const interned_string& id);
835 
836  ~priv();
837 }; // end struct corpus::priv
838 
839 void
840 maybe_update_scope_lookup_map(const scope_decl_sptr& member_scope);
841 
842 void
843 maybe_update_scope_lookup_map(const decl_base_sptr& member_scope);
844 
845 void
847 
848 void
850 
851 void
852 maybe_update_types_lookup_map(const union_decl_sptr& union_type);
853 
854 void
856 
857 void
859 
860 void
861 maybe_update_types_lookup_map(const qualified_type_def_sptr& qualified_type);
862 
863 void
865 
866 void
868 
869 void
871 
872 void
875 
876 void
877 maybe_update_types_lookup_map(const decl_base_sptr& decl);
878 
879 void
880 maybe_update_types_lookup_map(const type_base_sptr& type);
881 
882 }// end namespace ir
883 
884 }// end namespace abigail
885 
886 #endif // __ABG_CORPUS_PRIV_H__
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*...
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...
type_maps & get_types()
Get the maps that associate a name to a certain kind of type.
Definition: abg-corpus.cc:333
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...
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...
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:636
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
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...
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::...
Utilities to ease the wrapping of C types into std::shared_ptr.
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:22612
shared_ptr< function_type > function_type_sptr
Convenience typedef for a shared pointer on a function_type.
Definition: abg-fwd.h:209
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.
Definition: abg-regex.cc:111
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:441
std::unordered_set< const var_decl * > variables_set
Convenience typedef for std::unordered_set.
Definition: abg-corpus.h:40
This is the abstraction of a set of translation units (themselves seen as bundles of unitary abi arte...
Definition: abg-corpus.h:24
A declaration that introduces a scope.
Definition: abg-ir.h:1808
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...
Definition: abg-ir.cc:22317
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.
Definition: abg-ir.h:851
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.
Definition: abg-corpus.cc:493
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:564
shared_ptr< typedef_decl > typedef_decl_sptr
Convenience typedef for a shared pointer on a typedef_decl.
Definition: abg-fwd.h:165
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...
This contains the declarations for the symtab reader.
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:20822
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:22140
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...
Abstracts a variable declaration.
Definition: abg-ir.h:3007
std::vector< elf_symbol_sptr > elf_symbols
Convenience typedef for a vector of elf_symbol.
Definition: abg-ir.h:904
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:21036
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...
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...
Definition: abg-ir.cc:14510
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.
void add_var_to_exported(const var_decl *var)
Add a variable to the set of exported variables.
shared_ptr< scope_decl > scope_decl_sptr
Convenience typedef for a shared pointer on a scope_decl.
Definition: abg-fwd.h:262
vector< const var_decl * > variables
Convenience typedef for std::vector
Definition: abg-corpus.h:37
regex_t_sptrs_type & compiled_regex_fns_suppress()
Getter for the compiled regular expressions that designate the functions to suppress from the set of ...
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:21092
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
origin
This abstracts where the corpus comes from. That is, either it has been read from the native xml form...
Definition: abg-corpus.h:50
~priv()
Destructor of the corpus::priv type.
Definition: abg-corpus.cc:676
Abstraction for a function declaration.
Definition: abg-ir.h:3110
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.
Definition: abg-ir.cc:2664
vector< string > strings_type
A convenience typedef for std::vector.
Definition: abg-corpus.h:28
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:391
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.
Definition: abg-fwd.h:160
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...
Definition: abg-ir.h:592
This is an abstraction of the set of resources necessary to manage several aspects of the internal re...
Definition: abg-ir.h:139
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.
Definition: abg-fwd.h:233
shared_ptr< elf_symbol > elf_symbol_sptr
A convenience typedef for a shared pointer to elf_symbol.
Definition: abg-ir.h:886
const elf_symbols & get_sorted_fun_symbols() const
Return a sorted vector of function symbols for this corpus.
Definition: abg-corpus.cc:349
std::shared_ptr< regex_t > regex_t_sptr
A convenience typedef for a shared pointer of regex_t.
Definition: abg-fwd.h:88
#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:1714
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:374
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:419
Abstracts the building of the set of exported variables and functions.
Definition: abg-corpus.h:333
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().
Definition: abg-corpus.cc:586
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:519
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...
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.
Definition: abg-fwd.h:173
shared_ptr< class_decl > class_decl_sptr
Convenience typedef for a shared pointer on a class_decl.
Definition: abg-fwd.h:191
virtual void get_qualified_name(interned_string &qualified_name, bool internal=false) const
Compute the qualified name of the decl.
Definition: abg-ir.cc:5063
bool match(const regex_t_sptr &r, const std::string &str)
See if a string matches a regex.
Definition: abg-regex.cc:127
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.
Definition: abg-corpus.cc:662
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.
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.
Definition: abg-corpus.h:382
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, it tests if a given variable is present in the set of exported variables.
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.
Definition: abg-corpus.cc:536
shared_ptr< array_type_def > array_type_def_sptr
Convenience typedef for a shared pointer on a array_type_def.
Definition: abg-fwd.h:242
shared_ptr< pointer_type_def > pointer_type_def_sptr
Convenience typedef for a shared pointer on a pointer_type_def.
Definition: abg-fwd.h:224
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
Definition: abg-corpus.h:34
Abstraction of a function type.
Definition: abg-ir.h:3389
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...
vector< const function_decl * > functions
Convenience typedef for std::vector
Definition: abg-corpus.h:31
shared_ptr< exported_decls_builder > exported_decls_builder_sptr
Convenience typedef for shared_ptr.
Definition: abg-corpus.h:42