• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2 // -*- Mode: C++ -*-
3 //
4 // Copyright (C) 2017-2020 Red Hat, Inc.
5 //
6 // Author: Dodji Seketeli
7 
8 /// @file
9 ///
10 /// The declaration of the reporting types of libabigail's diff
11 /// engine.
12 
13 #ifndef __ABG_REPORTER_H__
14 #define __ABG_REPORTER_H__
15 
16 #include <memory>
17 #include <ostream>
18 #include <string>
19 
20 namespace abigail
21 {
22 
23 using std::shared_ptr;
24 
25 namespace comparison
26 {
27 class diff;
28 class type_decl_diff;
29 class enum_diff;
30 class typedef_diff;
31 class qualified_type_diff;
32 class distinct_diff;
33 class pointer_diff;
34 class reference_diff;
35 class array_diff;
36 class base_diff;
37 class class_or_union_diff;
38 class class_diff;
39 class union_diff;
40 class scope_diff;
41 class fn_parm_diff;
42 class function_type_diff;
43 class function_decl_diff;
44 class var_diff;
45 class translation_unit_diff;
46 class corpus_diff;
47 class diff_maps;
48 class reporter_base;
49 
50 /// A convenience typedef for a shared pointer to a @ref
51 /// reporter_base.
52 typedef shared_ptr<reporter_base> reporter_base_sptr;
53 
54 /// The base class of all the reporting classes.
55 class reporter_base
56 {
57 public:
58 
59   virtual bool diff_to_be_reported(const diff *d) const;
60 
61   virtual bool diff_has_net_changes(const corpus_diff *d) const = 0;
62 
63   virtual void
64   report(const type_decl_diff& d, std::ostream& out,
65 	 const std::string& indent = "") const = 0;
66 
67   virtual void
68   report(const enum_diff& d, std::ostream& out,
69 	 const std::string& indent = "") const = 0;
70 
71   virtual void
72   report(const typedef_diff& d, std::ostream& out,
73 	 const std::string& indent = "") const = 0;
74 
75   virtual void
76   report(const qualified_type_diff& d, std::ostream& out,
77 	 const std::string& indent = "") const = 0;
78 
79   virtual void
80   report(const distinct_diff& d, std::ostream& out,
81 	 const std::string& indent = "") const = 0;
82 
83   virtual void
84   report(const pointer_diff& d, std::ostream& out,
85 	 const std::string& indent = "") const = 0;
86 
87   virtual void
88   report(const reference_diff& d, std::ostream& out,
89 	 const std::string& indent = "") const = 0;
90 
91   virtual void
92   report(const array_diff& d, std::ostream& out,
93 	 const std::string& indent = "") const = 0;
94 
95   virtual void
96   report(const base_diff& d, std::ostream& out,
97 	 const std::string& indent = "") const = 0;
98 
99   virtual void
100   report(const class_or_union_diff& d, std::ostream& out,
101 	 const std::string& indent = "") const = 0;
102 
103   virtual void
104   report(const class_diff& d, std::ostream& out,
105 	 const std::string& indent = "") const = 0;
106 
107   virtual void
108   report(const union_diff& d, std::ostream& out,
109 	 const std::string& indent = "") const = 0;
110 
111   virtual void
112   report(const scope_diff& d, std::ostream& out,
113 	 const std::string& indent = "") const = 0;
114 
115   virtual void
116   report(const fn_parm_diff& d, std::ostream& out,
117 	 const std::string& indent = "") const = 0;
118 
119   virtual void
120   report(const function_type_diff& d, std::ostream& out,
121 	 const std::string& indent = "") const = 0;
122 
123   virtual void
124   report(const function_decl_diff& d, std::ostream& out,
125 	 const std::string& indent = "") const = 0;
126 
127   virtual void
128   report(const var_diff& d, std::ostream& out,
129 	 const std::string& indent = "") const = 0;
130 
131   virtual void
132   report(const translation_unit_diff& d, std::ostream& out,
133 	 const std::string& indent = "") const = 0;
134 
135   virtual void
136   report(const corpus_diff& d, std::ostream& out,
137 	 const std::string& indent = "") const = 0;
138 
~reporter_base()139   virtual ~reporter_base() {}
140 }; //end class reporter_base
141 
142 class default_reporter;
143 
144 /// A convenience typedef for a shared_ptr to a @ref default_reporter.
145 typedef shared_ptr<default_reporter> default_reporter_sptr;
146 
147 /// The default, initial, reporter of the libabigail comparison engine.
148 class default_reporter : public reporter_base
149 {
150 public:
151 
152   virtual bool diff_has_net_changes(const corpus_diff *d) const;
153 
154   virtual void
155   report(const type_decl_diff& d, std::ostream& out,
156 	 const std::string& indent = "") const;
157 
158   virtual void
159   report(const enum_diff& d, std::ostream& out,
160 	 const std::string& indent = "") const;
161 
162   void
163   report_non_type_typedef_changes(const typedef_diff &d,
164 				  std::ostream& out,
165 				  const std::string& indent) const;
166 
167   virtual void
168   report(const typedef_diff& d, std::ostream& out,
169 	 const std::string& indent = "") const;
170 
171   bool
172   report_local_qualified_type_changes(const qualified_type_diff& d,
173 				      std::ostream& out,
174 				      const std::string& indent) const;
175 
176   virtual void
177   report(const qualified_type_diff& d, std::ostream& out,
178 	 const std::string& indent = "") const;
179 
180   virtual void
181   report(const pointer_diff& d, std::ostream& out,
182 	 const std::string& indent = "") const;
183 
184   void
185   report_local_reference_type_changes(const reference_diff& d,
186 				      std::ostream& out,
187 				      const std::string& indent) const;
188 
189   virtual void
190   report(const reference_diff& d, std::ostream& out,
191 	 const std::string& indent = "") const;
192 
193   virtual void
194   report(const fn_parm_diff& d, std::ostream& out,
195 	 const std::string& indent = "") const;
196 
197   void
198   report_local_function_type_changes(const function_type_diff& d,
199 				     std::ostream& out,
200 				     const std::string& indent) const;
201 
202   virtual void
203   report(const function_type_diff& d, std::ostream& out,
204 	 const std::string& indent = "") const;
205 
206   virtual void
207   report(const array_diff& d, std::ostream& out,
208 	 const std::string& indent = "") const;
209 
210   virtual void
211   report(const base_diff& d, std::ostream& out,
212 	 const std::string& indent = "") const;
213 
214   virtual void
215   report(const scope_diff& d, std::ostream& out,
216 	 const std::string& indent = "") const;
217 
218   virtual void
219   report(const class_or_union_diff& d, std::ostream& out,
220 	 const std::string& indent = "") const;
221 
222   virtual void
223   report(const class_diff& d, std::ostream& out,
224 	 const std::string& indent = "") const;
225 
226   virtual void
227   report(const union_diff& d, std::ostream& out,
228 	 const std::string& indent = "") const;
229 
230   virtual void
231   report(const distinct_diff& d, std::ostream& out,
232 	 const std::string& indent = "") const;
233 
234   virtual void
235   report(const function_decl_diff& d, std::ostream& out,
236 	 const std::string& indent = "") const;
237 
238   virtual void
239   report(const var_diff& d, std::ostream& out,
240 	 const std::string& indent = "") const;
241 
242   virtual void
243   report(const translation_unit_diff& d, std::ostream& out,
244 	 const std::string& indent = "") const;
245 
246   virtual void
247   report(const corpus_diff& d, std::ostream& out,
248 	 const std::string& indent = "") const;
249 }; // end class default_reporter
250 
251 /// A reporter that only reports leaf changes
252 class leaf_reporter : public default_reporter
253 {
254 public:
255 
256   virtual bool diff_to_be_reported(const diff *d) const;
257 
258   virtual bool diff_has_net_changes(const corpus_diff *d) const;
259 
260   void
261   report_changes_from_diff_maps(const diff_maps&, std::ostream& out,
262 				const std::string& indent) const;
263 
264   virtual void
265   report(const typedef_diff& d, std::ostream& out,
266 	 const std::string& indent = "") const;
267 
268   virtual void
269   report(const qualified_type_diff& d, std::ostream& out,
270 	 const std::string& indent = "") const;
271 
272   virtual void
273   report(const pointer_diff& d, std::ostream& out,
274 	 const std::string& indent = "") const;
275 
276   virtual void
277   report(const reference_diff& d, std::ostream& out,
278 	 const std::string& indent = "") const;
279 
280   virtual void
281   report(const fn_parm_diff& d, std::ostream& out,
282 	 const std::string& indent = "") const;
283 
284   virtual void
285   report(const function_type_diff& d, std::ostream& out,
286 	 const std::string& indent = "") const;
287 
288   virtual void
289   report(const array_diff& d, std::ostream& out,
290 	 const std::string& indent = "") const;
291 
292   virtual void
293   report(const scope_diff& d, std::ostream& out,
294 	 const std::string& indent = "") const;
295 
296   virtual void
297   report(const class_or_union_diff& d, std::ostream& out,
298 	 const std::string& indent = "") const;
299 
300   virtual void
301   report(const class_diff& d, std::ostream& out,
302 	 const std::string& indent = "") const;
303 
304   virtual void
305   report(const union_diff& d, std::ostream& out,
306 	 const std::string& indent = "") const;
307 
308   virtual void
309   report(const distinct_diff& d, std::ostream& out,
310 	 const std::string& indent = "") const;
311 
312   virtual void
313   report(const function_decl_diff& d, std::ostream& out,
314 	 const std::string& indent = "") const;
315 
316   virtual void
317   report(const var_diff& d, std::ostream& out,
318 	 const std::string& indent = "") const;
319 
320   virtual void
321   report(const translation_unit_diff& d, std::ostream& out,
322 	 const std::string& indent = "") const;
323 
324   virtual void
325   report(const corpus_diff& d, std::ostream& out,
326 	 const std::string& indent = "") const;
327 }; // end class leaf_reporter
328 
329 } // end namespace comparison
330 } // end namespace abigail
331 
332 #endif // __ABG_REPORTER_H__
333