libabigail
abg-comparison-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) 2017-2025 Red Hat, Inc.
5 //
6 // Author: Dodji Seketeli
7 
8 /// @file
9 ///
10 /// The private data and functions of the @ref abigail::ir::comparison types.
11 ///
12 /// Interfaces declared/defined in this file are to be used by parts
13 /// of libabigail but *NOT* by clients of libabigail.
14 ///
15 
16 #ifndef __ABG_COMPARISON_PRIV_H__
17 #define __ABG_COMPARISON_PRIV_H__
18 
19 #include "abg-internal.h"
20 // <headers defining libabigail's API go under here>
21 #include <memory>
22 #include <unordered_set>
23 ABG_BEGIN_EXPORT_DECLARATIONS
24 
25 #include "abg-hash.h"
26 #include "abg-suppression.h"
27 #include "abg-comparison.h"
28 #include "abg-comp-filter.h"
29 #include "abg-sptr-utils.h"
30 #include "abg-tools-utils.h"
31 
33 // </headers defining libabigail's API>
34 
35 namespace abigail
36 {
37 
38 namespace comparison
39 {
40 
41 using std::unordered_set;
42 using namespace abigail::suppr;
43 
44 // Inject types from outside in here.
45 using std::vector;
46 using std::dynamic_pointer_cast;
47 using std::static_pointer_cast;
49 
50 /// Convenience typedef for a pair of decls or types.
51 typedef std::pair<const type_or_decl_base_sptr,
52  const type_or_decl_base_sptr> types_or_decls_type;
53 
54 /// A hashing functor for @ref types_or_decls_type.
56 {
57  size_t
58  operator()(const types_or_decls_type& d) const
59  {
60  size_t h1 = hash_type_or_decl(d.first);
61  size_t h2 = hash_type_or_decl(d.second);
62  return *hashing::combine_hashes(hash_t(h1), hash_t(h2));
63  }
64 };
65 
66 /// An equality functor for @ref types_or_decls_type.
68 {
69  bool
70  operator()(const types_or_decls_type &d1, const types_or_decls_type &d2) const
71  {return d1.first == d2.first && d1.second == d2.second;}
72 };
73 
74 /// A convenience typedef for a map of @ref types_or_decls_type and
75 /// diff_sptr.
76 typedef unordered_map<types_or_decls_type, diff_sptr,
79 
80 /// A hashing functor for using @ref diff_sptr and @ref diff* in a
81 /// hash map or set.
82 struct diff_hash
83 {
84  /// The function-call operator to hash a @ref diff node.
85  ///
86  /// @param d the @ref diff node to hash.
87  ///
88  /// @return the hash value of @p d.
89  size_t
90  operator()(const diff_sptr& d) const
91  {return operator()(*d);}
92 
93  /// The function-call operator to hash a @ref diff node.
94  ///
95  /// @param d the @ref diff node to hash.
96  ///
97  /// @return the hash value of @p d.
98  size_t
99  operator()(const diff *d) const
100  {return operator()(*d);}
101 
102  /// The function-call operator to hash a @ref diff node.
103  ///
104  /// @param d the @ref diff node to hash.
105  ///
106  /// @return the hash value of @p d.
107  size_t
108  operator()(const diff& d) const
109  {
110  diff* canonical_diff = d.get_canonical_diff();
111  ABG_ASSERT(canonical_diff);
112  return reinterpret_cast<size_t>(canonical_diff);
113  }
114 }; // end struct diff_hash
115 
116 /// A comparison functor for using @ref diff_sptr and @ref diff* in a
117 /// hash map or set.
119 {
120  /// The function-call operator to compare two @ref diff nodes.
121  ///
122  /// @param d1 the first diff node involved in the comparison.
123  ///
124  /// @param d2 the second diff node involved in the comparison.
125  ///
126  /// @return true iff @p d1 equals @p d2.
127  bool
128  operator()(const diff* d1, const diff* d2) const
129  {return operator()(*d1, *d2);}
130 
131  /// The function-call operator to compare two @ref diff nodes.
132  ///
133  /// @param d1 the first diff node involved in the comparison.
134  ///
135  /// @param d2 the second diff node involved in the comparison.
136  ///
137  /// @return true iff @p d1 equals @p d2.
138  bool
139  operator()(const diff_sptr& d1, const diff_sptr& d2) const
140  {return operator()(*d1, *d2);}
141 
142  /// The function-call operator to compare two @ref diff nodes.
143  ///
144  /// @param d1 the first diff node involved in the comparison.
145  ///
146  /// @param d2 the second diff node involved in the comparison.
147  ///
148  /// @return true iff @p d1 equals @p d2.
149  bool
150  operator()(const diff& d1, const diff& d2) const
151  {
152  diff* canonical_diff1 = d1.get_canonical_diff();
153  ABG_ASSERT(canonical_diff1);
154 
155  diff *canonical_diff2 = d2.get_canonical_diff();
156  ABG_ASSERT(canonical_diff2);
157 
158  return canonical_diff1 == canonical_diff2;
159  }
160 }; // end struct diff_equal
161 
162 /// A convenience typedef for an unordered_map which key is a @ref
163 /// diff* and which value is a @ref artifact_sptr_set_type.
164 typedef unordered_map<const diff*, artifact_sptr_set_type,
167 
168 /// The private member (pimpl) for @ref diff_context.
170 {
171  diff_category allowed_category_;
172  reporter_base_sptr reporter_;
173  types_or_decls_diff_map_type types_or_decls_diff_map;
174  unordered_diff_sptr_set live_diffs_;
175  vector<diff_sptr> canonical_diffs;
176  vector<filtering::filter_base_sptr> filters_;
177  // All the suppressions specifications are stored in this data
178  // member.
179  suppressions_type suppressions_;
180  // The negated suppressions specifications that are in
181  // suppressions_ are stored here. Each time suppressions_ is
182  // modified, this data member should be cleared.
183  suppressions_type negated_suppressions_;
184  // The non-negated suppressions specifications that are in
185  // suppressions_ are stored here. Each time suppressions_ is
186  // modified, this data member should be cleared.
187  suppressions_type direct_suppressions_;
188  pointer_map visited_diff_nodes_;
189  corpus_diff_sptr corpus_diff_;
190  ostream* default_output_stream_;
191  ostream* error_output_stream_;
192  bool perform_change_categorization_;
193  bool leaf_changes_only_;
194  bool forbid_visiting_a_node_twice_;
195  bool reset_visited_diffs_for_each_interface_;
196  bool hex_values_;
197  bool show_offsets_sizes_in_bits_;
198  bool show_relative_offset_changes_;
199  bool show_stats_only_;
200  bool show_soname_change_;
201  bool show_architecture_change_;
202  bool show_deleted_fns_;
203  bool show_changed_fns_;
204  bool show_added_fns_;
205  bool show_deleted_vars_;
206  bool show_changed_vars_;
207  bool show_added_vars_;
208  bool show_linkage_names_;
209  bool show_locs_;
210  bool show_redundant_changes_;
211  bool show_syms_unreferenced_by_di_;
212  bool show_added_syms_unreferenced_by_di_;
213  bool show_unreachable_types_;
214  bool show_impacted_interfaces_;
215  bool dump_diff_tree_;
216  bool do_log_;
217 
218  priv()
219  : allowed_category_(EVERYTHING_CATEGORY),
220  reporter_(),
221  default_output_stream_(),
222  error_output_stream_(),
223  perform_change_categorization_(true),
224  leaf_changes_only_(),
225  forbid_visiting_a_node_twice_(true),
226  reset_visited_diffs_for_each_interface_(),
227  hex_values_(),
228  show_offsets_sizes_in_bits_(true),
229  show_relative_offset_changes_(true),
230  show_stats_only_(false),
231  show_soname_change_(true),
232  show_architecture_change_(true),
233  show_deleted_fns_(true),
234  show_changed_fns_(true),
235  show_added_fns_(true),
236  show_deleted_vars_(true),
237  show_changed_vars_(true),
238  show_added_vars_(true),
239  show_linkage_names_(false),
240  show_locs_(true),
241  show_redundant_changes_(true),
242  show_syms_unreferenced_by_di_(true),
243  show_added_syms_unreferenced_by_di_(true),
244  show_unreachable_types_(false),
245  show_impacted_interfaces_(true),
246  dump_diff_tree_(),
247  do_log_()
248  {}
249 };// end struct diff_context::priv
250 
252 {
253 public:
254  friend class type_diff_base;
255 }; // end class type_diff_base
256 
257 /// Private data for the @ref diff type. The details of generic view
258 /// of the diff node are expressed here.
260 {
261  bool finished_;
262  bool traversing_;
263  type_or_decl_base_sptr first_subject_;
264  type_or_decl_base_sptr second_subject_;
265  vector<diff*> children_;
266  diff* parent_;
267  diff* parent_interface_;
268  diff* canonical_diff_;
269  diff_context_wptr ctxt_;
270  diff_category local_category_;
271  diff_category category_;
272  mutable bool reported_once_;
273  mutable bool currently_reporting_;
274  mutable string pretty_representation_;
275 
276  priv();
277 
278 public:
279 
280  priv(type_or_decl_base_sptr first_subject,
281  type_or_decl_base_sptr second_subject,
282  diff_context_sptr ctxt,
283  diff_category category,
284  bool reported_once,
285  bool currently_reporting)
286  : finished_(),
287  traversing_(),
288  first_subject_(first_subject),
289  second_subject_(second_subject),
290  parent_(),
291  parent_interface_(),
292  canonical_diff_(),
293  ctxt_(ctxt),
294  local_category_(category),
295  category_(category),
296  reported_once_(reported_once),
297  currently_reporting_(currently_reporting)
298  {}
299 
300  /// Getter of the diff context associated with this diff.
301  ///
302  /// @returnt a smart pointer to the diff context.
304  get_context() const
305  {return ctxt_.lock();}
306 
307  /// Check if a given categorization of a diff node should make it be
308  /// filtered out.
309  ///
310  /// @param category the categorization to take into account.
311  bool
313  {
314  diff_context_sptr ctxt = get_context();
315  if (!ctxt)
316  return false;
317 
318  if (ctxt->get_allowed_category() == EVERYTHING_CATEGORY)
319  return false;
320 
321  // If this node is on the path of a node that *must* be reported,
322  // then do not filter it.
326  return false;
327 
328  /// We don't want to display nodes suppressed by a user-provided
329  /// suppression specification or by a "private type" suppression
330  /// specification.
331  if (category & (SUPPRESSED_CATEGORY | PRIVATE_TYPE_CATEGORY))
332  return true;
333 
334  // We don't want to display redundant diff nodes, when the user
335  // asked to avoid seeing redundant diff nodes.
336  if (!ctxt->show_redundant_changes()
337  && (category & REDUNDANT_CATEGORY))
338  return true;
339 
340  if (category == NO_CHANGE_CATEGORY)
341  return false;
342 
343  // Ignore the REDUNDANT_CATEGORY bit when comparing allowed
344  // categories and the current set of categories.
345  return !((category & ~REDUNDANT_CATEGORY)
346  & (ctxt->get_allowed_category()
347  & ~REDUNDANT_CATEGORY));
348  }
349 };// end class diff::priv
350 
351 /// A functor to compare two instances of @ref diff_sptr.
353 {
354  /// An operator that takes two instances of @ref diff_sptr returns
355  /// true if its first operand compares less than its second operand.
356  ///
357  /// @param l the first operand to consider.
358  ///
359  /// @param r the second operand to consider.
360  ///
361  /// @return true if @p l compares less than @p r.
362  bool
363  operator()(const diff* l, const diff* r) const
364  {
365  if (!l || !r || !l->first_subject() || !r->first_subject())
366  return false;
367 
368  string l_qn = get_name(l->first_subject());
369  string r_qn = get_name(r->first_subject());
370 
371  return l_qn < r_qn;
372  }
373 
374  /// An operator that takes two instances of @ref diff_sptr returns
375  /// true if its first operand compares less than its second operand.
376  ///
377  /// @param l the first operand to consider.
378  ///
379  /// @param r the second operand to consider.
380  ///
381  /// @return true if @p l compares less than @p r.
382  bool
383  operator()(const diff_sptr& l, const diff_sptr& r) const
384  {return operator()(l.get(), r.get());}
385 }; // end struct diff_less_than_functor
386 
388 {
389 public:
390  friend class decl_diff_base;
391 };//end class priv
392 
393 /// The private data structure for @ref distinct_diff.
395 {
396  diff_sptr compatible_child_diff;
397 };// end struct distinct_diff
398 
399 /// The internal type for the impl idiom implementation of @ref
400 /// var_diff.
402 {
403  diff_wptr type_diff_;
404 };//end struct var_diff
405 
406 /// The internal type for the impl idiom implementation of @ref
407 /// pointer_diff.
409 {
410  diff_sptr underlying_type_diff_;
411 
412  priv(diff_sptr ud)
413  : underlying_type_diff_(ud)
414  {}
415 };//end struct pointer_diff::priv
416 
417 /// The internal type for the impl idiom implementation of @ref
418 /// subrange_diff.
420 {
421  diff_sptr underlying_type_diff_;
422 
423  priv(diff_sptr u)
424  : underlying_type_diff_(u)
425  {}
426 }; // end struct subrange_diff::priv
427 
429 {
430  /// The diff between the two array element types.
432  vector<subrange_diff_sptr> subrange_diffs_;
433 
434  priv(diff_sptr element_type_diff,
435  vector<subrange_diff_sptr>& subrange_diffs)
436  : element_type_diff_(element_type_diff),
437  subrange_diffs_(subrange_diffs)
438  {}
439 };//end struct array_diff::priv
440 
442 {
443  diff_sptr underlying_type_diff_;
444  priv(diff_sptr underlying)
445  : underlying_type_diff_(underlying)
446  {}
447 };//end struct reference_diff::priv
448 
449 /// The private data of the @ref ptr_to_mbr_diff type.
451 {
452  diff_sptr member_type_diff_;
453  diff_sptr containing_type_diff_;
454 
455  priv(const diff_sptr& member_type_diff,
456  const diff_sptr& containing_type_diff)
457  : member_type_diff_(member_type_diff),
458  containing_type_diff_(containing_type_diff)
459  {}
460 };//end ptr_to_mbr_diff::priv
461 
463 {
464  diff_sptr underlying_type_diff;
465  mutable diff_sptr leaf_underlying_type_diff;
466 
467  priv(diff_sptr underlying)
468  : underlying_type_diff(underlying)
469  {}
470 };// end struct qualified_type_diff::priv
471 
473 {
474  diff_sptr underlying_type_diff_;
475  edit_script enumerators_changes_;
476  string_enumerator_map deleted_enumerators_;
477  string_enumerator_map inserted_enumerators_;
478  string_changed_enumerator_map changed_enumerators_;
479 
480  priv(diff_sptr underlying)
481  : underlying_type_diff_(underlying)
482  {}
483 };//end struct enum_diff::priv
484 
485 /// A functor to compare two enumerators based on their value. This
486 /// implements the "less than" operator.
488 {
489  bool
490  operator()(const enum_type_decl::enumerator& f,
491  const enum_type_decl::enumerator& s) const
492  {return f.get_value() < s.get_value();}
493 };//end struct enumerator_value_comp
494 
495 /// A functor to compare two changed enumerators, based on their
496 /// initial value.
498 {
499  bool
500  operator()(const changed_enumerator& f,
501  const changed_enumerator& s) const
502  {return f.first.get_value() < s.first.get_value();}
503 };// end struct changed_enumerator_comp.
504 
505 /// The type of private data of @ref class_or_union_diff.
507 {
508  edit_script member_types_changes_;
509  edit_script data_members_changes_;
510  edit_script member_fns_changes_;
511  edit_script member_fn_tmpls_changes_;
512  edit_script member_class_tmpls_changes_;
513 
514  string_decl_base_sptr_map deleted_member_types_;
515  string_decl_base_sptr_map inserted_member_types_;
516  string_diff_sptr_map changed_member_types_;
517  diff_sptrs_type sorted_changed_member_types_;
518  string_decl_base_sptr_map deleted_data_members_;
519  unsigned_decl_base_sptr_map deleted_dm_by_offset_;
520  string_decl_base_sptr_map inserted_data_members_;
521  unsigned_decl_base_sptr_map inserted_dm_by_offset_;
522  // This map contains the data member which sub-type changed.
523  string_var_diff_sptr_map subtype_changed_dm_;
524  var_diff_sptrs_type sorted_subtype_changed_dm_;
525  // This one contains the list of data members changes that can be
526  // represented as a data member foo that got removed from offset N,
527  // and a data member bar that got inserted at offset N; IOW, this
528  // can be translated as data member foo that got changed into data
529  // member bar at offset N.
530  unsigned_var_diff_sptr_map changed_dm_;
531  var_diff_sptrs_type sorted_changed_dm_;
532 
533  // This is a data structure to represent data members that have been
534  // replaced by anonymous data members. It's a map that associates
535  // the name of the data member to the anonymous data member that
536  // replaced it.
537  string_decl_base_sptr_map dms_replaced_by_adms_;
538  mutable changed_var_sptrs_type dms_replaced_by_adms_ordered_;
539  string_member_function_sptr_map deleted_member_functions_;
540  class_or_union::member_functions sorted_deleted_member_functions_;
541  string_member_function_sptr_map inserted_member_functions_;
542  class_or_union::member_functions sorted_inserted_member_functions_;
543  string_function_decl_diff_sptr_map changed_member_functions_;
544  function_decl_diff_sptrs_type sorted_changed_member_functions_;
545  string_decl_base_sptr_map deleted_member_class_tmpls_;
546  string_decl_base_sptr_map inserted_member_class_tmpls_;
547  string_diff_sptr_map changed_member_class_tmpls_;
548  diff_sptrs_type sorted_changed_member_class_tmpls_;
549 
550  type_or_decl_base_sptr
551  member_type_has_changed(decl_base_sptr) const;
552 
553  decl_base_sptr
554  subtype_changed_dm(decl_base_sptr) const;
555 
556  decl_base_sptr
557  member_class_tmpl_has_changed(decl_base_sptr) const;
558 
559  size_t
560  get_deleted_non_static_data_members_number() const;
561 
562  size_t
563  get_inserted_non_static_data_members_number() const;
564 
565  size_t
566  count_filtered_subtype_changed_dm(bool local_only = false);
567 
568  size_t
569  count_filtered_changed_dm(bool local_only = false);
570 
571  size_t
572  count_filtered_changed_mem_fns(const diff_context_sptr&);
573 
574  size_t
575  count_filtered_inserted_mem_fns(const diff_context_sptr&);
576 
577  size_t
578  count_filtered_deleted_mem_fns(const diff_context_sptr&);
579 
580  priv()
581  {}
582 }; // end struct class_or_union_diff::priv
583 
584 /// A comparison functor to compare two data members based on their
585 /// offset.
587 {
588 
589  /// Compare two data members.
590  ///
591  /// First look at their offset and then their name.
592  ///
593  /// @parm first_dm the first data member to consider.
594  ///
595  /// @param second_dm the second data member to consider.
596  bool
598  const var_decl_sptr& second_dm) const
599  {
600  ABG_ASSERT(first_dm);
601  ABG_ASSERT(second_dm);
602 
603  size_t first_offset = get_data_member_offset(first_dm);
604  size_t second_offset = get_data_member_offset(second_dm);
605 
606  // The data member at the smallest offset comes first.
607  if (first_offset != second_offset)
608  return first_offset < second_offset;
609 
610  string first_dm_name = first_dm->get_name();
611  string second_dm_name = second_dm->get_name();
612 
613  // But in case the two data members are at the same offset, then
614  // sort them lexicographically.
615  return first_dm_name < second_dm_name;
616  }
617 
618  /// Compare two data members.
619  ///
620  /// First look at their offset and then their name.
621  ///
622  /// @parm first_dm the first data member to consider.
623  ///
624  /// @param second_dm the second data member to consider.
625  bool
626  operator()(const decl_base_sptr& f,
627  const decl_base_sptr& s) const
628  {
629  var_decl_sptr first_dm = is_data_member(f);
630  var_decl_sptr second_dm = is_data_member(s);
631 
632  return compare_data_members(first_dm, second_dm);
633  }
634 
635  /// Compare two data members.
636  ///
637  /// First look at their offset and then their name.
638  ///
639  /// @parm first_dm the first data member to consider.
640  ///
641  /// @param second_dm the second data member to consider.
642  bool
644  const changed_var_sptr& s) const
645  {
646  var_decl_sptr first_dm = is_data_member(is_decl(f.first));
647  var_decl_sptr second_dm = is_data_member(is_decl(s.first));
648 
649  return compare_data_members(first_dm, second_dm);
650  }
651 };//end struct data_member_comp
652 
653 /// The type of the private data (pimpl sub-object) of the @ref
654 /// class_diff type.
656 {
657  edit_script base_changes_;
658  string_base_sptr_map deleted_bases_;
659  class_decl::base_specs sorted_deleted_bases_;
660  string_base_sptr_map inserted_bases_;
661  class_decl::base_specs sorted_inserted_bases_;
662  string_base_diff_sptr_map changed_bases_;
663  base_diff_sptrs_type sorted_changed_bases_;
664  vector<class_decl::base_spec_sptr> moved_bases_;
665 
667  base_has_changed(class_decl::base_spec_sptr) const;
668 
669  size_t
670  count_filtered_bases();
671 
672  priv()
673  {}
674 };//end struct class_diff::priv
675 
676 /// A functor to compare instances of @ref class_decl::base_spec.
678 {
679  bool
680  operator()(const class_decl::base_spec&l,
681  const class_decl::base_spec&r)
682  {
683  string str1 = l.get_pretty_representation();
684  string str2 = r.get_pretty_representation();
685  return str1 < str2;
686  }
687  bool
688  operator()(const class_decl::base_spec_sptr&l,
690  {return operator()(*l, *r);}
691 }; // end base_spec_comp
692 
693 /// A comparison function for instances of @ref base_diff.
695 {
696  bool
697  operator()(const base_diff& l, const base_diff& r) const
698  {
700  if (f->get_offset_in_bits() >= 0
701  && s->get_offset_in_bits() >= 0)
702  return f->get_offset_in_bits() < s->get_offset_in_bits();
703  else
704  return (f->get_base_class()->get_pretty_representation()
705  < s->get_base_class()->get_pretty_representation());
706  }
707 
708  bool
709  operator()(const base_diff* l, const base_diff* r) const
710  {return operator()(*l, *r);}
711 
712  bool
713  operator()(const base_diff_sptr l, const base_diff_sptr r) const
714  {return operator()(l.get(), r.get());}
715 }; // end struct base_diff_comp
716 
717 bool
718 is_less_than(const decl_diff_base& first, const decl_diff_base& second);
719 
720 bool
721 is_less_than(const decl_diff_base_sptr& first,
722  const decl_diff_base_sptr& second);
723 
724 /// A comparison functor to compare two instances of @ref var_diff
725 /// that represent changed data members based on the offset of the
726 /// initial data members, or if equal, based on their qualified name.
727 /// If equal again, then the offset and qualified name of the new data
728 /// members are considered.
730 {
731  /// @param f the first change to data member to take into account
732  ///
733  /// @param s the second change to data member to take into account.
734  ///
735  /// @return true iff f is before s.
736  bool
738  const var_diff_sptr s) const
739  {
740  var_decl_sptr first_dm = f->first_var();
741  var_decl_sptr second_dm = s->first_var();
742 
743  ABG_ASSERT(is_data_member(first_dm));
744  ABG_ASSERT(is_data_member(second_dm));
745 
746  size_t off1 = get_data_member_offset(first_dm);
747  size_t off2 = get_data_member_offset(second_dm);
748 
749  if (off1 != off2)
750  return off1 < off2;
751 
752  // The two offsets of the initial data members are the same. So
753  // lets compare the qualified name of these initial data members.
754 
755  string name1 = first_dm->get_qualified_name();
756  string name2 = second_dm->get_qualified_name();
757 
758  if (name1 != name2)
759  return name1 < name2;
760 
761  // The offsets and the qualified names of the initial data members
762  // are the same. Let's now compare the offsets of the *new* data
763  // members.
764 
765  first_dm = f->second_var();
766  second_dm = s->second_var();
767 
768  ABG_ASSERT(is_data_member(first_dm));
769  ABG_ASSERT(is_data_member(second_dm));
770 
771  off1 = get_data_member_offset(first_dm);
772  off2 = get_data_member_offset(second_dm);
773 
774  if (off1 != off2)
775  return off1 < off2;
776 
777  // The offsets of the new data members are the same, dang! Let's
778  // compare the qualified names of these new data members then.
779 
780  name1 = first_dm->get_qualified_name();
781  name2 = second_dm->get_qualified_name();
782 
783  return name1 < name2;
784  }
785 }; // end struct data_member_diff_comp
786 
787 /// A comparison functor for instances of @ref function_decl_diff that
788 /// represent changes between two virtual member functions.
790 {
791  bool
792  operator()(const function_decl_diff& l,
793  const function_decl_diff& r) const
794  {
797 
800  if (l_offset != r_offset)
801  return l_offset < r_offset;
802 
803  return is_less_than(l, r);
804  }
805 
806  bool
807  operator()(const function_decl_diff* l,
808  const function_decl_diff* r)
809  {return operator()(*l, *r);}
810 
811  bool
812  operator()(const function_decl_diff_sptr l,
813  const function_decl_diff_sptr r)
814  {return operator()(l.get(), r.get());}
815 }; // end struct virtual_member_function_diff_comp
816 
818 {
819  class_diff_sptr underlying_class_diff_;
820 
821  priv(class_diff_sptr underlying)
822  : underlying_class_diff_(underlying)
823  {}
824 }; // end struct base_diff::priv
825 
827 {
828  // The edit script built by the function compute_diff.
829  edit_script member_changes_;
830 
831  // Below are the useful lookup tables.
832  //
833  // If you add a new lookup table, please update member functions
834  // clear_lookup_tables, lookup_tables_empty and
835  // ensure_lookup_tables_built.
836 
837  // The deleted/inserted types/decls. These basically map what is
838  // inside the member_changes_ data member. Note that for instance,
839  // a given type T might be deleted from the first scope and added to
840  // the second scope again; this means that the type was *changed*.
841  string_decl_base_sptr_map deleted_types_;
842  string_decl_base_sptr_map deleted_decls_;
843  string_decl_base_sptr_map inserted_types_;
844  string_decl_base_sptr_map inserted_decls_;
845 
846  // The changed types/decls lookup tables.
847  //
848  // These lookup tables are populated from the lookup tables above.
849  //
850  // Note that the value stored in each of these tables is a pair
851  // containing the old decl/type and the new one. That way it is
852  // easy to run a diff between the old decl/type and the new one.
853  //
854  // A changed type/decl is one that has been deleted from the first
855  // scope and that has been inserted into the second scope.
856  string_diff_sptr_map changed_types_;
857  diff_sptrs_type sorted_changed_types_;
858  string_diff_sptr_map changed_decls_;
859  diff_sptrs_type sorted_changed_decls_;
860 
861  // The removed types/decls lookup tables.
862  //
863  // A removed type/decl is one that has been deleted from the first
864  // scope and that has *NOT* been inserted into it again.
865  string_decl_base_sptr_map removed_types_;
866  string_decl_base_sptr_map removed_decls_;
867 
868  // The added types/decls lookup tables.
869  //
870  // An added type/decl is one that has been inserted to the first
871  // scope but that has not been deleted from it.
872  string_decl_base_sptr_map added_types_;
873  string_decl_base_sptr_map added_decls_;
874 };//end struct scope_diff::priv
875 
876 /// A comparison functor for instances of @ref diff.
877 struct diff_comp
878 {
879  /// Lexicographically compare two diff nodes.
880  ///
881  /// Compare the pretty representation of the first subjects of two
882  /// diff nodes.
883  ///
884  /// @return true iff @p l is less than @p r.
885  bool
886  operator()(const diff& l, diff& r) const
887  {
889  <
891  }
892 
893  /// Lexicographically compare two diff nodes.
894  ///
895  /// Compare the pretty representation of the first subjects of two
896  /// diff nodes.
897  ///
898  /// @return true iff @p l is less than @p r.
899  bool
900  operator()(const diff* l, diff* r) const
901  {return operator()(*l, *r);}
902 
903  /// Lexicographically compare two diff nodes.
904  ///
905  /// Compare the pretty representation of the first subjects of two
906  /// diff nodes.
907  ///
908  /// @return true iff @p l is less than @p r.
909  bool
910  operator()(const diff_sptr l, diff_sptr r) const
911  {return operator()(l.get(), r.get());}
912 }; // end struct diff_comp;
913 
915 {
916  mutable diff_sptr type_diff;
917 }; // end struct fn_parm_diff::priv
918 
920 {
921  diff_sptr return_type_diff_;
922  edit_script parm_changes_;
923 
924  // useful lookup tables.
925  string_parm_map deleted_parms_;
926  vector<function_decl::parameter_sptr> sorted_deleted_parms_;
927  string_parm_map added_parms_;
928  vector<function_decl::parameter_sptr> sorted_added_parms_;
929  // This map contains parameters sub-type changes that don't change
930  // the name of the type of the parameter.
931  string_fn_parm_diff_sptr_map subtype_changed_parms_;
932  vector<fn_parm_diff_sptr> sorted_subtype_changed_parms_;
933  // This map contains parameter type changes that actually change the
934  // name of the type of the parameter, but in a compatible way;
935  // otherwise, the mangling of the function would have changed (in
936  // c++ at least).
937  unsigned_fn_parm_diff_sptr_map changed_parms_by_id_;
938  vector<fn_parm_diff_sptr> sorted_changed_parms_by_id_;
939  unsigned_parm_map deleted_parms_by_id_;
940  unsigned_parm_map added_parms_by_id_;
941 
942  priv()
943  {}
944 }; // end struct function_type_diff::priv
945 
947 {
948  function_type_diff_sptr type_diff_;
949 
950  priv()
951  {}
952 };// end struct function_decl_diff::priv
953 
954 /// A comparison functor to compare two instances of @ref fn_parm_diff
955 /// based on their indexes.
957 {
958  /// @param f the first diff
959  ///
960  /// @param s the second diff
961  ///
962  /// @return true if the index of @p f is less than the index of @p
963  /// s.
964  bool
966  {return f.first_parameter()->get_index() < s.first_parameter()->get_index();}
967 
968  bool
969  operator()(const fn_parm_diff_sptr& f, const fn_parm_diff_sptr& s)
970  {return operator()(*f, *s);}
971 }; // end struct fn_parm_diff_comp
972 
973 /// Functor that compares two function parameters for the purpose of
974 /// sorting them.
975 struct parm_comp
976 {
977  /// Returns true iff the index of the first parameter is smaller
978  /// than the of the second parameter.
979  ///
980  /// @param l the first parameter to compare.
981  ///
982  /// @param r the second parameter to compare.
983  ///
984  /// @return true iff the index of the first parameter is smaller
985  /// than the of the second parameter.
986  bool
988  const function_decl::parameter& r)
989  {return l.get_index() < r.get_index();}
990 
991  /// Returns true iff the index of the first parameter is smaller
992  /// than the of the second parameter.
993  ///
994  /// @param l the first parameter to compare.
995  ///
996  /// @param r the second parameter to compare.
997  ///
998  /// @return true iff the index of the first parameter is smaller
999  /// than the of the second parameter.
1000  bool
1003  {return operator()(*l, *r);}
1004 }; // end struct parm_comp
1005 
1006 /// A functor to compare instances of @ref var_decl base on their
1007 /// qualified names.
1008 struct var_comp
1009 {
1010  bool
1011  operator() (const var_decl& l, const var_decl& r) const
1012  {
1013  string name1 = l.get_qualified_name(), name2 = r.get_qualified_name();
1014  return name1 < name2;
1015  }
1016 
1017  bool
1018  operator() (const var_decl* l, const var_decl* r) const
1019  {return operator()(*l, *r);}
1020 
1021  bool
1022  operator() (const var_decl_sptr& l, const var_decl_sptr& r) const
1023  {return operator()(l.get(), r.get());}
1024 };// end struct var_comp
1025 
1026 /// A functor to compare instances of @ref elf_symbol base on their
1027 /// names.
1029 {
1030  bool
1031  operator()(const elf_symbol& l, const elf_symbol& r)
1032  {
1033  string name1 = l.get_id_string(), name2 = r.get_id_string();
1034  return name1 < name2;
1035  }
1036 
1037  bool
1038  operator()(const elf_symbol* l, const elf_symbol* r)
1039  {return operator()(*l, *r);}
1040 
1041  bool
1042  operator()(const elf_symbol_sptr& l, const elf_symbol_sptr& r)
1043  {return operator()(l.get(), r.get());}
1044 }; //end struct elf_symbol_comp
1045 
1047 {
1048  diff_sptr underlying_type_diff_;
1049 
1050  priv(const diff_sptr underlying_type_diff)
1051  : underlying_type_diff_(underlying_type_diff)
1052  {}
1053 };//end struct typedef_diff::priv
1054 
1056 {
1057  translation_unit_sptr first_;
1058  translation_unit_sptr second_;
1059 
1061  : first_(f), second_(s)
1062  {}
1063 };//end struct translation_unit_diff::priv
1064 
1066 {
1067  bool finished_;
1068  string pretty_representation_;
1069  vector<diff*> children_;
1070  corpus_sptr first_;
1071  corpus_sptr second_;
1072  diff_context_wptr ctxt_;
1073  corpus_diff::diff_stats_sptr diff_stats_;
1074  bool sonames_equal_;
1075  bool architectures_equal_;
1076  edit_script fns_edit_script_;
1077  edit_script vars_edit_script_;
1078  edit_script unrefed_fn_syms_edit_script_;
1079  edit_script unrefed_var_syms_edit_script_;
1080  string_function_ptr_map deleted_fns_;
1081  string_function_ptr_map suppressed_deleted_fns_;
1082  string_function_ptr_map added_fns_;
1083  string_function_ptr_map suppressed_added_fns_;
1084  string_function_decl_diff_sptr_map changed_fns_map_;
1085  function_decl_diff_sptrs_type changed_fns_;
1086  function_decl_diff_sptrs_type incompatible_changed_fns_;
1087  string_var_ptr_map deleted_vars_;
1088  string_var_ptr_map suppressed_deleted_vars_;
1089  string_var_ptr_map added_vars_;
1090  string_var_ptr_map suppressed_added_vars_;
1091  string_var_diff_sptr_map changed_vars_map_;
1092  var_diff_sptrs_type incompatible_changed_vars_;
1093  var_diff_sptrs_type sorted_changed_vars_;
1094  string_elf_symbol_map added_unrefed_fn_syms_;
1095  string_elf_symbol_map suppressed_added_unrefed_fn_syms_;
1096  string_elf_symbol_map deleted_unrefed_fn_syms_;
1097  string_elf_symbol_map suppressed_deleted_unrefed_fn_syms_;
1098  string_elf_symbol_map added_unrefed_var_syms_;
1099  string_elf_symbol_map suppressed_added_unrefed_var_syms_;
1100  string_elf_symbol_map deleted_unrefed_var_syms_;
1101  string_elf_symbol_map suppressed_deleted_unrefed_var_syms_;
1102  edit_script unreachable_types_edit_script_;
1103  string_type_base_sptr_map deleted_unreachable_types_;
1104  vector<type_base_sptr> deleted_unreachable_types_sorted_;
1105  string_type_base_sptr_map suppressed_deleted_unreachable_types_;
1106  string_type_base_sptr_map added_unreachable_types_;
1107  vector<type_base_sptr> added_unreachable_types_sorted_;
1108  string_type_base_sptr_map suppressed_added_unreachable_types_;
1109  string_diff_sptr_map changed_unreachable_types_;
1110  mutable vector<diff_sptr> changed_unreachable_types_sorted_;
1111  diff_maps leaf_diffs_;
1112 
1113  /// Default constructor of corpus_diff::priv.
1115  : finished_(false),
1116  sonames_equal_(false),
1117  architectures_equal_(false)
1118  {}
1119 
1120  /// Constructor of corpus_diff::priv.
1121  ///
1122  /// @param first the first corpus of this diff.
1123  ///
1124  /// @param second the second corpus of this diff.
1125  ///
1126  /// @param ctxt the context of the diff.
1127  priv(corpus_sptr first,
1128  corpus_sptr second,
1129  diff_context_sptr ctxt)
1130  : finished_(false),
1131  first_(first),
1132  second_(second),
1133  ctxt_(ctxt),
1134  sonames_equal_(false),
1135  architectures_equal_(false)
1136  {}
1137 
1139  get_context();
1140 
1141  bool
1142  lookup_tables_empty() const;
1143 
1144  void
1145  clear_lookup_tables();
1146 
1147  void
1148  ensure_lookup_tables_populated();
1149 
1150  void
1151  apply_supprs_to_added_removed_fns_vars_unreachable_types();
1152 
1153  bool
1154  deleted_function_is_suppressed(const function_decl* fn) const;
1155 
1156  bool
1157  added_function_is_suppressed(const function_decl* fn) const;
1158 
1159  bool
1160  deleted_variable_is_suppressed(const var_decl_sptr& var) const;
1161 
1162  bool
1163  added_variable_is_suppressed(const var_decl_sptr& var) const;
1164 
1165  bool
1166  added_unreachable_type_is_suppressed(const type_base *t)const ;
1167 
1168  bool
1169  deleted_unreachable_type_is_suppressed(const type_base *t)const ;
1170 
1171  bool
1172  deleted_unrefed_fn_sym_is_suppressed(const elf_symbol*) const;
1173 
1174  bool
1175  added_unrefed_fn_sym_is_suppressed(const elf_symbol*) const;
1176 
1177  bool
1178  deleted_unrefed_var_sym_is_suppressed(const elf_symbol*) const;
1179 
1180  bool
1181  added_unrefed_var_sym_is_suppressed(const elf_symbol*) const;
1182 
1183  void count_leaf_changes(size_t &num_changes, size_t &num_filtered);
1184 
1185  void count_leaf_type_changes(size_t &num_type_changes,
1186  size_t &num_type_changes_filtered);
1187 
1188  void count_unreachable_types(size_t &num_added,
1189  size_t &num_removed,
1190  size_t &num_changed,
1191  size_t &num_filtered_added,
1192  size_t &num_filtered_removed,
1193  size_t &num_filtered_changed);
1194 
1195  const string_diff_sptr_map&
1196  changed_unreachable_types() const;
1197 
1198  const vector<diff_sptr>&
1199  changed_unreachable_types_sorted() const;
1200 
1201  void
1202  apply_filters_and_compute_diff_stats(corpus_diff::diff_stats&);
1203 
1204  void
1205  emit_diff_stats(const diff_stats& stats,
1206  ostream& out,
1207  const string& indent);
1208 
1209  void
1210  categorize_redundant_changed_sub_nodes();
1211 
1212  void
1214 
1215  void
1216  maybe_dump_diff_tree();
1217 }; // end corpus::priv
1218 
1219 /// "Less than" functor to compare instances of @ref function_decl.
1221 {
1222  /// The actual "less than" operator for instances of @ref
1223  /// function_decl. It returns true if the first @ref function_decl
1224  /// is lest than the second one.
1225  ///
1226  /// @param f the first @ref function_decl to take in account.
1227  ///
1228  /// @param s the second @ref function_decl to take in account.
1229  ///
1230  /// @return true iff @p f is less than @p s.
1231  bool
1234 
1235  /// The actual "less than" operator for instances of @ref
1236  /// function_decl. It returns true if the first @ref function_decl
1237  /// is lest than the second one.
1238  ///
1239  /// @param f the first @ref function_decl to take in account.
1240  ///
1241  /// @param s the second @ref function_decl to take in account.
1242  ///
1243  /// @return true iff @p f is less than @p s.
1244  bool
1246  {return operator()(*f, *s);}
1247 
1248  /// The actual "less than" operator for instances of @ref
1249  /// function_decl. It returns true if the first @ref function_decl
1250  /// is lest than the second one.
1251  ///
1252  /// @param f the first @ref function_decl to take in account.
1253  ///
1254  /// @param s the second @ref function_decl to take in account.
1255  ///
1256  /// @return true iff @p f is less than @p s.
1257  bool
1259  {return operator()(f.get(), s.get());}
1260 }; // end function_comp
1261 
1262 /// A "Less Than" functor to compare instance of @ref
1263 /// function_decl_diff.
1265 {
1266  /// The actual less than operator.
1267  ///
1268  /// It returns true if the first @ref function_decl_diff is less
1269  /// than the second one.
1270  ///
1271  /// param first the first @ref function_decl_diff to consider.
1272  ///
1273  /// @param second the second @ref function_decl_diff to consider.
1274  ///
1275  /// @return true iff @p first is less than @p second.
1276  bool
1278  const function_decl_diff& second)
1279  {
1280  return is_less_than(first, second);
1281  }
1282 
1283  /// The actual less than operator.
1284  ///
1285  /// It returns true if the first @ref function_decl_diff_sptr is
1286  /// less than the second one.
1287  ///
1288  /// param first the first @ref function_decl_diff_sptr to consider.
1289  ///
1290  /// @param second the second @ref function_decl_diff_sptr to
1291  /// consider.
1292  ///
1293  /// @return true iff @p first is less than @p second.
1294  bool
1296  const function_decl_diff_sptr second)
1297  {return operator()(*first, *second);}
1298 }; // end struct function_decl_diff_comp
1299 
1300 /// Functor to sort instances of @ref var_diff_sptr
1302 {
1303  /// Return true if the first argument is less than the second one.
1304  ///
1305  /// @param f the first argument to consider.
1306  ///
1307  /// @param s the second argument to consider.
1308  ///
1309  /// @return true if @p f is less than @p s.
1310  bool
1312  {
1313  return is_less_than(f, s);
1314  }
1315 }; // end struct var_diff_sptr_comp
1316 
1317 /// The type of the private data of corpus_diff::diff_stats.
1319 {
1320  friend class corpus_diff::diff_stats;
1321 
1322  diff_context_wptr ctxt_;
1323  size_t num_func_removed;
1324  size_t num_removed_func_filtered_out;
1325  size_t num_func_added;
1326  size_t num_added_func_filtered_out;
1327  size_t num_func_changed;
1328  size_t num_changed_func_filtered_out;
1329  size_t num_func_with_virt_offset_changes;
1330  size_t num_func_with_local_harmful_changes;
1331  size_t num_func_with_incompatible_changes;
1332  size_t num_var_with_local_harmful_changes;
1333  size_t num_var_with_incompatible_changes;
1334  size_t num_vars_removed;
1335  size_t num_removed_vars_filtered_out;
1336  size_t num_vars_added;
1337  size_t num_added_vars_filtered_out;
1338  size_t num_vars_changed;
1339  size_t num_changed_vars_filtered_out;
1340  size_t num_func_syms_removed;
1341  size_t num_removed_func_syms_filtered_out;
1342  size_t num_func_syms_added;
1343  size_t num_added_func_syms_filtered_out;
1344  size_t num_var_syms_removed;
1345  size_t num_removed_var_syms_filtered_out;
1346  size_t num_var_syms_added;
1347  size_t num_added_var_syms_filtered_out;
1348  size_t num_leaf_changes;
1349  size_t num_leaf_changes_filtered_out;
1350  size_t num_leaf_type_changes;
1351  size_t num_leaf_type_changes_filtered_out;
1352  size_t num_leaf_func_changes;
1353  size_t num_leaf_func_with_incompatible_changes;
1354  size_t num_leaf_func_changes_filtered_out;
1355  size_t num_leaf_var_changes;
1356  size_t num_leaf_var_with_incompatible_changes;
1357  size_t num_leaf_var_changes_filtered_out;
1358  size_t num_added_unreachable_types;
1359  size_t num_added_unreachable_types_filtered_out;
1360  size_t num_removed_unreachable_types;
1361  size_t num_removed_unreachable_types_filtered_out;
1362  size_t num_changed_unreachable_types;
1363  size_t num_changed_unreachable_types_filtered_out;
1364 
1365  priv(diff_context_sptr ctxt)
1366  : ctxt_(ctxt),
1367  num_func_removed(),
1368  num_removed_func_filtered_out(),
1369  num_func_added(),
1370  num_added_func_filtered_out(),
1371  num_func_changed(),
1372  num_changed_func_filtered_out(),
1373  num_func_with_virt_offset_changes(),
1374  num_func_with_local_harmful_changes(),
1375  num_func_with_incompatible_changes(),
1376  num_var_with_local_harmful_changes(),
1377  num_var_with_incompatible_changes(),
1378  num_vars_removed(),
1379  num_removed_vars_filtered_out(),
1380  num_vars_added(),
1381  num_added_vars_filtered_out(),
1382  num_vars_changed(),
1383  num_changed_vars_filtered_out(),
1384  num_func_syms_removed(),
1385  num_removed_func_syms_filtered_out(),
1386  num_func_syms_added(),
1387  num_added_func_syms_filtered_out(),
1388  num_var_syms_removed(),
1389  num_removed_var_syms_filtered_out(),
1390  num_var_syms_added(),
1391  num_added_var_syms_filtered_out(),
1392  num_leaf_changes(),
1393  num_leaf_changes_filtered_out(),
1394  num_leaf_type_changes(),
1395  num_leaf_type_changes_filtered_out(),
1396  num_leaf_func_changes(),
1397  num_leaf_func_with_incompatible_changes(),
1398  num_leaf_func_changes_filtered_out(),
1399  num_leaf_var_changes(),
1400  num_leaf_var_with_incompatible_changes(),
1401  num_leaf_var_changes_filtered_out(),
1402  num_added_unreachable_types(),
1403  num_added_unreachable_types_filtered_out(),
1404  num_removed_unreachable_types(),
1405  num_removed_unreachable_types_filtered_out(),
1406  num_changed_unreachable_types(),
1407  num_changed_unreachable_types_filtered_out()
1408  {}
1409 
1411  ctxt()
1412  {return ctxt_.lock();}
1413 }; // end class corpus_diff::diff_stats::priv
1414 
1415 void
1416 sort_enumerators(const string_enumerator_map& enumerators_map,
1417  enum_type_decl::enumerators& sorted);
1418 
1419 void
1421  changed_enumerators_type& sorted);
1422 
1423 void
1424 sort_data_members(const string_decl_base_sptr_map &data_members,
1425  vector<decl_base_sptr>& sorted);
1426 
1427 void
1429 
1430 void
1432  vector<const function_decl*>& sorted);
1433 
1434 void
1437 
1438 void
1440  vector<type_base_sptr>& sorted);
1441 
1442 void
1446 
1447 void
1449 
1450 void
1452  var_diff_sptrs_type& sorted);
1453 
1454 void
1456 
1457 void
1459  vector<elf_symbol_sptr>& sorted);
1460 
1461 void
1463  vector<var_decl_sptr>& sorted);
1464 
1465 void
1467  var_diff_sptrs_type& sorted);
1468 
1469 void
1471  var_diff_sptrs_type& sorted);
1472 
1473 void
1477 
1478 void
1480  diff_sptrs_type& sorted);
1481 
1482 void
1484  diff_ptrs_type& sorted);
1485 
1486 void
1488  base_diff_sptrs_type& sorted);
1489 
1490 void
1492  class_decl::base_specs& sorted);
1493 
1494 void
1496  vector<fn_parm_diff_sptr>& sorted);
1497 void
1499  vector<fn_parm_diff_sptr>& sorted);
1500 void
1502  vector<function_decl::parameter_sptr>& sorted);
1503 
1504 void
1505 sort_artifacts_set(const artifact_sptr_set_type& set,
1506  vector<type_or_decl_base_sptr>& sorted);
1507 
1508 type_base_sptr
1509 get_leaf_type(qualified_type_def_sptr t);
1510 
1511 diff*
1512 get_fn_decl_or_var_decl_diff_ancestor(const diff *);
1513 
1514 bool
1515 is_diff_of_global_decls(const diff*);
1516 
1517 } // end namespace comparison
1518 
1519 } // namespace abigail
1520 
1521 #endif // __ABG_COMPARISON_PRIV_H__
vector< diff * > diff_ptrs_type
Convenience typedef for a vector of diff*.
std::pair< var_decl_sptr, var_decl_sptr > changed_var_sptr
Convenience typedef for a pair of var_decl_sptr representing a var_decl change. The first member of t...
A comparison function for instances of base_diff.
priv()
Default constructor of corpus_diff::priv.
bool operator()(const diff *l, const diff *r) const
An operator that takes two instances of diff_sptr returns true if its first operand compares less tha...
bool get_member_function_is_virtual(const function_decl &f)
Test if a given member function is virtual.
Definition: abg-ir.cc:6641
void sort_enumerators(const string_enumerator_map &enumerators_map, enum_type_decl::enumerators &sorted)
Sort a map of enumerators by their value.
The abstraction of an enumerator.
Definition: abg-ir.h:2880
shared_ptr< function_type_diff > function_type_diff_sptr
A convenience typedef for a shared pointer to function_type_type_diff.
A comparison functor for instances of diff.
shared_ptr< decl_diff_base > decl_diff_base_sptr
Convenience typedef for a shared_ptr of decl_diff_base.
vector< function_decl_diff_sptr > function_decl_diff_sptrs_type
Convenience typedef for a vector of function_decl_diff_sptr.
The private data of the ptr_to_mbr_diff type.
A "Less Than" functor to compare instance of function_decl_diff.
void sort_string_member_function_sptr_map(const string_member_function_sptr_map &map, class_or_union::member_functions &sorted)
Sort a map that's an instance of string_member_function_sptr_map and fill a vector of member function...
This header declares filters for the diff trees resulting from comparing ABI Corpora.
bool operator()(const diff_sptr l, diff_sptr r) const
Lexicographically compare two diff nodes.
The abstraction of a change between two ABI artifacts, a.k.a an artifact change.
shared_ptr< class_diff > class_diff_sptr
Convenience typedef for a shared pointer on a class_diff type.
vector< var_diff_sptr > var_diff_sptrs_type
Convenience typedef for a vector of var_diff_sptr.
int64_t get_value() const
Getter for the value of enum_type_decl::enumerator.
Definition: abg-ir.cc:21022
const function_decl_sptr first_function_decl() const
The internal type for the impl idiom implementation of pointer_diff.
bool operator()(const diff *d1, const diff *d2) const
The function-call operator to compare two diff nodes.
bool is_data_member(const var_decl &v)
Test if a var_decl is a data member.
Definition: abg-ir.cc:5613
virtual string get_pretty_representation(bool internal=false, bool qualified_name=true) const
Get the pretty representatin of the current declaration.
Definition: abg-ir.cc:4846
Utilities to ease the wrapping of C types into std::shared_ptr.
An equality functor for types_or_decls_type.
bool operator()(const var_diff_sptr f, const var_diff_sptr s)
Return true if the first argument is less than the second one.
void sort_string_var_diff_sptr_map(const string_var_diff_sptr_map &map, var_diff_sptrs_type &sorted)
Sort of an instance of string_var_diff_sptr_map map.
bool operator()(const function_decl *f, const function_decl *s)
The actual "less than" operator for instances of function_decl. It returns true if the first function...
vector< changed_var_sptr > changed_var_sptrs_type
Convenience typedef for a vector of .gg381.
void sort_var_diffs(var_diff_sptrs_type &var_diffs)
Sort a vector of var_diff_sptr.
A special enumerator that is the logical 'or' all the enumerators above.
An abstraction helper for type declarations.
Definition: abg-ir.h:2002
A functor to compare instances of elf_symbol base on their names.
size_t operator()(const diff &d) const
The function-call operator to hash a diff node.
void sort_function_decl_diffs(function_decl_diff_sptrs_type &fn_diffs)
Sort a vector of function_decl_diff_sptr.
void clear_redundancy_categorization(diff *diff_tree)
Walk a given diff sub-tree to clear the REDUNDANT_CATEGORY out of the category of the nodes...
This means that a diff node was marked as suppressed by a user-provided suppression specification...
void sort_string_data_member_diff_sptr_map(const string_var_diff_sptr_map &map, var_diff_sptrs_type &sorted)
Sort the values of a string_var_diff_sptr_map and store the result in a vector of var_diff_sptr...
bool operator()(const var_diff_sptr f, const var_diff_sptr s) const
type_or_decl_base_sptr first_subject() const
Getter of the first subject of the diff.
This means the diff node does not carry any (meaningful) change, or that it carries changes that have...
Abstraction of a base specifier in a class declaration.
Definition: abg-ir.h:4362
unordered_map< string, class_decl::base_spec_sptr > string_base_sptr_map
Convenience typedef for a map of string and class_decl::basse_spec_sptr.
shared_ptr< diff_context > diff_context_sptr
Convenience typedef for a shared pointer of diff_context.
Definition: abg-fwd.h:67
ssize_t get_member_function_vtable_offset(const function_decl &f)
Get the vtable offset of a member function.
Definition: abg-ir.cc:6578
void sort_data_members(const string_decl_base_sptr_map &data_members, vector< decl_base_sptr > &sorted)
Sort a map of data members by the offset of their initial value.
bool operator()(const function_decl &f, const function_decl &s)
The actual "less than" operator for instances of function_decl. It returns true if the first function...
bool compare_data_members(const var_decl_sptr &first_dm, const var_decl_sptr &second_dm) const
Compare two data members.
shared_ptr< var_decl > var_decl_sptr
Convenience typedef for a shared pointer on a var_decl.
Definition: abg-fwd.h:253
A diff node in this category has a parent node that is in the HAS_ALLOWED_CHANGE_CATEGORY category...
void sort_string_var_ptr_map(const string_var_ptr_map &map, vector< var_decl_sptr > &sorted)
Sort a map of string -> pointer to var_decl.
bool operator()(const fn_parm_diff &f, const fn_parm_diff &s)
class_decl::base_spec_sptr first_base() const
Getter for the first base spec of the diff object.
shared_ptr< translation_unit > translation_unit_sptr
Convenience typedef for a shared pointer on a translation_unit type.
Definition: abg-fwd.h:133
Abstraction of a diff between two function_decl.
void sort_string_diff_sptr_map(const string_diff_sptr_map &map, diff_sptrs_type &sorted)
Sort a map ofg string -> diff_sptr into a vector of diff_sptr. The diff_sptr are sorted lexicographic...
unordered_map< string, diff * > string_diff_ptr_map
Convenience typedef for a map which value is a diff*. The key of the map is the qualified name of the...
unordered_set< diff_sptr, diff_sptr_hasher > unordered_diff_sptr_set
Convenience typedef for an unoredered set of diff_sptr.
hash_t combine_hashes(hash_t val1, hash_t val2)
Combine two hash values to produce a third hash value.
Definition: abg-hash.cc:172
unordered_map< string, decl_base_sptr > string_decl_base_sptr_map
Convenience typedef for a map which key is a string and which value is a decl_base_sptr.
Definition: abg-fwd.h:157
Abstracts a variable declaration.
Definition: abg-ir.h:3067
void sort_string_elf_symbol_map(const string_elf_symbol_map &map, vector< elf_symbol_sptr > &sorted)
Sort a map of string -> pointer to elf_symbol.
The private data structure for distinct_diff.
void sort_string_parm_map(const string_parm_map &map, vector< function_decl::parameter_sptr > &sorted)
Sort a map of string -> function parameters.
A functor to compare instances of var_decl base on their qualified names.
diff_context_sptr get_context() const
Getter of the diff context associated with this diff.
bool is_diff_of_global_decls(const diff *)
Tests if a given diff node is to represent the changes between two gobal decls.
Abstraction of a function parameter.
Definition: abg-ir.h:3334
The base class of diff between decls.
The base class of diff between types.
bool operator()(const function_decl_diff &first, const function_decl_diff &second)
The actual less than operator.
unordered_map< string, var_diff_sptr > string_var_diff_sptr_map
Convenience typedef for a map whose key is a string and whose value is a changed variable of type var...
unordered_map< string, base_diff_sptr > string_base_diff_sptr_map
Convenience typedef for a map of string and base_diff_sptr.
unordered_map< string, elf_symbol_sptr > string_elf_symbol_map
Convenience typedef for a map whose key is a string and whose value is an elf_symbol_sptr.
The internal type for the impl idiom implementation of subrange_diff.
std::vector< enumerator > enumerators
Convenience typedef for a list of enumerator.
Definition: abg-ir.h:2798
unordered_map< unsigned, fn_parm_diff_sptr > unsigned_fn_parm_diff_sptr_map
Convenience typedef for a map which key is an integer and which value is a changed parameter...
void sort_string_base_diff_sptr_map(const string_base_diff_sptr_map &map, base_diff_sptrs_type &sorted)
Sort a map of string -> base_diff_sptr into a sorted vector of base_diff_sptr. The base_diff_sptr are...
A functor to compare instances of class_decl::base_spec.
A functor to compare two instances of diff_sptr.
void sort_unsigned_data_member_diff_sptr_map(const unsigned_var_diff_sptr_map map, var_diff_sptrs_type &sorted)
Sort the values of a unsigned_var_diff_sptr_map map and store the result into a vector of var_diff_sp...
vector< changed_enumerator > changed_enumerators_type
Convenience typedef for a vector of changed enumerators.
uint64_t get_data_member_offset(const var_decl &m)
Get the offset of a data member.
Definition: abg-ir.cc:6184
diff_category
An enum for the different categories that a diff tree node falls into, regarding the kind of changes ...
Toplevel namespace for libabigail.
bool operator()(const changed_var_sptr &f, const changed_var_sptr &s) const
Compare two data members.
unordered_set< type_or_decl_base_sptr, type_or_decl_hash, type_or_decl_equal > artifact_sptr_set_type
A convenience typedef for a hash set of type_or_decl_base_sptr.
Definition: abg-ir.h:559
unordered_map< string, changed_enumerator > string_changed_enumerator_map
Convenience typedef for a map which value is a changed enumerator. The key is the name of the changed...
An abstraction of a diff between two instances of class_decl::base_spec.
size_t operator()(const diff_sptr &d) const
The function-call operator to hash a diff node.
shared_ptr< function_decl > function_decl_sptr
Convenience typedef for a shared pointer on a function_decl.
Definition: abg-fwd.h:266
decl_base * is_decl(const type_or_decl_base *d)
Test if an ABI artifact is a declaration.
Definition: abg-ir.cc:10747
type_base_sptr get_leaf_type(qualified_type_def_sptr t)
Return the first underlying type that is not a qualified type.
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:21740
void sort_string_base_sptr_map(const string_base_sptr_map &m, class_decl::base_specs &sorted)
Lexicographically sort base specifications found in instances of string_base_sptr_map.
shared_ptr< parameter > parameter_sptr
Convenience typedef for a shared pointer on a function_decl::parameter.
Definition: abg-ir.h:3183
The type of the private data of corpus_diff::diff_stats.
shared_ptr< diff_stats > diff_stats_sptr
A convenience typedef for a shared pointer to diff_stats.
size_t hash_type_or_decl(const type_or_decl_base *tod)
Hash an ABI artifact that is either a type or a decl.
Definition: abg-ir.cc:28498
shared_ptr< base_spec > base_spec_sptr
Convenience typedef.
Definition: abg-ir.h:4188
diff_sptr element_type_diff_
The diff between the two array element types.
unordered_map< string, type_base_sptr > string_type_base_sptr_map
Convenience typedef for a map which key is a string and which value is a type_base_sptr.
This means that a diff node was warked as being for a private type. That is, the diff node is meant t...
Abstraction of a diff between two function parameters.
const function_decl::parameter_sptr first_parameter() const
Getter for the first subject of this diff node.
Abstraction for a function declaration.
Definition: abg-ir.h:3164
bool operator()(const diff &l, diff &r) const
Lexicographically compare two diff nodes.
unordered_map< string, diff_sptr > string_diff_sptr_map
Convenience typedef for a map which value is a diff_sptr. The key of the map is the qualified name of...
unordered_map< string, function_decl_diff_sptr > string_function_decl_diff_sptr_map
Convenience typedef for a map which key is a string and which value is a function_decl_diff_sptr.
bool operator()(const diff *l, diff *r) const
Lexicographically compare two diff nodes.
A hashing functor for types_or_decls_type.
priv(corpus_sptr first, corpus_sptr second, diff_context_sptr ctxt)
Constructor of corpus_diff::priv.
unordered_map< string, var_decl_sptr > string_var_ptr_map
Convenience typedef for a map which key is a string and which value is a point to var_decl...
A diff node in this category is redundant. That means it's present as a child of a other nodes in the...
shared_ptr< function_decl_diff > function_decl_diff_sptr
Convenience typedef for a shared pointer to a function_decl type.
Functor to sort instances of var_diff_sptr.
unordered_map< unsigned, function_decl::parameter_sptr > unsigned_parm_map
Convenience typedef for a map which key is an integer and which value is a parameter.
diff * get_canonical_diff() const
Getter for the canonical diff of the current instance of diff.
unordered_map< const diff *, artifact_sptr_set_type, diff_hash, diff_equal > diff_artifact_set_map_type
A convenience typedef for an unordered_map which key is a diff* and which value is a artifact_sptr_se...
shared_ptr< type_or_decl_base > type_or_decl_base_sptr
A convenience typedef for a shared_ptr to type_or_decl_base.
Definition: abg-fwd.h:118
A hashing functor for using diff_sptr and diff* in a hash map or set.
bool operator()(const function_decl::parameter_sptr &l, const function_decl::parameter_sptr &r)
Returns true iff the index of the first parameter is smaller than the of the second parameter...
Abstraction of an elf symbol.
Definition: abg-ir.h:960
unordered_map< string, const function_decl * > string_function_ptr_map
Convenience typedef for a map which key is a string and which value is a pointer to decl_base...
vector< method_decl_sptr > member_functions
Convenience typedef.
Definition: abg-ir.h:4008
shared_ptr< var_diff > var_diff_sptr
Convenience typedef for a shared pointer to a var_diff type.
shared_ptr< elf_symbol > elf_symbol_sptr
A convenience typedef for a shared pointer to elf_symbol.
Definition: abg-ir.h:924
#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:1743
vector< suppression_sptr > suppressions_type
Convenience typedef for a vector of suppression_sptr.
Definition: abg-fwd.h:1687
A functor to compare two enumerators based on their value. This implements the "less than" operator...
A diff node in this category has a descendant node that is in the HAS_ALLOWED_CHANGE_CATEGORY categor...
bool operator()(const function_decl::parameter &l, const function_decl::parameter &r)
Returns true iff the index of the first parameter is smaller than the of the second parameter...
A comparison functor to compare two instances of fn_parm_diff based on their indexes.
unordered_map< unsigned, decl_base_sptr > unsigned_decl_base_sptr_map
Convenience typedef for a map which key is an unsigned integer and which value is a decl_base_sptr...
std::pair< enum_type_decl::enumerator, enum_type_decl::enumerator > changed_enumerator
Convenience typedef for a changed enumerator. The first element of the pair is the old enumerator and...
A comparison functor to compare two instances of var_diff that represent changed data members based o...
bool operator()(const diff_sptr &l, const diff_sptr &r) const
An operator that takes two instances of diff_sptr returns true if its first operand compares less tha...
abg_compat::optional< uint64_t > hash_t
The abstraction for an 8 bytes hash value.
Definition: abg-ir.h:105
This type contains maps. Each map associates a type name to a diff of that type. Not all kinds of dif...
unordered_map< unsigned, var_diff_sptr > unsigned_var_diff_sptr_map
Convenience typedef for a map whose key is an unsigned int and whose value is a changed variable of t...
The private member (pimpl) for diff_context.
bool is_less_than(const decl_diff_base &first, const decl_diff_base &second)
Compare two decl diff nodes (decl_diff_base) for the purpose of sorting.
bool operator()(const function_decl_diff_sptr first, const function_decl_diff_sptr second)
The actual less than operator.
unordered_map< types_or_decls_type, diff_sptr, types_or_decls_hash, types_or_decls_equal > types_or_decls_diff_map_type
A convenience typedef for a map of types_or_decls_type and diff_sptr.
void sort_changed_data_members(changed_var_sptrs_type &input)
Sort (in place) a vector of changed data members.
shared_ptr< base_diff > base_diff_sptr
Convenience typedef for a shared pointer to a base_diff type.
void sort_changed_enumerators(const string_changed_enumerator_map &enumerators_map, changed_enumerators_type &sorted)
Sort a map of changed enumerators.
bool is_filtered_out(diff_category category)
Check if a given categorization of a diff node should make it be filtered out.
A comparison functor to compare two data members based on their offset.
shared_ptr< fn_parm_diff > fn_parm_diff_sptr
Convenience typedef for a shared pointer to a fn_parm_diff type.
string get_name(const type_or_decl_base *tod, bool qualified)
Build and return a copy of the name of an ABI artifact that is either a type or a decl...
Definition: abg-ir.cc:8686
unordered_map< string, method_decl_sptr > string_member_function_sptr_map
Convenience typedef for a hash map of strings and member functions.
bool function_decl_is_less_than(const function_decl &f, const function_decl &s)
Test if the pretty representation of a given function_decl is lexicographically less then the pretty ...
Definition: abg-ir.cc:28797
The type of private data of class_or_union_diff.
A deleter for shared pointers that ... doesn't delete the object managed by the shared pointer...
std::pair< const type_or_decl_base_sptr, const type_or_decl_base_sptr > types_or_decls_type
Convenience typedef for a pair of decls or types.
unordered_map< size_t, size_t > pointer_map
Convenience typedef for a map of pointer values. The Key is a pointer value and the value is potentia...
unordered_map< string, fn_parm_diff_sptr > string_fn_parm_diff_sptr_map
Convenience typedef for a map which value is a changed function parameter and which key is the name o...
void sort_string_fn_parm_diff_sptr_map(const unsigned_fn_parm_diff_sptr_map &map, vector< fn_parm_diff_sptr > &sorted)
Sort a map of fn_parm_diff by the indexes of the function parameters.
void sort_string_virtual_member_function_diff_sptr_map(const string_function_decl_diff_sptr_map &map, function_decl_diff_sptrs_type &sorted)
Sort an map of string -> virtual member function into a vector of virtual member functions. The virtual member functions are sorted by increasing order of their virtual index.
an engine to suppress the parts of the result of comparing two sets of ABI artifacts.
void sort_string_function_decl_diff_sptr_map(const string_function_decl_diff_sptr_map &map, function_decl_diff_sptrs_type &sorted)
Sort the values of a string_function_decl_diff_sptr_map map and store the result in a vector of funct...
A diff node in this category carries a change that must be reported, even if the diff node is also in...
vector< diff_sptr > diff_sptrs_type
Convenience typedef for a vector of diff_sptr.
A functor to compare two changed enumerators, based on their initial value.
shared_ptr< corpus_diff > corpus_diff_sptr
A convenience typedef for a shared pointer to corpus_diff.
weak_ptr< diff_context > diff_context_wptr
Convenience typedef for a weak pointer of diff_context.
Definition: abg-fwd.h:73
A comparison functor for using diff_sptr and diff* in a hash map or set.
vector< base_diff_sptr > base_diff_sptrs_type
Convenience typedef for a vector of base_diff_sptr.
unordered_map< string, function_decl::parameter_sptr > string_parm_map
Convenience typedef for a map which value is a function parameter. The key is the name of the functio...
bool operator()(const diff &d1, const diff &d2) const
The function-call operator to compare two diff nodes.
"Less than" functor to compare instances of function_decl.
void sort_string_type_base_sptr_map(string_type_base_sptr_map &map, vector< type_base_sptr > &sorted)
Sort a map of string to type_base_sptr entities.
Functor that compares two function parameters for the purpose of sorting them.
void sort_string_diff_ptr_map(const string_diff_ptr_map &map, diff_ptrs_type &sorted)
Sort a map ofg string -> diff* into a vector of diff_ptr. The diff_ptr are sorted lexicographically w...
bool operator()(const diff_sptr &d1, const diff_sptr &d2) const
The function-call operator to compare two diff nodes.
unordered_map< string, enum_type_decl::enumerator > string_enumerator_map
Convenience typedef for a map which value is an enumerator. The key is the name of the enumerator...
size_t operator()(const diff *d) const
The function-call operator to hash a diff node.
const string & get_id_string() const
Get a string that is representative of a given elf_symbol.
Definition: abg-ir.cc:2616
vector< base_spec_sptr > base_specs
Convenience typedef.
Definition: abg-ir.h:4193
This is a document class that aims to capture statistics about the changes carried by a corpus_diff t...
void sort_string_function_ptr_map(const string_function_ptr_map &map, vector< const function_decl * > &sorted)
Sort an instance of string_function_ptr_map map and stuff a resulting sorted vector of pointers to fu...
The type of the private data (pimpl sub-object) of the class_diff type.
The internal type for the impl idiom implementation of var_diff.
shared_ptr< diff > diff_sptr
Convenience typedef for a shared_ptr for the diff class.
Definition: abg-fwd.h:75
shared_ptr< reporter_base > reporter_base_sptr
A convenience typedef for a shared pointer to a reporter_base.
Definition: abg-reporter.h:50
void sort_artifacts_set(const artifact_sptr_set_type &set, vector< type_or_decl_base_sptr > &sorted)
Sort the set of ABI artifacts contained in a artifact_sptr_set_type.
bool operator()(const function_decl_sptr f, const function_decl_sptr s)
The actual "less than" operator for instances of function_decl. It returns true if the first function...
string get_pretty_representation(diff *d)
Get a copy of the pretty representation of a diff node.
weak_ptr< diff > diff_wptr
Convenience typedef for a weak_ptr for the diff class.
Definition: abg-fwd.h:81
A comparison functor for instances of function_decl_diff that represent changes between two virtual m...
Private data for the diff type. The details of generic view of the diff node are expressed here...
bool operator()(const decl_base_sptr &f, const decl_base_sptr &s) const
Compare two data members.