• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2 // -*- Mode: C++ -*-
3 //
4 // Copyright (C) 2013-2020 Red Hat, Inc.
5 //
6 // Author: Dodji Seketeli
7 
8 #ifndef __ABG_COMPARISON_H__
9 #define __ABG_COMPARISON_H__
10 
11 /// @file
12 
13 #include <memory>
14 #include <ostream>
15 #include <unordered_map>
16 #include <unordered_set>
17 #include "abg-corpus.h"
18 #include "abg-diff-utils.h"
19 #include "abg-reporter.h"
20 
21 namespace abigail
22 {
23 
24 /// @brief utilities to compare abi artifacts
25 ///
26 /// The main entry points of the namespace are the compute_diff()
27 /// overloads used to compute the difference between two abi artifacts.
28 namespace comparison
29 {
30 
31 namespace filtering
32 {
33 struct filter_base;
34 typedef shared_ptr<filter_base> filter_base_sptr;
35 typedef std::vector<filter_base_sptr> filters;
36 }
37 
38 // Inject types we need into this namespace.
39 using std::ostream;
40 using std::vector;
41 using std::unordered_map;
42 using std::unordered_set;
43 using std::pair;
44 
45 using diff_utils::insertion;
46 using diff_utils::deletion;
47 using diff_utils::edit_script;
48 
49 class diff;
50 
51 /// Convenience typedef for a shared_ptr for the @ref diff class
52 typedef shared_ptr<diff> diff_sptr;
53 
54 /// Convenience typedef for a weak_ptr for the @ref diff class
55 typedef weak_ptr<diff> diff_wptr;
56 
57 /// Hasher for @ref diff_sptr.
58 struct diff_sptr_hasher
59 {
60   /// The actual hashing functor.
61   size_t
operatordiff_sptr_hasher62   operator()(const diff_sptr& t) const
63   {return reinterpret_cast<size_t>(t.get());}
64 }; // end struct diff_sptr_hasher
65 
66 /// Convenience typedef for a vector of @ref diff_sptr.
67 typedef vector<diff_sptr> diff_sptrs_type;
68 
69 /// Convenience typedef for a vector of @ref diff*.
70 typedef vector<diff*> diff_ptrs_type;
71 
72 /// Convenience typedef for an unoredered set of @ref diff_sptr
73 typedef unordered_set<diff_sptr, diff_sptr_hasher> unordered_diff_sptr_set;
74 
75 class decl_diff_base;
76 
77 /// Convenience typedef for a shared_ptr of @ref decl_diff_base.
78 typedef shared_ptr<decl_diff_base> decl_diff_base_sptr;
79 
80 /// Convenience typedef for a vector of @ref decl_diff_base_sptr.
81 typedef vector<decl_diff_base_sptr> decl_diff_base_sptrs_type;
82 
83 class type_diff_base;
84 /// Convenience pointer for a shared pointer to a type_diff_base
85 typedef shared_ptr<type_diff_base> type_diff_base_sptr;
86 
87 /// Convenience typedef for a vector of @ref type_diff_base_sptr
88 typedef vector<type_diff_base_sptr> type_diff_base_sptrs_type;
89 
90 class function_decl_diff;
91 
92 /// Convenience typedef for a shared pointer to a @ref function_decl type.
93 typedef shared_ptr<function_decl_diff> function_decl_diff_sptr;
94 
95 /// Convenience typedef for a vector of @ref function_decl_diff_sptr
96 typedef vector<function_decl_diff_sptr> function_decl_diff_sptrs_type;
97 
98 class fn_parm_diff;
99 
100 /// Convenience typedef for a shared pointer to a @ref fn_parm_diff
101 /// type.
102 typedef shared_ptr<fn_parm_diff> fn_parm_diff_sptr;
103 
104 class var_diff;
105 
106 /// Convenience typedef for a shared pointer to a @ref var_diff type.
107 typedef shared_ptr<var_diff> var_diff_sptr;
108 
109 /// Convenience typedef for a vector of @ref var_diff_sptr.
110 typedef vector<var_diff_sptr> var_diff_sptrs_type;
111 
112 class base_diff;
113 
114 /// Convenience typedef for a shared pointer to a @ref base_diff type.
115 typedef shared_ptr<base_diff> base_diff_sptr;
116 
117 /// Convenience typedef for a vector of @ref base_diff_sptr.
118 typedef vector<base_diff_sptr> base_diff_sptrs_type;
119 
120 class class_diff;
121 
122 /// Convenience typedef for a shared pointer on a @ref class_diff type.
123 typedef shared_ptr<class_diff> class_diff_sptr;
124 
125 /// Convenience typedef for a map of pointer values.  The Key is a
126 /// pointer value and the value is potentially another pointer value
127 /// associated to the first one.
128 typedef unordered_map<size_t, size_t> pointer_map;
129 
130 /// Convenience typedef for a map which key is a string and which
131 /// value is a @ref decl_base_sptr.
132 typedef unordered_map<string, decl_base_sptr> string_decl_base_sptr_map;
133 
134 /// Convenience typedef for a map which key is a string and which
135 /// value is a @ref type_base_sptr.
136 typedef unordered_map<string, type_base_sptr> string_type_base_sptr_map;
137 
138 /// Convenience typedef for a map which key is an unsigned integer and
139 /// which value is a @ref decl_base_sptr
140 typedef unordered_map<unsigned, decl_base_sptr> unsigned_decl_base_sptr_map;
141 
142 /// Convenience typedef for a map of string and class_decl::basse_spec_sptr.
143 typedef unordered_map<string, class_decl::base_spec_sptr> string_base_sptr_map;
144 
145 /// Convenience typedef for a map of string and @ref base_diff_sptr.
146 typedef unordered_map<string, base_diff_sptr> string_base_diff_sptr_map;
147 
148 /// Convenience typedef for a map which value is a changed function
149 /// parameter and which key is the name of the function parameter.
150 typedef unordered_map<string, fn_parm_diff_sptr> string_fn_parm_diff_sptr_map;
151 
152 /// Convenience typedef for a map which key is an integer and which
153 /// value is a changed parameter.
154 typedef unordered_map<unsigned, fn_parm_diff_sptr>
155 unsigned_fn_parm_diff_sptr_map;
156 
157 /// Convenience typedef for a map which key is an integer and which
158 /// value is a parameter.
159 typedef unordered_map<unsigned,
160 		      function_decl::parameter_sptr> unsigned_parm_map;
161 
162 /// Convenience typedef for a map which value is a
163 /// type_diff_base_sptr.  The key of the map is the qualified name of
164 /// the changed type.
165 typedef unordered_map<string,
166 		      type_diff_base_sptr> string_type_diff_base_sptr_map;
167 
168 /// Convenience typedef for a map which value is a
169 /// decl_diff_base_sptr.  The key of the map is the qualified name of
170 /// the changed type.
171 typedef unordered_map<string,
172 		      decl_diff_base_sptr> string_decl_diff_base_sptr_map;
173 
174 /// Convenience typedef for a map which value is a diff_sptr.  The key
175 /// of the map is the qualified name of the changed type.
176 typedef unordered_map<string, diff_sptr> string_diff_sptr_map;
177 
178 /// Convenience typedef for a map which value is a diff*.  The key of
179 /// the map is the qualified name of the changed type.
180 typedef unordered_map<string, diff*> string_diff_ptr_map;
181 
182 /// Convenience typedef for a map whose key is a string and whose
183 /// value is a changed variable of type @ref var_diff_sptr.
184 typedef unordered_map<string,
185 		      var_diff_sptr> string_var_diff_sptr_map;
186 
187 
188 /// Convenience typedef for a map whose key is an unsigned int and
189 /// whose value is a changed variable of type @ref var_diff_sptr.
190 typedef unordered_map<unsigned, var_diff_sptr> unsigned_var_diff_sptr_map;
191 
192 /// Convenience typedef for a map which value is a function
193 /// parameter.  The key is the name of the function parm.
194 typedef unordered_map<string, function_decl::parameter_sptr> string_parm_map;
195 
196 /// Convenience typedef for a map which value is an enumerator.  The
197 /// key is the name of the enumerator.
198 typedef unordered_map<string, enum_type_decl::enumerator> string_enumerator_map;
199 
200 /// Convenience typedef for a changed enumerator.  The first element
201 /// of the pair is the old enumerator and the second one is the new enumerator.
202 typedef std::pair<enum_type_decl::enumerator,
203 		  enum_type_decl::enumerator> changed_enumerator;
204 
205 /// Convenience typedef for a vector of changed enumerators.
206 typedef vector<changed_enumerator> changed_enumerators_type;
207 
208 /// Convenience typedef for a map which value is a changed enumerator.
209 /// The key is the name of the changed enumerator.
210 typedef unordered_map<string, changed_enumerator> string_changed_enumerator_map;
211 
212 /// Convenience typedef for a map which key is a string and which
213 /// value is a pointer to @ref decl_base.
214 typedef unordered_map<string, function_decl*> string_function_ptr_map;
215 
216 /// Convenience typedef for a map which key is a string and which
217 /// value is a @ref function_decl_diff_sptr.
218 typedef unordered_map<string,
219 		      function_decl_diff_sptr>
220 				string_function_decl_diff_sptr_map;
221 
222 /// Convenience typedef for a pair of class_decl::member_function_sptr
223 /// representing a changed member function.  The first element of the
224 /// pair is the initial member function and the second element is the
225 /// changed one.
226 typedef pair<method_decl_sptr,
227 	     method_decl_sptr> changed_member_function_sptr;
228 
229 /// Convenience typedef for a hash map of strings and changed member functions.
230 typedef unordered_map<string,
231 		      changed_member_function_sptr>
232 				string_changed_member_function_sptr_map;
233 
234 /// Convenience typedef for a hash map of strings  and member functions.
235 typedef unordered_map<string, method_decl_sptr> string_member_function_sptr_map;
236 
237 /// Convenience typedef for a map which key is a string and which
238 /// value is a point to @ref var_decl.
239 typedef unordered_map<string, var_decl*> string_var_ptr_map;
240 
241 /// Convenience typedef for a pair of pointer to @ref var_decl
242 /// representing a @ref var_decl change.  The first member of the pair
243 /// represents the initial variable and the second member represents
244 /// the changed variable.
245 typedef std::pair<var_decl*, var_decl*> changed_var_ptr;
246 
247 /// Convenience typedef for a pair of @ref var_decl_sptr representing
248 /// a @ref var_decl change.  The first member of the pair represents
249 /// the initial variable and the second member represents the changed
250 /// variable.
251 typedef std::pair<var_decl_sptr, var_decl_sptr> changed_var_sptr;
252 
253 /// Convenience typedef for a vector of @changed_var_sptr.gg381
254 typedef vector<changed_var_sptr> changed_var_sptrs_type;
255 
256 /// Convenience typedef for a map whose key is a string and whose
257 /// value is an @ref elf_symbol_sptr.
258 typedef unordered_map<string, elf_symbol_sptr> string_elf_symbol_map;
259 
260 /// Convenience typedef for a map which key is a string and which
261 /// value is a @ref var_diff_sptr.
262 typedef unordered_map<string, var_diff_sptr> string_var_diff_ptr_map;
263 
264 class diff_context;
265 
266 /// Convenience typedef for a shared pointer of @ref diff_context.
267 typedef shared_ptr<diff_context> diff_context_sptr;
268 
269 /// Convenience typedef for a weak pointer of @ref diff_context.
270 typedef weak_ptr<diff_context> diff_context_wptr;
271 
272 class diff_node_visitor;
273 
274 class diff_traversable_base;
275 
276 /// Convenience typedef for shared_ptr on diff_traversable_base.
277 typedef shared_ptr<diff_traversable_base> diff_traversable_base_sptr;
278 
279 /// An enum for the different ways to visit a diff tree node.
280 ///
281 /// This is used by the node traversing code, to know when to avoid
282 /// visiting children nodes, for instance.
283 enum visiting_kind
284 {
285   /// The default enumerator value of this enum.  It doesn't have any
286   /// particular meaning yet.
287   DEFAULT_VISITING_KIND = 0,
288 
289   /// This says that the traversing code should avoid visiting the
290   /// children nodes of the current node being visited.
291   SKIP_CHILDREN_VISITING_KIND = 1,
292 
293   /// This says that the traversing code should not mark visited nodes
294   /// as having been traversed.  This is useful, for instance, for
295   /// visitors which have debugging purposes.
296   DO_NOT_MARK_VISITED_NODES_AS_VISITED = 1 << 1
297 };
298 
299 visiting_kind
300 operator|(visiting_kind l, visiting_kind r);
301 
302 visiting_kind
303 operator&(visiting_kind l, visiting_kind r);
304 
305 visiting_kind
306 operator~(visiting_kind l);
307 
308 ///  The base class for the diff classes that are to be traversed.
309 class diff_traversable_base : public traversable_base
310 {
311 public:
312   virtual bool
313   traverse(diff_node_visitor& v);
314 }; // end struct diff_traversable_base
315 
316 /// An enum for the different categories that a diff tree node falls
317 /// into, regarding the kind of changes it represents.
318 ///
319 /// Note that if you add an enumerator to this enum, you need to
320 /// update a few spots accordingly:
321 ///
322 ///   * update the ACCESS_CHANGE_CATEGORY enumerator (which is the
323 ///     last enumerator of this enum by OR-ing its initializer with
324 ///     the new enumerator.
325 ///
326 ///   * update the categorize_harmless_diff_node or
327 ///     categorize_harmful_diff_node function depending on if the new
328 ///     enumerator classifies diff nodes as harmless or harmful.
329 ///
330 ///   * update the get_default_harmless_categories_bitmap or
331 ///    get_default_harmful_categories_bitmap function as well, just
332 ///    like above.
333 ///
334 ///   * update the "operator<<(ostream& o, diff_category c)" streaming
335 ///     operator so that it can stream the new enumerator to a textual
336 ///     output stream.
337 enum diff_category
338 {
339   /// This means the diff node does not carry any (meaningful) change,
340   /// or that it carries changes that have not yet been categorized.
341   NO_CHANGE_CATEGORY = 0,
342 
343   /// This means the diff node (or at least one of its descendant
344   /// nodes) carries access related changes, e.g, a private member
345   /// that becomes public.
346   ACCESS_CHANGE_CATEGORY = 1,
347 
348   /// This means the diff node (or at least one of its descendant
349   /// nodes) carries a change involving two compatible types.  For
350   /// instance a type and its typedefs.
351   COMPATIBLE_TYPE_CHANGE_CATEGORY = 1 << 1,
352 
353   /// This means that a diff node in the sub-tree carries a harmless
354   /// declaration name change.  This is set only for name changes for
355   /// data members and typedefs.
356   HARMLESS_DECL_NAME_CHANGE_CATEGORY = 1 << 2,
357 
358   /// This means that a diff node in the sub-tree carries an addition
359   /// or removal of a non-virtual member function.
360   NON_VIRT_MEM_FUN_CHANGE_CATEGORY = 1 << 3,
361 
362   /// This means that a diff node in the sub-tree carries an addition
363   /// or removal of a static data member.
364   STATIC_DATA_MEMBER_CHANGE_CATEGORY = 1 << 4,
365 
366   /// This means that a diff node in the sub-tree carries an addition
367   /// of enumerator to an enum type.
368   HARMLESS_ENUM_CHANGE_CATEGORY = 1 << 5,
369 
370   /// This means that a diff node in the sub-tree carries an a symbol
371   /// alias change that is harmless.
372   HARMLESS_SYMBOL_ALIAS_CHANGE_CATEGORY = 1 << 6,
373 
374   /// This means that a diff node in the sub-tree carries a harmless
375   /// union change.
376   HARMLESS_UNION_CHANGE_CATEGORY = 1 << 7,
377 
378   /// This means that a diff node in the sub-tree carries a harmless
379   /// data member change.  An example of harmless data member change
380   /// is an anonymous data member that replaces a given data member
381   /// without locally changing the layout.
382   HARMLESS_DATA_MEMBER_CHANGE_CATEGORY = 1 << 8,
383 
384   /// This means that a diff node was marked as suppressed by a
385   /// user-provided suppression specification.
386   SUPPRESSED_CATEGORY = 1 << 9,
387 
388   /// This means that a diff node was warked as being for a private
389   /// type.  That is, the diff node is meant to be suppressed by a
390   /// suppression specification that was auto-generated to filter out
391   /// changes to private types.
392   PRIVATE_TYPE_CATEGORY = 1 << 10,
393 
394   /// This means the diff node (or at least one of its descendant
395   /// nodes) carries a change that modifies the size of a type or an
396   /// offset of a type member.  Removal or changes of enumerators in a
397   /// enum fall in this category too.
398   SIZE_OR_OFFSET_CHANGE_CATEGORY = 1 << 11,
399 
400   /// This means that a diff node in the sub-tree carries an
401   /// incompatible change to a vtable.
402   VIRTUAL_MEMBER_CHANGE_CATEGORY = 1 << 12,
403 
404   /// A diff node in this category is redundant.  That means it's
405   /// present as a child of a other nodes in the diff tree.
406   REDUNDANT_CATEGORY = 1 << 13,
407 
408   /// This means that a diff node in the sub-tree carries a type that
409   /// was declaration-only and that is now defined, or vice versa.
410   TYPE_DECL_ONLY_DEF_CHANGE_CATEGORY = 1 << 14,
411 
412   /// A diff node in this category is a function parameter type which
413   /// top cv-qualifiers change.
414   FN_PARM_TYPE_TOP_CV_CHANGE_CATEGORY = 1 << 15,
415 
416   /// A diff node in this category has a function parameter type with a
417   /// cv-qualifiers change.
418   FN_PARM_TYPE_CV_CHANGE_CATEGORY = 1 << 16,
419 
420   /// A diff node in this category is a function return type with a
421   /// cv-qualifier change.
422   FN_RETURN_TYPE_CV_CHANGE_CATEGORY = 1 << 17,
423 
424   /// A diff node in this category is a function (or function type)
425   /// with at least one parameter added or removed.
426   FN_PARM_ADD_REMOVE_CHANGE_CATEGORY = 1 << 18,
427 
428   /// A diff node in this category is for a variable which type holds
429   /// a cv-qualifier change.
430   VAR_TYPE_CV_CHANGE_CATEGORY = 1 << 19,
431 
432   /// A diff node in this category carries a change from void pointer
433   /// to non-void pointer.
434   VOID_PTR_TO_PTR_CHANGE_CATEGORY = 1 << 20,
435 
436   /// A diff node in this category carries a change in the size of the
437   /// array type of a global variable, but the ELF size of the
438   /// variable didn't change.
439   BENIGN_INFINITE_ARRAY_CHANGE_CATEGORY = 1 << 21,
440 
441   /// A special enumerator that is the logical 'or' all the
442   /// enumerators above.
443   ///
444   /// This one must stay the last enumerator.  Please update it each
445   /// time you add a new enumerator above.
446   EVERYTHING_CATEGORY =
447   ACCESS_CHANGE_CATEGORY
448   | COMPATIBLE_TYPE_CHANGE_CATEGORY
449   | HARMLESS_DECL_NAME_CHANGE_CATEGORY
450   | NON_VIRT_MEM_FUN_CHANGE_CATEGORY
451   | STATIC_DATA_MEMBER_CHANGE_CATEGORY
452   | HARMLESS_ENUM_CHANGE_CATEGORY
453   | HARMLESS_SYMBOL_ALIAS_CHANGE_CATEGORY
454   | HARMLESS_UNION_CHANGE_CATEGORY
455   | HARMLESS_DATA_MEMBER_CHANGE_CATEGORY
456   | SUPPRESSED_CATEGORY
457   | PRIVATE_TYPE_CATEGORY
458   | SIZE_OR_OFFSET_CHANGE_CATEGORY
459   | VIRTUAL_MEMBER_CHANGE_CATEGORY
460   | REDUNDANT_CATEGORY
461   | TYPE_DECL_ONLY_DEF_CHANGE_CATEGORY
462   | FN_PARM_TYPE_TOP_CV_CHANGE_CATEGORY
463   | FN_PARM_TYPE_CV_CHANGE_CATEGORY
464   | FN_RETURN_TYPE_CV_CHANGE_CATEGORY
465   | FN_PARM_ADD_REMOVE_CHANGE_CATEGORY
466   | VAR_TYPE_CV_CHANGE_CATEGORY
467   | VOID_PTR_TO_PTR_CHANGE_CATEGORY
468   | BENIGN_INFINITE_ARRAY_CHANGE_CATEGORY
469 }; // enum diff_category
470 
471 diff_category
472 operator|(diff_category c1, diff_category c2);
473 
474 diff_category&
475 operator|=(diff_category& c1, diff_category c2);
476 
477 diff_category&
478 operator&=(diff_category& c1, diff_category c2);
479 
480 diff_category
481 operator^(diff_category c1, diff_category c2);
482 
483 diff_category
484 operator&(diff_category c1, diff_category c2);
485 
486 diff_category
487 operator~(diff_category c);
488 
489 diff_category
490 get_default_harmless_categories_bitmap();
491 
492 diff_category
493 get_default_harmful_categories_bitmap();
494 
495 ostream&
496 operator<<(ostream& o, diff_category);
497 
498 class corpus_diff;
499 
500 /// This type contains maps.  Each map associates a type name to a
501 /// diff of that type. Not all kinds of diffs are present; only those
502 /// that carry leaf changes are, for now.
503 class diff_maps
504 {
505   struct priv;
506   std::unique_ptr<priv> priv_;
507 
508 public:
509 
510   diff_maps();
511 
512   ~diff_maps();
513 
514   const string_diff_ptr_map&
515   get_type_decl_diff_map() const;
516 
517   string_diff_ptr_map&
518   get_type_decl_diff_map();
519 
520   const string_diff_ptr_map&
521   get_enum_diff_map() const;
522 
523   string_diff_ptr_map&
524   get_enum_diff_map();
525 
526   const string_diff_ptr_map&
527   get_class_diff_map() const;
528 
529   string_diff_ptr_map&
530   get_class_diff_map();
531 
532   const string_diff_ptr_map&
533   get_union_diff_map() const;
534 
535   string_diff_ptr_map&
536   get_union_diff_map();
537 
538   const string_diff_ptr_map&
539   get_typedef_diff_map() const;
540 
541   string_diff_ptr_map&
542   get_typedef_diff_map();
543 
544   const string_diff_ptr_map&
545   get_array_diff_map() const;
546 
547   string_diff_ptr_map&
548   get_array_diff_map();
549 
550   const string_diff_ptr_map&
551   get_reference_diff_map() const;
552 
553   string_diff_ptr_map&
554   get_reference_diff_map();
555 
556   const string_diff_ptr_map&
557   get_fn_parm_diff_map() const;
558 
559   string_diff_ptr_map&
560   get_fn_parm_diff_map();
561 
562   const string_diff_ptr_map&
563   get_function_type_diff_map() const;
564 
565   string_diff_ptr_map&
566   get_function_type_diff_map();
567 
568   const string_diff_ptr_map&
569   get_function_decl_diff_map() const;
570 
571   string_diff_ptr_map&
572   get_function_decl_diff_map();
573 
574   const string_diff_ptr_map&
575   get_var_decl_diff_map() const;
576 
577   string_diff_ptr_map&
578   get_var_decl_diff_map();
579 
580   const string_diff_ptr_map&
581   get_distinct_diff_map() const;
582 
583   string_diff_ptr_map&
584   get_distinct_diff_map();
585 
586   bool
587   insert_diff_node(const diff *d,
588 		   const type_or_decl_base_sptr& impacted_iface);
589 
590   artifact_sptr_set_type*
591   lookup_impacted_interfaces(const diff *d) const;
592 }; // end class diff_maps
593 
594 /// A convenience typedef for a shared pointer to @ref corpus_diff.
595 typedef shared_ptr<corpus_diff> corpus_diff_sptr;
596 
597 /// The context of the diff.  This type holds various bits of
598 /// information that is going to be used throughout the diffing of two
599 /// entities and the reporting that follows.
600 class diff_context
601 {
602   struct priv;
603   std::unique_ptr<priv> priv_;
604 
605   diff_sptr
606   has_diff_for(const type_or_decl_base_sptr first,
607 	       const type_or_decl_base_sptr second) const;
608 
609   diff_sptr
610   has_diff_for_types(const type_base_sptr first,
611 		     const type_base_sptr second) const;
612 
613   const diff*
614   has_diff_for(const diff* d) const;
615 
616   diff_sptr
617   has_diff_for(const diff_sptr d) const;
618 
619   void
620   add_diff(const type_or_decl_base_sptr first,
621 	   const type_or_decl_base_sptr second,
622 	   const diff_sptr d);
623 
624   void
625   add_diff(const diff_sptr d);
626 
627   void
628   add_diff(const diff* d);
629 
630   void
631   set_canonical_diff_for(const type_or_decl_base_sptr first,
632 			 const type_or_decl_base_sptr second,
633 			 const diff_sptr);
634 
635   diff_sptr
636   set_or_get_canonical_diff_for(const type_or_decl_base_sptr first,
637 				const type_or_decl_base_sptr second,
638 				const diff_sptr canonical_diff);
639 
640 public:
641   diff_context();
642 
643   ~diff_context();
644 
645   void
646   set_corpus_diff(const corpus_diff_sptr&);
647 
648   const corpus_diff_sptr&
649   get_corpus_diff() const;
650 
651   corpus_sptr
652   get_first_corpus() const;
653 
654   corpus_sptr
655   get_second_corpus() const;
656 
657   reporter_base_sptr
658   get_reporter() const;
659 
660   void
661   set_reporter(reporter_base_sptr&);
662 
663   diff_sptr
664   get_canonical_diff_for(const type_or_decl_base_sptr first,
665 			 const type_or_decl_base_sptr second) const;
666 
667   diff_sptr
668   get_canonical_diff_for(const diff_sptr d) const;
669 
670   void
671   initialize_canonical_diff(const diff_sptr diff);
672 
673   void
674   keep_diff_alive(diff_sptr&);
675 
676   diff*
677   diff_has_been_visited(const diff*) const;
678 
679   diff_sptr
680   diff_has_been_visited(const diff_sptr) const;
681 
682   void
683   mark_diff_as_visited(const diff*);
684 
685   void
686   forget_visited_diffs();
687 
688   void
689   mark_last_diff_visited_per_class_of_equivalence(const diff*);
690 
691   void
692   clear_last_diffs_visited_per_class_of_equivalence();
693 
694   const diff*
695   get_last_visited_diff_of_class_of_equivalence(const diff*);
696 
697   void
698   forbid_visiting_a_node_twice(bool f);
699 
700   bool
701   visiting_a_node_twice_is_forbidden() const;
702 
703   void
704   forbid_visiting_a_node_twice_per_interface(bool);
705 
706   bool
707   visiting_a_node_twice_is_forbidden_per_interface() const;
708 
709   diff_category
710   get_allowed_category() const;
711 
712   void
713   set_allowed_category(diff_category c);
714 
715   void
716   switch_categories_on(diff_category c);
717 
718   void
719   switch_categories_off(diff_category c);
720 
721   const filtering::filters&
722   diff_filters() const;
723 
724   void
725   add_diff_filter(filtering::filter_base_sptr);
726 
727   void
728   maybe_apply_filters(diff_sptr diff);
729 
730   void
731   maybe_apply_filters(corpus_diff_sptr diff);
732 
733   suppr::suppressions_type&
734   suppressions() const;
735 
736   void
737   add_suppression(const suppr::suppression_sptr suppr);
738 
739   void
740   add_suppressions(const suppr::suppressions_type& supprs);
741 
742   void
743   show_leaf_changes_only(bool f);
744 
745   bool
746   show_leaf_changes_only() const;
747 
748   bool
749   show_hex_values() const;
750 
751   void
752   show_hex_values(bool f);
753 
754   bool
755   show_offsets_sizes_in_bits() const;
756 
757   void
758   show_offsets_sizes_in_bits(bool f);
759 
760   void
761   show_relative_offset_changes(bool f);
762 
763   bool
764   show_relative_offset_changes(void);
765 
766   void
767   show_stats_only(bool f);
768 
769   bool
770   show_stats_only() const;
771 
772   void
773   show_soname_change(bool f);
774 
775   bool
776   show_soname_change() const;
777 
778   void
779   show_architecture_change(bool f);
780 
781   bool
782   show_architecture_change() const;
783 
784   void
785   show_deleted_fns(bool f);
786 
787   bool
788   show_deleted_fns() const;
789 
790   void
791   show_changed_fns(bool f);
792 
793   bool
794   show_changed_fns() const;
795 
796   void
797   show_added_fns(bool f);
798 
799   bool
800   show_added_fns() const;
801 
802   void
803   show_deleted_vars(bool f);
804 
805   bool
806   show_deleted_vars() const;
807 
808   void
809   show_changed_vars(bool f);
810 
811   bool
812   show_changed_vars() const;
813 
814   void
815   show_added_vars(bool f);
816 
817   bool
818   show_added_vars() const;
819 
820   bool
821   show_linkage_names() const;
822 
823   void
824   show_linkage_names(bool f);
825 
826   bool
827   show_locs() const;
828 
829   void
830   show_locs(bool f);
831 
832   bool
833   show_redundant_changes() const;
834 
835   void
836   show_redundant_changes(bool f);
837 
838   bool
839   flag_indirect_changes() const;
840 
841   void
842   flag_indirect_changes(bool f);
843 
844   bool
845   show_symbols_unreferenced_by_debug_info() const;
846 
847   void
848   show_symbols_unreferenced_by_debug_info(bool f);
849 
850   bool
851   show_added_symbols_unreferenced_by_debug_info() const;
852 
853   void
854   show_added_symbols_unreferenced_by_debug_info(bool f);
855 
856   void show_unreachable_types(bool f);
857 
858   bool show_unreachable_types();
859 
860   bool
861   show_impacted_interfaces() const;
862 
863   void
864   show_impacted_interfaces(bool f);
865 
866   void
867   default_output_stream(ostream*);
868 
869   ostream*
870   default_output_stream();
871 
872   void
873   error_output_stream(ostream*);
874 
875   ostream*
876   error_output_stream() const;
877 
878   bool
879   dump_diff_tree() const;
880 
881   void
882   dump_diff_tree(bool f);
883 
884   void
885   do_dump_diff_tree(const diff_sptr) const;
886 
887   void
888   do_dump_diff_tree(const corpus_diff_sptr) const;
889 
890   friend class_diff_sptr
891   compute_diff(const class_decl_sptr	first,
892 	       const class_decl_sptr	second,
893 	       diff_context_sptr	ctxt);
894 };//end struct diff_context.
895 
896 /// The abstraction of a change between two ABI artifacts.
897 ///
898 /// Please read more about the @ref DiffNode "IR" of the comparison
899 /// engine to learn more about this.
900 ///
901 /// This type encapsulates an edit script (a set of insertions and
902 /// deletions) for two constructs that are to be diff'ed.  The two
903 /// constructs are called the "subjects" of the diff.
904 class diff : public diff_traversable_base
905 {
906   friend class diff_context;
907 
908   // Forbidden
909   diff();
910 
911 protected:
912   struct priv;
913   std::unique_ptr<priv> priv_;
914 
915   diff(type_or_decl_base_sptr first_subject,
916        type_or_decl_base_sptr second_subject);
917 
918   diff(type_or_decl_base_sptr	first_subject,
919        type_or_decl_base_sptr	second_subject,
920        diff_context_sptr	ctxt);
921 
922   void
923   begin_traversing();
924 
925   void
926   end_traversing();
927 
928   virtual void
929   finish_diff_type();
930 
931   void
932   set_canonical_diff(diff *);
933 
934 public:
935   type_or_decl_base_sptr
936   first_subject() const;
937 
938   type_or_decl_base_sptr
939   second_subject() const;
940 
941   const vector<diff*>&
942   children_nodes() const;
943 
944   const diff*
945   parent_node() const;
946 
947   diff* get_canonical_diff() const;
948 
949   bool
950   is_traversing() const;
951 
952   void
953   append_child_node(diff_sptr);
954 
955   const diff_context_sptr
956   context() const;
957 
958   void
959   context(diff_context_sptr c);
960 
961   bool
962   currently_reporting() const;
963 
964   void
965   currently_reporting(bool f) const;
966 
967   bool
968   reported_once() const;
969 
970   void
971   reported_once(bool f) const;
972 
973   diff_category
974   get_category() const;
975 
976   diff_category
977   get_local_category() const;
978 
979   diff_category
980   get_class_of_equiv_category() const;
981 
982   diff_category
983   add_to_category(diff_category c);
984 
985   diff_category
986   add_to_local_category(diff_category c);
987 
988   void
989   add_to_local_and_inherited_categories(diff_category c);
990 
991   diff_category
992   remove_from_category(diff_category c);
993 
994   diff_category
995   remove_from_local_category(diff_category c);
996 
997   void
998   set_category(diff_category c);
999 
1000   void
1001   set_local_category(diff_category c);
1002 
1003   bool
1004   is_filtered_out() const;
1005 
1006   bool
1007   is_filtered_out_wrt_non_inherited_categories() const;
1008 
1009   bool
1010   is_suppressed() const;
1011 
1012   bool
1013   is_suppressed(bool &is_private_type) const;
1014 
1015   bool
1016   to_be_reported() const;
1017 
1018   bool
1019   has_local_changes_to_be_reported() const;
1020 
1021   virtual const string&
1022   get_pretty_representation() const;
1023 
1024   virtual void
1025   chain_into_hierarchy();
1026 
1027   /// Pure interface to get the length of the changes encapsulated by
1028   /// this diff.  A length of zero means that the current instance of
1029   /// @ref diff doesn't carry any change.
1030   ///
1031   /// This is to be implemented by all descendants of this type.
1032   virtual bool
1033   has_changes() const = 0;
1034 
1035   /// Pure interface to know if the current instance of @diff carries
1036   /// a local change.  A local change is a change that is on the @ref
1037   /// diff object itself, as opposed to a change that is carried by
1038   /// some of its children nodes.
1039   ///
1040   /// This is to be implemented by all descendants of this type.
1041   virtual enum change_kind
1042   has_local_changes() const = 0;
1043 
1044   /// Pure interface to report the diff in a serialized form that is
1045   /// legible for the user.
1046   ///
1047   /// Note that the serializd report has to leave one empty line at
1048   /// the end of its content.
1049   ///
1050   /// @param out the output stream to serialize the report to.
1051   ///
1052   /// @param indent the indentation string to use.
1053   virtual void
1054   report(ostream& out, const string& indent = "") const = 0;
1055 
1056   virtual bool
1057   traverse(diff_node_visitor& v);
1058 };// end class diff
1059 
1060 diff_sptr
1061 compute_diff(const decl_base_sptr,
1062 	     const decl_base_sptr,
1063 	     diff_context_sptr ctxt);
1064 
1065 diff_sptr
1066 compute_diff(const type_base_sptr,
1067 	     const type_base_sptr,
1068 	     diff_context_sptr ctxt);
1069 
1070 /// The base class of diff between types.
1071 class type_diff_base : public diff
1072 {
1073   struct priv;
1074   std::unique_ptr<priv> priv_;
1075 
1076   type_diff_base();
1077 
1078 protected:
1079   type_diff_base(type_base_sptr	first_subject,
1080 		 type_base_sptr	second_subject,
1081 		 diff_context_sptr	ctxt);
1082 
1083 public:
1084 
1085   virtual enum change_kind
1086   has_local_changes() const = 0;
1087 
1088   virtual ~type_diff_base();
1089 };// end class type_diff_base
1090 
1091 /// The base class of diff between decls.
1092 class decl_diff_base : public diff
1093 {
1094   struct priv;
1095   std::unique_ptr<priv> priv_;
1096 
1097 protected:
1098   decl_diff_base(decl_base_sptr	first_subject,
1099 		 decl_base_sptr	second_subject,
1100 		 diff_context_sptr	ctxt);
1101 
1102 public:
1103 
1104   virtual enum change_kind
1105   has_local_changes() const = 0;
1106 
1107   virtual ~decl_diff_base();
1108 };// end class decl_diff_base
1109 
1110 string
1111 get_pretty_representation(diff*);
1112 
1113 class distinct_diff;
1114 
1115 /// Convenience typedef for a shared pointer to distinct_types_diff
1116 typedef shared_ptr<distinct_diff> distinct_diff_sptr;
1117 
1118 /// An abstraction of a diff between entities that are of a different
1119 /// kind (disctinct).
1120 class distinct_diff : public diff
1121 {
1122   struct priv;
1123   std::unique_ptr<priv> priv_;
1124 
1125 protected:
1126   distinct_diff(type_or_decl_base_sptr first,
1127 		type_or_decl_base_sptr second,
1128 		diff_context_sptr ctxt = diff_context_sptr());
1129 
1130   virtual void
1131   finish_diff_type();
1132 
1133 public:
1134 
1135   const type_or_decl_base_sptr
1136   first() const;
1137 
1138   const type_or_decl_base_sptr
1139   second() const;
1140 
1141   const diff_sptr
1142   compatible_child_diff() const;
1143 
1144   virtual const string&
1145   get_pretty_representation() const;
1146 
1147   virtual bool
1148   has_changes() const;
1149 
1150   virtual enum change_kind
1151   has_local_changes() const;
1152 
1153   virtual void
1154   report(ostream& out, const string& indent = "") const;
1155 
1156   virtual void
1157   chain_into_hierarchy();
1158 
1159   static bool
1160   entities_are_of_distinct_kinds(type_or_decl_base_sptr first,
1161 				 type_or_decl_base_sptr second);
1162 
1163   friend distinct_diff_sptr
1164   compute_diff_for_distinct_kinds(const type_or_decl_base_sptr first,
1165 				  const type_or_decl_base_sptr second,
1166 				  diff_context_sptr ctxt);
1167 };// end class distinct_types_diff
1168 
1169 distinct_diff_sptr
1170 compute_diff_for_distinct_kinds(const type_or_decl_base_sptr,
1171 				const type_or_decl_base_sptr,
1172 				diff_context_sptr ctxt);
1173 
1174 /// Abstracts a diff between two instances of @ref var_decl
1175 class var_diff : public decl_diff_base
1176 {
1177   struct priv;
1178   std::unique_ptr<priv> priv_;
1179 
1180 protected:
1181   var_diff(var_decl_sptr first,
1182 	   var_decl_sptr second,
1183 	   diff_sptr type_diff,
1184 	   diff_context_sptr ctxt = diff_context_sptr());
1185 
1186   virtual void
1187   finish_diff_type();
1188 
1189 public:
1190   var_decl_sptr
1191   first_var() const;
1192 
1193   var_decl_sptr
1194   second_var() const;
1195 
1196   diff_sptr
1197   type_diff() const;
1198 
1199   virtual void
1200   chain_into_hierarchy();
1201 
1202   virtual bool
1203   has_changes() const;
1204 
1205   virtual enum change_kind
1206   has_local_changes() const;
1207 
1208   virtual void
1209   report(ostream& out, const string& indent = "") const;
1210 
1211   virtual const string&
1212   get_pretty_representation() const;
1213 
1214   friend var_diff_sptr
1215   compute_diff(const var_decl_sptr	first,
1216 	       const var_decl_sptr	second,
1217 	       diff_context_sptr	ctxt);
1218 };// end class var_diff
1219 
1220 var_diff_sptr
1221 compute_diff(const var_decl_sptr, const var_decl_sptr, diff_context_sptr);
1222 
1223 class pointer_diff;
1224 /// Convenience typedef for a shared pointer on a @ref
1225 /// pointer_diff type.
1226 typedef shared_ptr<pointer_diff> pointer_diff_sptr;
1227 
1228 /// The abstraction of a diff between two pointers.
1229 class pointer_diff : public type_diff_base
1230 {
1231   struct priv;
1232   std::unique_ptr<priv> priv_;
1233 
1234 protected:
1235   pointer_diff(pointer_type_def_sptr	first,
1236 	       pointer_type_def_sptr	second,
1237 	       diff_sptr		underlying_type_diff,
1238 	       diff_context_sptr	ctxt = diff_context_sptr());
1239 
1240   virtual void
1241   finish_diff_type();
1242 
1243 public:
1244   const pointer_type_def_sptr
1245   first_pointer() const;
1246 
1247   const pointer_type_def_sptr
1248   second_pointer() const;
1249 
1250   diff_sptr
1251   underlying_type_diff() const;
1252 
1253   void
1254   underlying_type_diff(const diff_sptr);
1255 
1256   virtual const string&
1257   get_pretty_representation() const;
1258 
1259   virtual bool
1260   has_changes() const;
1261 
1262   virtual enum change_kind
1263   has_local_changes() const;
1264 
1265   virtual void
1266   report(ostream&, const string& indent = "") const;
1267 
1268   virtual void
1269   chain_into_hierarchy();
1270 
1271   friend pointer_diff_sptr
1272   compute_diff(pointer_type_def_sptr	first,
1273 	       pointer_type_def_sptr	second,
1274 	       diff_context_sptr	ctxt);
1275 };// end class pointer_diff
1276 
1277 pointer_diff_sptr
1278 compute_diff(pointer_type_def_sptr first,
1279 	     pointer_type_def_sptr second,
1280 	     diff_context_sptr ctxt);
1281 
1282 class reference_diff;
1283 
1284 /// Convenience typedef for a shared pointer on a @ref
1285 /// reference_diff type.
1286 typedef shared_ptr<reference_diff> reference_diff_sptr;
1287 
1288 /// The abstraction of a diff between two references.
1289 class reference_diff : public type_diff_base
1290 {
1291   struct priv;
1292   std::unique_ptr<priv> priv_;
1293 
1294 protected:
1295   reference_diff(const reference_type_def_sptr	first,
1296 		 const reference_type_def_sptr	second,
1297 		 diff_sptr			underlying,
1298 		 diff_context_sptr		ctxt = diff_context_sptr());
1299 
1300   virtual void
1301   finish_diff_type();
1302 
1303 public:
1304   reference_type_def_sptr
1305   first_reference() const;
1306 
1307   reference_type_def_sptr
1308   second_reference() const;
1309 
1310   const diff_sptr&
1311   underlying_type_diff() const;
1312 
1313   diff_sptr&
1314   underlying_type_diff(diff_sptr);
1315 
1316   virtual const string&
1317   get_pretty_representation() const;
1318 
1319   virtual bool
1320   has_changes() const;
1321 
1322   virtual enum change_kind
1323   has_local_changes() const;
1324 
1325   virtual void
1326   report(ostream&, const string& indent = "") const;
1327 
1328   virtual void
1329   chain_into_hierarchy();
1330 
1331   friend reference_diff_sptr
1332   compute_diff(reference_type_def_sptr first,
1333 	       reference_type_def_sptr second,
1334 	       diff_context_sptr ctxt);
1335 };// end class reference_diff
1336 
1337 reference_diff_sptr
1338 compute_diff(reference_type_def_sptr first,
1339 	     reference_type_def_sptr second,
1340 	     diff_context_sptr ctxt);
1341 
1342 class array_diff;
1343 
1344 /// Convenience typedef for a shared pointer on a @ref
1345 /// array_diff type.
1346 typedef shared_ptr<array_diff> array_diff_sptr;
1347 
1348 /// The abstraction of a diff between two arrays.
1349 class array_diff : public type_diff_base
1350 {
1351   struct priv;
1352   std::unique_ptr<priv> priv_;
1353 
1354 protected:
1355   array_diff(const array_type_def_sptr	first,
1356 	     const array_type_def_sptr	second,
1357 	     diff_sptr			element_type_diff,
1358 	     diff_context_sptr		ctxt = diff_context_sptr());
1359 
1360   virtual void
1361   finish_diff_type();
1362 
1363 public:
1364   const array_type_def_sptr
1365   first_array() const;
1366 
1367   const array_type_def_sptr
1368   second_array() const;
1369 
1370   const diff_sptr&
1371   element_type_diff() const;
1372 
1373   void
1374   element_type_diff(diff_sptr);
1375 
1376   virtual const string&
1377   get_pretty_representation() const;
1378 
1379   virtual bool
1380   has_changes() const;
1381 
1382   virtual enum change_kind
1383   has_local_changes() const;
1384 
1385   virtual void
1386   report(ostream&, const string& indent = "") const;
1387 
1388   virtual void
1389   chain_into_hierarchy();
1390 
1391   friend array_diff_sptr
1392   compute_diff(array_type_def_sptr first,
1393 	       array_type_def_sptr second,
1394 	       diff_context_sptr ctxt);
1395 };// end class array_diff
1396 
1397 array_diff_sptr
1398 compute_diff(array_type_def_sptr first,
1399 	     array_type_def_sptr second,
1400 	     diff_context_sptr ctxt);
1401 
1402 class qualified_type_diff;
1403 typedef class shared_ptr<qualified_type_diff> qualified_type_diff_sptr;
1404 
1405 /// Abstraction of a diff between two qualified types.
1406 class qualified_type_diff : public type_diff_base
1407 {
1408   struct priv;
1409   std::unique_ptr<priv> priv_;
1410 
1411 protected:
1412   qualified_type_diff(qualified_type_def_sptr	first,
1413 		      qualified_type_def_sptr	second,
1414 		      diff_sptr		underling,
1415 		      diff_context_sptr	ctxt = diff_context_sptr());
1416 
1417   virtual void
1418   finish_diff_type();
1419 
1420 public:
1421   const qualified_type_def_sptr
1422   first_qualified_type() const;
1423 
1424   const qualified_type_def_sptr
1425   second_qualified_type() const;
1426 
1427   diff_sptr
1428   underlying_type_diff() const;
1429 
1430   void
1431   underlying_type_diff(const diff_sptr);
1432 
1433   diff_sptr
1434   leaf_underlying_type_diff() const;
1435 
1436   virtual const string&
1437   get_pretty_representation() const;
1438 
1439   virtual bool
1440   has_changes() const;
1441 
1442   virtual enum change_kind
1443   has_local_changes() const;
1444 
1445   virtual void
1446   report(ostream&, const string& indent = "") const;
1447 
1448   virtual void
1449   chain_into_hierarchy();
1450 
1451   friend qualified_type_diff_sptr
1452   compute_diff(const qualified_type_def_sptr first,
1453 	       const qualified_type_def_sptr second,
1454 	       diff_context_sptr ctxt);
1455 };// end class qualified_type_diff.
1456 
1457 qualified_type_diff_sptr
1458 compute_diff(const qualified_type_def_sptr first,
1459 	     const qualified_type_def_sptr second,
1460 	     diff_context_sptr ctxt);
1461 
1462 class enum_diff;
1463 typedef shared_ptr<enum_diff> enum_diff_sptr;
1464 
1465 /// Abstraction of a diff between two enums.
1466 class enum_diff : public type_diff_base
1467 {
1468   struct priv;
1469   std::unique_ptr<priv> priv_;
1470 
1471   void
1472   clear_lookup_tables();
1473 
1474   bool
1475   lookup_tables_empty() const;
1476 
1477   void
1478   ensure_lookup_tables_populated();
1479 
1480 protected:
1481   enum_diff(const enum_type_decl_sptr,
1482 	    const enum_type_decl_sptr,
1483 	    const diff_sptr,
1484 	    diff_context_sptr ctxt = diff_context_sptr());
1485 
1486   virtual void
1487   finish_diff_type();
1488 
1489 public:
1490   const enum_type_decl_sptr
1491   first_enum() const;
1492 
1493   const enum_type_decl_sptr
1494   second_enum() const;
1495 
1496   diff_sptr
1497   underlying_type_diff() const;
1498 
1499   const string_enumerator_map&
1500   deleted_enumerators() const;
1501 
1502   const string_enumerator_map&
1503   inserted_enumerators() const;
1504 
1505   const string_changed_enumerator_map&
1506   changed_enumerators() const;
1507 
1508   virtual const string&
1509   get_pretty_representation() const;
1510 
1511   virtual bool
1512   has_changes() const;
1513 
1514   virtual enum change_kind
1515   has_local_changes() const;
1516 
1517   virtual void
1518   report(ostream&, const string& indent = "") const;
1519 
1520   virtual void
1521   chain_into_hierarchy();
1522 
1523   friend enum_diff_sptr
1524   compute_diff(const enum_type_decl_sptr first,
1525 	       const enum_type_decl_sptr second,
1526 	       diff_context_sptr ctxt);
1527 };//end class enum_diff;
1528 
1529 enum_diff_sptr
1530 compute_diff(const enum_type_decl_sptr,
1531 	     const enum_type_decl_sptr,
1532 	     diff_context_sptr);
1533 
1534 /// This is the base class of @ref class_diff and @ref union_diff.
1535 class class_or_union_diff : public type_diff_base
1536 {
1537 protected:
1538   struct priv;
1539   typedef std::unique_ptr<priv> priv_ptr;
1540   priv_ptr priv_;
1541 
1542   void
1543   clear_lookup_tables(void);
1544 
1545   bool
1546   lookup_tables_empty(void) const;
1547 
1548   void
1549   ensure_lookup_tables_populated(void) const;
1550 
1551   void
1552   allocate_priv_data();
1553 
1554 protected:
1555   class_or_union_diff(class_or_union_sptr first_scope,
1556 		      class_or_union_sptr second_scope,
1557 		      diff_context_sptr ctxt = diff_context_sptr());
1558 
1559   virtual void
1560   finish_diff_type();
1561 
1562 public:
1563 
1564   const class_or_union_diff::priv_ptr&
1565   get_priv() const;
1566 
1567   //TODO: add change of the name of the type.
1568 
1569   virtual ~class_or_union_diff();
1570 
1571   class_or_union_sptr
1572   first_class_or_union() const;
1573 
1574   class_or_union_sptr
1575   second_class_or_union() const;
1576 
1577   const edit_script&
1578   member_types_changes() const;
1579 
1580   edit_script&
1581   member_types_changes();
1582 
1583   const edit_script&
1584   data_members_changes() const;
1585 
1586   edit_script&
1587   data_members_changes();
1588 
1589   const string_decl_base_sptr_map&
1590   inserted_data_members() const;
1591 
1592   const string_decl_base_sptr_map&
1593   deleted_data_members() const;
1594 
1595   const edit_script&
1596   member_fns_changes() const;
1597 
1598   edit_script&
1599   member_fns_changes();
1600 
1601   const function_decl_diff_sptrs_type&
1602   changed_member_fns() const;
1603 
1604   const string_member_function_sptr_map&
1605   deleted_member_fns() const;
1606 
1607   const string_member_function_sptr_map&
1608   inserted_member_fns() const;
1609 
1610   const var_diff_sptrs_type&
1611   sorted_changed_data_members() const;
1612 
1613   size_t
1614   count_filtered_changed_data_members(bool local_only = false) const;
1615 
1616   const var_diff_sptrs_type&
1617   sorted_subtype_changed_data_members() const;
1618 
1619   size_t
1620   count_filtered_subtype_changed_data_members(bool local_only = false) const;
1621 
1622   const string_decl_base_sptr_map&
1623   data_members_replaced_by_adms() const;
1624 
1625   const changed_var_sptrs_type&
1626   ordered_data_members_replaced_by_adms() const;
1627 
1628   const edit_script&
1629   member_fn_tmpls_changes() const;
1630 
1631   edit_script&
1632   member_fn_tmpls_changes();
1633 
1634   const edit_script&
1635   member_class_tmpls_changes() const;
1636 
1637   edit_script&
1638   member_class_tmpls_changes();
1639 
1640   virtual bool
1641   has_changes() const;
1642 
1643   virtual enum change_kind
1644   has_local_changes() const;
1645 
1646   virtual void
1647   report(ostream&, const string& indent = "") const;
1648 
1649   virtual void
1650   chain_into_hierarchy();
1651 
1652   friend class default_reporter;
1653 }; // end class_or_union_diff;
1654 
1655 /// This type abstracts changes for a class_decl.
1656 class class_diff : public class_or_union_diff
1657 {
1658   struct priv;
1659   typedef std::unique_ptr<priv> priv_ptr;
1660   priv_ptr priv_;
1661 
1662   const priv_ptr& get_priv()const;
1663 
1664   void
1665   clear_lookup_tables(void);
1666 
1667   bool
1668   lookup_tables_empty(void) const;
1669 
1670   void
1671   ensure_lookup_tables_populated(void) const;
1672 
1673   void
1674    allocate_priv_data();
1675 
1676 protected:
1677   class_diff(class_decl_sptr first_scope,
1678 	     class_decl_sptr second_scope,
1679 	     diff_context_sptr ctxt = diff_context_sptr());
1680 
1681   virtual void
1682   finish_diff_type();
1683 
1684 public:
1685   //TODO: add change of the name of the type.
1686 
1687   virtual ~class_diff();
1688 
1689   class_decl_sptr
1690   first_class_decl() const;
1691 
1692   class_decl_sptr
1693   second_class_decl() const;
1694 
1695   const edit_script&
1696   base_changes() const;
1697 
1698   edit_script&
1699   base_changes();
1700 
1701   const string_base_sptr_map&
1702   deleted_bases() const;
1703 
1704   const string_base_sptr_map&
1705   inserted_bases() const;
1706 
1707   const base_diff_sptrs_type&
1708   changed_bases();
1709 
1710   virtual bool
1711   has_changes() const;
1712 
1713   virtual enum change_kind
1714   has_local_changes() const;
1715 
1716   virtual const string&
1717   get_pretty_representation() const;
1718 
1719   virtual void
1720   report(ostream&, const string& indent = "") const;
1721 
1722   virtual void
1723   chain_into_hierarchy();
1724 
1725   friend class_diff_sptr
1726   compute_diff(const class_decl_sptr	first,
1727 	       const class_decl_sptr	second,
1728 	       diff_context_sptr	ctxt);
1729 
1730   friend class default_reporter;
1731 };// end class_diff
1732 
1733 class_diff_sptr
1734 compute_diff(const class_decl_sptr	first,
1735 	     const class_decl_sptr	second,
1736 	     diff_context_sptr		ctxt);
1737 
1738 class union_diff;
1739 typedef shared_ptr<union_diff> union_diff_sptr;
1740 
1741 class union_diff : public class_or_union_diff
1742 {
1743   void
1744   clear_lookup_tables(void);
1745 
1746   bool
1747   lookup_tables_empty(void) const;
1748 
1749   void
1750   ensure_lookup_tables_populated(void) const;
1751 
1752   void
1753   allocate_priv_data();
1754 
1755 protected:
1756   union_diff(union_decl_sptr first_union,
1757 	     union_decl_sptr second_union,
1758 	     diff_context_sptr ctxt = diff_context_sptr());
1759 
1760   virtual void
1761   finish_diff_type();
1762 
1763 public:
1764 
1765   virtual ~union_diff();
1766 
1767   union_decl_sptr
1768   first_union_decl() const;
1769 
1770   union_decl_sptr
1771   second_union_decl() const;
1772 
1773   virtual const string&
1774   get_pretty_representation() const;
1775 
1776   virtual void
1777   report(ostream&, const string& indent = "") const;
1778 
1779   friend union_diff_sptr
1780   compute_diff(const union_decl_sptr	first,
1781 	       const union_decl_sptr	second,
1782 	       diff_context_sptr	ctxt);
1783 }; // end class union_diff
1784 
1785 union_diff_sptr
1786 compute_diff(const union_decl_sptr	first,
1787 	     const union_decl_sptr	second,
1788 	     diff_context_sptr	ctxt);
1789 
1790 /// An abstraction of a diff between two instances of class_decl::base_spec.
1791 class base_diff : public diff
1792 {
1793   struct priv;
1794   std::unique_ptr<priv> priv_;
1795 
1796 protected:
1797   base_diff(class_decl::base_spec_sptr	first,
1798 	    class_decl::base_spec_sptr	second,
1799 	    class_diff_sptr		underlying,
1800 	    diff_context_sptr		ctxt = diff_context_sptr());
1801 
1802   virtual void
1803   finish_diff_type();
1804 
1805 public:
1806   class_decl::base_spec_sptr
1807   first_base() const;
1808 
1809   class_decl::base_spec_sptr
1810   second_base() const;
1811 
1812   const class_diff_sptr
1813   get_underlying_class_diff() const;
1814 
1815   void
1816   set_underlying_class_diff(class_diff_sptr d);
1817 
1818   virtual const string&
1819   get_pretty_representation() const;
1820 
1821   virtual bool
1822   has_changes() const;
1823 
1824   virtual enum change_kind
1825   has_local_changes() const;
1826 
1827   virtual void
1828   report(ostream&, const string& indent = "") const;
1829 
1830   virtual void
1831   chain_into_hierarchy();
1832 
1833   friend base_diff_sptr
1834   compute_diff(const class_decl::base_spec_sptr first,
1835 	       const class_decl::base_spec_sptr second,
1836 	       diff_context_sptr		ctxt);
1837 };// end class base_diff
1838 
1839 base_diff_sptr
1840 compute_diff(const class_decl::base_spec_sptr first,
1841 	     const class_decl::base_spec_sptr second,
1842 	     diff_context_sptr		ctxt);
1843 
1844 class scope_diff;
1845 
1846 /// Convenience typedef for a shared pointer on a @ref scope_diff.
1847 typedef shared_ptr<scope_diff> scope_diff_sptr;
1848 
1849 /// An abstractions of the changes between two scopes.
1850 class scope_diff : public diff
1851 {
1852   struct priv;
1853   std::unique_ptr<priv> priv_;
1854 
1855   bool
1856   lookup_tables_empty() const;
1857 
1858   void
1859   clear_lookup_tables();
1860 
1861   void
1862   ensure_lookup_tables_populated();
1863 
1864 protected:
1865   scope_diff(scope_decl_sptr first_scope,
1866 	     scope_decl_sptr second_scope,
1867 	     diff_context_sptr ctxt = diff_context_sptr());
1868 
1869   virtual void
1870   finish_diff_type();
1871 
1872 public:
1873 
1874   friend scope_diff_sptr
1875   compute_diff(const scope_decl_sptr	first,
1876 	       const scope_decl_sptr	second,
1877 	       scope_diff_sptr		d,
1878 	       diff_context_sptr	ctxt);
1879 
1880   friend scope_diff_sptr
1881   compute_diff(const scope_decl_sptr	first_scope,
1882 	       const scope_decl_sptr	second_scope,
1883 	       diff_context_sptr	ctxt);
1884 
1885   const scope_decl_sptr
1886   first_scope() const;
1887 
1888   const scope_decl_sptr
1889   second_scope() const;
1890 
1891   const edit_script&
1892   member_changes() const;
1893 
1894   edit_script&
1895   member_changes();
1896 
1897   const decl_base_sptr
1898   deleted_member_at(unsigned index) const;
1899 
1900   const decl_base_sptr
1901   deleted_member_at(vector<deletion>::const_iterator) const;
1902 
1903   const decl_base_sptr
1904   inserted_member_at(unsigned i);
1905 
1906   const decl_base_sptr
1907   inserted_member_at(vector<unsigned>::const_iterator i);
1908 
1909   const diff_sptrs_type&
1910   changed_types() const;
1911 
1912   const diff_sptrs_type&
1913   changed_decls() const;
1914 
1915   const string_decl_base_sptr_map&
1916   removed_types() const;
1917 
1918   const string_decl_base_sptr_map&
1919   removed_decls() const;
1920 
1921   const string_decl_base_sptr_map&
1922   added_types() const;
1923 
1924   const string_decl_base_sptr_map&
1925   added_decls() const;
1926 
1927   virtual const string&
1928   get_pretty_representation() const;
1929 
1930   virtual bool
1931   has_changes() const;
1932 
1933   virtual enum change_kind
1934   has_local_changes() const;
1935 
1936   virtual void
1937   report(ostream& out, const string& indent = "") const;
1938 
1939   virtual void
1940   chain_into_hierarchy();
1941 
1942   friend class default_reporter;
1943   friend class leaf_reporter;
1944 };// end class scope_diff
1945 
1946 scope_diff_sptr
1947 compute_diff(const scope_decl_sptr first,
1948 	     const scope_decl_sptr second,
1949 	     scope_diff_sptr d,
1950 	     diff_context_sptr ctxt);
1951 
1952 scope_diff_sptr
1953 compute_diff(const scope_decl_sptr first_scope,
1954 	     const scope_decl_sptr second_scope,
1955 	     diff_context_sptr ctxt);
1956 
1957 /// Abstraction of a diff between two function parameters.
1958 class fn_parm_diff : public decl_diff_base
1959 {
1960   struct priv;
1961   std::unique_ptr<priv> priv_;
1962 
1963   virtual void
1964   finish_diff_type();
1965 
1966   fn_parm_diff(const function_decl::parameter_sptr	first,
1967 	       const function_decl::parameter_sptr	second,
1968 	       diff_context_sptr			ctxt);
1969 
1970 public:
1971   friend fn_parm_diff_sptr
1972   compute_diff(const function_decl::parameter_sptr	first,
1973 	       const function_decl::parameter_sptr	second,
1974 	       diff_context_sptr			ctxt);
1975 
1976   const function_decl::parameter_sptr
1977   first_parameter() const;
1978 
1979   const function_decl::parameter_sptr
1980   second_parameter() const;
1981 
1982   diff_sptr
1983   type_diff() const;
1984 
1985   virtual const string&
1986   get_pretty_representation() const;
1987 
1988   virtual bool
1989   has_changes() const;
1990 
1991   virtual enum change_kind
1992   has_local_changes() const;
1993 
1994   virtual void
1995   report(ostream&, const string& indent = "") const;
1996 
1997   virtual void
1998   chain_into_hierarchy();
1999 }; // end class fn_parm_diff
2000 
2001 fn_parm_diff_sptr
2002 compute_diff(const function_decl::parameter_sptr	first,
2003 	     const function_decl::parameter_sptr	second,
2004 	     diff_context_sptr				ctxt);
2005 
2006 class function_type_diff;
2007 
2008 /// A convenience typedef for a shared pointer to @ref
2009 /// function_type_type_diff
2010 typedef shared_ptr<function_type_diff> function_type_diff_sptr;
2011 
2012 /// Abstraction of a diff between two function types.
2013 class function_type_diff: public type_diff_base
2014 {
2015   struct priv;
2016   std::unique_ptr<priv> priv_;
2017 
2018   void
2019   ensure_lookup_tables_populated();
2020 
2021   const function_decl::parameter_sptr
2022   deleted_parameter_at(int i) const;
2023 
2024   const function_decl::parameter_sptr
2025   inserted_parameter_at(int i) const;
2026 
2027 protected:
2028   function_type_diff(const function_type_sptr	first,
2029 		     const function_type_sptr	second,
2030 		     diff_context_sptr		ctxt);
2031 
2032   virtual void
2033   finish_diff_type();
2034 
2035 public:
2036   friend function_type_diff_sptr
2037   compute_diff(const function_type_sptr	first,
2038 	       const function_type_sptr	second,
2039 	       diff_context_sptr		ctxt);
2040 
2041   const function_type_sptr
2042   first_function_type() const;
2043 
2044   const function_type_sptr
2045   second_function_type() const;
2046 
2047   const diff_sptr
2048   return_type_diff() const;
2049 
2050   const string_fn_parm_diff_sptr_map&
2051   subtype_changed_parms() const;
2052 
2053   const string_parm_map&
2054   removed_parms() const;
2055 
2056   const string_parm_map&
2057   added_parms() const;
2058 
2059   const vector<function_decl::parameter_sptr>&
2060   sorted_deleted_parms() const;
2061 
2062   const vector<function_decl::parameter_sptr>&
2063   sorted_added_parms() const;
2064 
2065   virtual const string&
2066   get_pretty_representation() const;
2067 
2068   virtual bool
2069   has_changes() const;
2070 
2071   virtual enum change_kind
2072   has_local_changes() const;
2073 
2074   virtual void
2075   report(ostream&, const string& indent = "") const;
2076 
2077   virtual void
2078   chain_into_hierarchy();
2079 
2080   friend class default_reporter;
2081   friend class leaf_reporter;
2082 };// end class function_type_diff
2083 
2084 function_type_diff_sptr
2085 compute_diff(const function_type_sptr	first,
2086 	     const function_type_sptr	second,
2087 	     diff_context_sptr		ctxt);
2088 
2089 /// Abstraction of a diff between two function_decl.
2090 class function_decl_diff : public decl_diff_base
2091 {
2092   struct priv;
2093   std::unique_ptr<priv> priv_;
2094 
2095   void
2096   ensure_lookup_tables_populated();
2097 
2098 
2099 protected:
2100   function_decl_diff(const function_decl_sptr	first,
2101 		     const function_decl_sptr	second,
2102 		     diff_context_sptr		ctxt);
2103 
2104   virtual void
2105   finish_diff_type();
2106 
2107 public:
2108 
2109 friend function_decl_diff_sptr
2110 compute_diff(const function_decl_sptr	first,
2111 	     const function_decl_sptr	second,
2112 	     diff_context_sptr		ctxt);
2113 
2114   const function_decl_sptr
2115   first_function_decl() const;
2116 
2117   const function_decl_sptr
2118   second_function_decl() const;
2119 
2120   const function_type_diff_sptr
2121   type_diff() const;
2122 
2123   virtual const string&
2124   get_pretty_representation() const;
2125 
2126   virtual bool
2127   has_changes() const;
2128 
2129   virtual enum change_kind
2130   has_local_changes() const;
2131 
2132   virtual void
2133   report(ostream&, const string& indent = "") const;
2134 
2135   virtual void
2136   chain_into_hierarchy();
2137 }; // end class function_decl_diff
2138 
2139 function_decl_diff_sptr
2140 compute_diff(const function_decl_sptr	first,
2141 	     const function_decl_sptr	second,
2142 	     diff_context_sptr		ctxt);
2143 
2144 class type_decl_diff;
2145 
2146 /// Convenience typedef for a shared pointer on a @ref type_decl_diff type.
2147 typedef shared_ptr<type_decl_diff> type_decl_diff_sptr;
2148 
2149 /// Abstraction of a diff between two basic type declarations.
2150 class type_decl_diff : public type_diff_base
2151 {
2152   type_decl_diff();
2153 
2154 protected:
2155   type_decl_diff(const type_decl_sptr first,
2156 		 const type_decl_sptr second,
2157 		 diff_context_sptr ctxt = diff_context_sptr());
2158 
2159   virtual void
2160   finish_diff_type();
2161 
2162 public:
2163   friend type_decl_diff_sptr
2164   compute_diff(const type_decl_sptr	first,
2165 	       const type_decl_sptr	second,
2166 	       diff_context_sptr	ctxt);
2167 
2168   const type_decl_sptr
2169   first_type_decl() const;
2170 
2171   const type_decl_sptr
2172   second_type_decl() const;
2173 
2174   virtual const string&
2175   get_pretty_representation() const;
2176 
2177   virtual bool
2178   has_changes() const;
2179 
2180   virtual enum change_kind
2181   has_local_changes() const;
2182 
2183   virtual void
2184   report(ostream& out, const string& indent = "") const;
2185 };// end type_decl_diff
2186 
2187 type_decl_diff_sptr
2188 compute_diff(const type_decl_sptr,
2189 	     const type_decl_sptr,
2190 	     diff_context_sptr);
2191 
2192 class typedef_diff;
2193 
2194 /// Convenience typedef for a shared pointer on a typedef_diff type.
2195 typedef shared_ptr<typedef_diff> typedef_diff_sptr;
2196 
2197 /// Abstraction of a diff between two typedef_decl.
2198 class typedef_diff : public type_diff_base
2199 {
2200   struct priv;
2201   std::unique_ptr<priv> priv_;
2202 
2203   typedef_diff();
2204 
2205 protected:
2206   typedef_diff(const typedef_decl_sptr	first,
2207 	       const typedef_decl_sptr	second,
2208 	       const diff_sptr		underlying_type_diff,
2209 	       diff_context_sptr	ctxt = diff_context_sptr());
2210 
2211   virtual void
2212   finish_diff_type();
2213 
2214 public:
2215   friend typedef_diff_sptr
2216   compute_diff(const typedef_decl_sptr	first,
2217 	       const typedef_decl_sptr	second,
2218 	       diff_context_sptr	ctxt);
2219 
2220   const typedef_decl_sptr
2221   first_typedef_decl() const;
2222 
2223   const typedef_decl_sptr
2224   second_typedef_decl() const;
2225 
2226   const diff_sptr
2227   underlying_type_diff() const;
2228 
2229   void
2230   underlying_type_diff(const diff_sptr);
2231 
2232   virtual const string&
2233   get_pretty_representation() const;
2234 
2235   virtual bool
2236   has_changes() const;
2237 
2238   virtual enum change_kind
2239   has_local_changes() const;
2240 
2241   virtual void
2242   report(ostream&, const string& indent = "") const;
2243 
2244   virtual void
2245   chain_into_hierarchy();
2246 };// end class typedef_diff
2247 
2248 typedef_diff_sptr
2249 compute_diff(const typedef_decl_sptr,
2250 	     const typedef_decl_sptr,
2251 	     diff_context_sptr ctxt);
2252 
2253 const diff*
2254 get_typedef_diff_underlying_type_diff(const diff* diff);
2255 
2256 class translation_unit_diff;
2257 
2258 /// Convenience typedef for a shared pointer on a
2259 /// @ref translation_unit_diff type.
2260 typedef shared_ptr<translation_unit_diff> translation_unit_diff_sptr;
2261 
2262 /// An abstraction of a diff between two translation units.
2263 class translation_unit_diff : public scope_diff
2264 {
2265   struct priv;
2266   std::unique_ptr<priv> priv_;
2267 
2268 protected:
2269   translation_unit_diff(translation_unit_sptr	first,
2270 			translation_unit_sptr	second,
2271 			diff_context_sptr	ctxt = diff_context_sptr());
2272 
2273 public:
2274 
2275   const translation_unit_sptr
2276   first_translation_unit() const;
2277 
2278   const translation_unit_sptr
2279   second_translation_unit() const;
2280 
2281   friend translation_unit_diff_sptr
2282   compute_diff(const translation_unit_sptr	first,
2283 	       const translation_unit_sptr	second,
2284 	       diff_context_sptr		ctxt);
2285 
2286   virtual bool
2287   has_changes() const;
2288 
2289   virtual enum change_kind
2290   has_local_changes() const;
2291 
2292   virtual void
2293   report(ostream& out, const string& indent = "") const;
2294 };//end class translation_unit_diff
2295 
2296 translation_unit_diff_sptr
2297 compute_diff(const translation_unit_sptr first,
2298 	     const translation_unit_sptr second,
2299 	     diff_context_sptr ctxt = diff_context_sptr());
2300 
2301 /// An abstraction of a diff between between two abi corpus.
2302 class corpus_diff
2303 {
2304   struct priv;
2305   std::unique_ptr<priv> priv_;
2306 
2307 protected:
2308   corpus_diff(corpus_sptr	first,
2309 	      corpus_sptr	second,
2310 	      diff_context_sptr ctxt = diff_context_sptr());
2311 
2312   void
2313   finish_diff_type();
2314 
2315 public:
2316 
2317   class diff_stats;
2318 
2319   virtual ~corpus_diff();
2320 
2321   /// A convenience typedef for a shared pointer to @ref diff_stats
2322   typedef shared_ptr<diff_stats> diff_stats_sptr;
2323 
2324   corpus_sptr
2325   first_corpus() const;
2326 
2327   corpus_sptr
2328   second_corpus() const;
2329 
2330   const vector<diff*>&
2331   children_nodes() const;
2332 
2333   void
2334   append_child_node(diff_sptr);
2335 
2336   edit_script&
2337   function_changes() const;
2338 
2339   edit_script&
2340   variable_changes() const;
2341 
2342   bool
2343   soname_changed() const;
2344 
2345   bool
2346   architecture_changed() const;
2347 
2348   const string_function_ptr_map&
2349   deleted_functions() const;
2350 
2351   const string_function_ptr_map&
2352   added_functions();
2353 
2354   const string_function_decl_diff_sptr_map&
2355   changed_functions();
2356 
2357   const function_decl_diff_sptrs_type&
2358   changed_functions_sorted();
2359 
2360   const string_var_ptr_map&
2361   deleted_variables() const;
2362 
2363   const string_var_ptr_map&
2364   added_variables() const;
2365 
2366   const string_var_diff_sptr_map&
2367   changed_variables();
2368 
2369   const var_diff_sptrs_type&
2370   changed_variables_sorted();
2371 
2372   const string_elf_symbol_map&
2373   deleted_unrefed_function_symbols() const;
2374 
2375   const string_elf_symbol_map&
2376   added_unrefed_function_symbols() const;
2377 
2378   const string_elf_symbol_map&
2379   deleted_unrefed_variable_symbols() const;
2380 
2381   const string_elf_symbol_map&
2382   added_unrefed_variable_symbols() const;
2383 
2384   const string_type_base_sptr_map&
2385   deleted_unreachable_types() const;
2386 
2387   const vector<type_base_sptr>&
2388   deleted_unreachable_types_sorted() const;
2389 
2390   const string_type_base_sptr_map&
2391   added_unreachable_types() const;
2392 
2393   const vector<type_base_sptr>&
2394   added_unreachable_types_sorted() const;
2395 
2396   const string_diff_sptr_map&
2397   changed_unreachable_types() const;
2398 
2399   const vector<diff_sptr>&
2400   changed_unreachable_types_sorted() const;
2401 
2402   const diff_context_sptr
2403   context() const;
2404 
2405   const string&
2406   get_pretty_representation() const;
2407 
2408   bool
2409   has_changes() const;
2410 
2411   bool
2412   has_incompatible_changes() const;
2413 
2414   bool
2415   has_net_subtype_changes() const;
2416 
2417   bool
2418   has_net_changes() const;
2419 
2420   const diff_stats&
2421   apply_filters_and_suppressions_before_reporting();
2422 
2423   void
2424   mark_leaf_diff_nodes();
2425 
2426   diff_maps&
2427   get_leaf_diffs();
2428 
2429   const diff_maps&
2430   get_leaf_diffs() const;
2431 
2432   virtual void
2433   report(ostream& out, const string& indent = "") const;
2434 
2435   virtual bool
2436   traverse(diff_node_visitor& v);
2437 
2438   virtual void
2439   chain_into_hierarchy();
2440 
2441   friend corpus_diff_sptr
2442   compute_diff(const corpus_sptr f,
2443 	       const corpus_sptr s,
2444 	       diff_context_sptr ctxt);
2445 
2446   friend void
2447   apply_suppressions(const corpus_diff* diff_tree);
2448 
2449   friend void
2450   maybe_report_unreachable_type_changes(const corpus_diff& d,
2451 					const corpus_diff::diff_stats &s,
2452 					const string& indent,
2453 					ostream& out);
2454 
2455   friend class default_reporter;
2456   friend class leaf_reporter;
2457 }; // end class corpus_diff
2458 
2459 corpus_diff_sptr
2460 compute_diff(const corpus_sptr,
2461 	     const corpus_sptr,
2462 	     diff_context_sptr = diff_context_sptr());
2463 
2464 corpus_diff_sptr
2465 compute_diff(const corpus_group_sptr&,
2466 	     const corpus_group_sptr&,
2467 	     diff_context_sptr	ctxt);
2468 
2469 /// This is a document class that aims to capture statistics about the
2470 /// changes carried by a @ref corpus_diff type.
2471 ///
2472 /// Its values are populated by the member function
2473 /// corpus_diff::apply_filters_and_suppressions_before_reporting()
2474 class corpus_diff::diff_stats
2475 {
2476   struct priv;
2477   std::unique_ptr<priv> priv_;
2478 
2479   diff_stats();
2480 
2481 public:
2482 
2483   diff_stats(diff_context_sptr);
2484 
2485   size_t num_func_removed() const;
2486   void num_func_removed(size_t);
2487 
2488   size_t num_removed_func_filtered_out() const;
2489   void num_removed_func_filtered_out(size_t);
2490 
2491   size_t net_num_func_removed() const;
2492 
2493   size_t num_func_added() const;
2494   void num_func_added(size_t);
2495 
2496   size_t num_added_func_filtered_out() const;
2497   void num_added_func_filtered_out(size_t);
2498 
2499   size_t net_num_func_added() const;
2500 
2501   size_t num_func_changed() const;
2502   void num_func_changed(size_t);
2503 
2504   size_t num_changed_func_filtered_out() const;
2505   void num_changed_func_filtered_out(size_t);
2506 
2507   size_t num_func_with_virtual_offset_changes() const;
2508   void num_func_with_virtual_offset_changes(size_t);
2509 
2510   size_t net_num_func_changed() const;
2511 
2512   size_t num_vars_removed() const;
2513   void num_vars_removed(size_t);
2514 
2515   size_t num_removed_vars_filtered_out() const;
2516   void num_removed_vars_filtered_out(size_t) const;
2517 
2518   size_t net_num_vars_removed() const;
2519 
2520   size_t num_vars_added() const;
2521   void num_vars_added(size_t);
2522 
2523   size_t num_added_vars_filtered_out() const;
2524   void num_added_vars_filtered_out(size_t);
2525 
2526   size_t net_num_vars_added() const;
2527 
2528   size_t num_vars_changed() const;
2529   void num_vars_changed(size_t);
2530 
2531   size_t num_changed_vars_filtered_out() const;
2532   void num_changed_vars_filtered_out(size_t);
2533 
2534   size_t net_num_vars_changed() const;
2535 
2536   size_t num_func_syms_removed() const;
2537   void num_func_syms_removed(size_t);
2538 
2539   size_t num_removed_func_syms_filtered_out() const;
2540   void num_removed_func_syms_filtered_out(size_t);
2541 
2542   size_t num_func_syms_added() const;
2543   void num_func_syms_added(size_t);
2544 
2545   size_t num_added_func_syms_filtered_out() const;
2546   void num_added_func_syms_filtered_out(size_t);
2547 
2548   size_t net_num_removed_func_syms() const;
2549   size_t net_num_added_func_syms() const;
2550 
2551   size_t num_var_syms_removed() const;
2552   void num_var_syms_removed(size_t);
2553 
2554   size_t num_removed_var_syms_filtered_out() const;
2555   void num_removed_var_syms_filtered_out(size_t);
2556 
2557   size_t num_var_syms_added() const;
2558   void num_var_syms_added(size_t);
2559 
2560   size_t num_added_var_syms_filtered_out() const;
2561   void num_added_var_syms_filtered_out(size_t);
2562 
2563   size_t net_num_removed_var_syms() const;
2564   size_t net_num_added_var_syms() const;
2565 
2566   size_t num_leaf_changes() const;
2567   void num_leaf_changes(size_t);
2568 
2569   size_t num_leaf_changes_filtered_out() const;
2570   void num_leaf_changes_filtered_out(size_t);
2571 
2572   size_t net_num_leaf_changes() const;
2573 
2574   size_t num_leaf_type_changes() const;
2575   void num_leaf_type_changes(size_t);
2576 
2577   size_t num_leaf_type_changes_filtered_out() const;
2578   void num_leaf_type_changes_filtered_out(size_t);
2579   size_t net_num_leaf_type_changes() const;
2580 
2581   size_t num_leaf_func_changes() const;
2582   void num_leaf_func_changes(size_t);
2583 
2584   size_t num_leaf_func_changes_filtered_out() const;
2585   void num_leaf_func_changes_filtered_out(size_t);
2586   size_t net_num_leaf_func_changes() const;
2587 
2588   size_t num_leaf_var_changes() const;
2589   void num_leaf_var_changes(size_t);
2590 
2591   size_t num_leaf_var_changes_filtered_out() const;
2592   void num_leaf_var_changes_filtered_out(size_t);
2593   size_t net_num_leaf_var_changes() const;
2594 
2595   size_t num_added_unreachable_types() const;
2596   void num_added_unreachable_types(size_t);
2597 
2598   size_t num_added_unreachable_types_filtered_out() const;
2599   void num_added_unreachable_types_filtered_out(size_t);
2600   size_t net_num_added_unreachable_types() const;
2601 
2602   size_t num_removed_unreachable_types() const;
2603   void num_removed_unreachable_types(size_t);
2604 
2605   size_t num_removed_unreachable_types_filtered_out() const;
2606   void num_removed_unreachable_types_filtered_out(size_t);
2607   size_t net_num_removed_unreachable_types() const;
2608 
2609   size_t num_changed_unreachable_types() const;
2610   void num_changed_unreachable_types(size_t);
2611 
2612   size_t num_changed_unreachable_types_filtered_out() const;
2613   void num_changed_unreachable_types_filtered_out(size_t);
2614   size_t net_num_changed_unreachable_types() const;
2615 
2616 }; // end class corpus_diff::diff_stats
2617 
2618 /// The base class for the node visitors.  These are the types used to
2619 /// visit each node traversed by the diff_traversable_base::traverse() method.
2620 class diff_node_visitor : public node_visitor_base
2621 {
2622 protected:
2623   struct priv;
2624   std::unique_ptr<priv> priv_;
2625 
2626 public:
2627 
2628   diff_node_visitor();
2629 
2630   virtual ~diff_node_visitor();
2631 
2632   diff_node_visitor(visiting_kind k);
2633 
2634   visiting_kind
2635   get_visiting_kind() const;
2636 
2637   void
2638   set_visiting_kind(visiting_kind v);
2639 
2640   void
2641   or_visiting_kind(visiting_kind v);
2642 
2643   void
2644   set_current_topmost_iface_diff(diff*);
2645 
2646   diff*
2647   get_current_topmost_iface_diff() const;
2648 
2649   virtual void
2650   visit_begin(diff*);
2651 
2652   virtual void
2653   visit_begin(corpus_diff*);
2654 
2655   virtual void
2656   visit_end(diff*);
2657 
2658   virtual void
2659   visit_end(corpus_diff*);
2660 
2661   virtual bool
2662   visit(diff*, bool);
2663 
2664   virtual bool
2665   visit(distinct_diff*, bool);
2666 
2667   virtual bool
2668   visit(var_diff*, bool);
2669 
2670   virtual bool
2671   visit(pointer_diff*, bool);
2672 
2673   virtual bool
2674   visit(reference_diff*, bool);
2675 
2676   virtual bool
2677   visit(qualified_type_diff*, bool);
2678 
2679   virtual bool
2680   visit(enum_diff*, bool);
2681 
2682   virtual bool
2683   visit(class_diff*, bool);
2684 
2685   virtual bool
2686   visit(base_diff*, bool);
2687 
2688   virtual bool
2689   visit(scope_diff*, bool);
2690 
2691   virtual bool
2692   visit(function_decl_diff*, bool);
2693 
2694   virtual bool
2695   visit(type_decl_diff*, bool);
2696 
2697   virtual bool
2698   visit(typedef_diff*, bool);
2699 
2700   virtual bool
2701   visit(translation_unit_diff*, bool);
2702 
2703   virtual bool
2704   visit(corpus_diff*, bool);
2705 }; // end struct diff_node_visitor
2706 
2707 void
2708 propagate_categories(diff* diff_tree);
2709 
2710 void
2711 propagate_categories(diff_sptr diff_tree);
2712 
2713 void
2714 propagate_categories(corpus_diff* diff_tree);
2715 
2716 void
2717 propagate_categories(corpus_diff_sptr diff_tree);
2718 
2719 void
2720 apply_suppressions(diff* diff_tree);
2721 
2722 void
2723 apply_suppressions(const corpus_diff* diff_tree);
2724 
2725 void
2726 apply_suppressions(diff_sptr diff_tree);
2727 
2728 void
2729 apply_suppressions(corpus_diff_sptr diff_tree);
2730 
2731 void
2732 print_diff_tree(diff* diff_tree, std::ostream&);
2733 
2734 void
2735 print_diff_tree(corpus_diff* diff_tree,
2736 		std::ostream&);
2737 
2738 void
2739 print_diff_tree(diff_sptr diff_tree,
2740 		std::ostream&);
2741 
2742 void
2743 print_diff_tree(corpus_diff_sptr diff_tree,
2744 		std::ostream&);
2745 
2746 void
2747 categorize_redundancy(diff* diff_tree);
2748 
2749 void
2750 categorize_redundancy(diff_sptr diff_tree);
2751 
2752 void
2753 categorize_redundancy(corpus_diff* diff_tree);
2754 
2755 void
2756 categorize_redundancy(corpus_diff_sptr diff_tree);
2757 
2758 void
2759 clear_redundancy_categorization(diff* diff_tree);
2760 
2761 void
2762 clear_redundancy_categorization(diff_sptr diff_tree);
2763 
2764 void
2765 clear_redundancy_categorization(corpus_diff* diff_tree);
2766 
2767 void
2768 clear_redundancy_categorization(corpus_diff_sptr diff_tree);
2769 
2770 void
2771 apply_filters(corpus_diff_sptr diff_tree);
2772 
2773 bool
2774 is_diff_of_variadic_parameter_type(const diff*);
2775 
2776 bool
2777 is_diff_of_variadic_parameter_type(const diff_sptr&);
2778 
2779 bool
2780 is_diff_of_variadic_parameter(const diff*);
2781 
2782 bool
2783 is_diff_of_variadic_parameter(const diff_sptr&);
2784 
2785 const type_diff_base*
2786 is_type_diff(const diff* diff);
2787 
2788 const decl_diff_base*
2789 is_decl_diff(const diff* diff);
2790 
2791 const type_decl_diff*
2792 is_diff_of_basic_type(const diff* diff);
2793 
2794 const type_decl_diff*
2795 is_diff_of_basic_type(const diff* diff, bool);
2796 
2797 const class_or_union_diff*
2798 is_diff_of_class_or_union_type(const diff *d);
2799 
2800 bool
2801 has_basic_type_change_only(const diff* diff);
2802 
2803 const enum_diff*
2804 is_enum_diff(const diff *diff);
2805 
2806 const class_diff*
2807 is_class_diff(const diff* diff);
2808 
2809 const union_diff*
2810 is_union_diff(const diff* diff);
2811 
2812 const class_or_union_diff*
2813 is_class_or_union_diff(const diff* d);
2814 
2815 const class_or_union_diff*
2816 is_anonymous_class_or_union_diff(const diff* d);
2817 
2818 const array_diff*
2819 is_array_diff(const diff* diff);
2820 
2821 const function_type_diff*
2822 is_function_type_diff(const diff* diff);
2823 
2824 const function_type_diff*
2825 is_function_type_diff_with_local_changes(const diff* diff);
2826 
2827 const typedef_diff*
2828 is_typedef_diff(const diff *diff);
2829 
2830 const var_diff*
2831 is_var_diff(const diff* diff);
2832 
2833 const function_decl_diff*
2834 is_function_decl_diff(const diff* diff);
2835 
2836 const pointer_diff*
2837 is_pointer_diff(const diff* diff);
2838 
2839 const reference_diff*
2840 is_reference_diff(const diff* diff);
2841 
2842 const qualified_type_diff*
2843 is_qualified_type_diff(const diff* diff);
2844 
2845 const fn_parm_diff*
2846 is_fn_parm_diff(const diff* diff);
2847 
2848 const base_diff*
2849 is_base_diff(const diff* diff);
2850 
2851 const distinct_diff*
2852 is_distinct_diff(const diff *diff);
2853 
2854 bool
2855 is_child_node_of_function_parm_diff(const diff* diff);
2856 
2857 bool
2858 is_child_node_of_base_diff(const diff* diff);
2859 
2860 const corpus_diff*
2861 is_corpus_diff(const diff* diff);
2862 
2863 const diff*
2864 peel_typedef_diff(const diff* dif);
2865 
2866 const diff*
2867 peel_pointer_diff(const diff* dif);
2868 
2869 const diff*
2870 peel_reference_diff(const diff* dif);
2871 
2872 const diff*
2873 peel_qualified_diff(const diff* dif);
2874 
2875 const diff*
2876 peel_pointer_or_qualified_type_diff(const diff* dif);
2877 
2878 const diff*
2879 peel_typedef_or_qualified_type_diff(const diff* dif);
2880 }// end namespace comparison
2881 
2882 }// end namespace abigail
2883 
2884 #endif //__ABG_COMPARISON_H__
2885