libabigail
abg-comp-filter.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) 2013-2025 Red Hat, Inc.
5 //
6 // Author: Dodji Seketeli
7 
8 /// @file
9 ///
10 /// This header declares filters for the diff trees resulting from
11 /// comparing ABI Corpora.
12 
13 #ifndef __ABG_COMP_FILTER_H__
14 #define __ABG_COMP_FILTER_H__
15 
16 #include "abg-comparison.h"
17 
18 namespace abigail
19 {
20 namespace comparison
21 {
22 /// Facilities to walk, categorize and possibly filter nodes of the
23 /// diff tree.
24 namespace filtering
25 {
26 
27 bool
28 has_harmless_name_change(const decl_base_sptr& f,
29  const decl_base_sptr& s,
30  const diff_context_sptr& ctxt);
31 
32 bool union_diff_has_harmless_changes(const diff *d);
33 
34 bool
35 has_harmful_name_change(const decl_base_sptr& f,
36  const decl_base_sptr& s,
37  const diff_context_sptr& ctxt);
38 
39 bool
40 has_harmful_name_change(const diff* dif);
41 
42 bool
43 has_virtual_mem_fn_change(const function_decl_diff* diff);
44 
45 bool
46 is_decl_only_class_with_size_change(const class_or_union& first,
47  const class_or_union& second);
48 
49 bool
50 is_decl_only_class_with_size_change(const class_or_union_sptr& first,
51  const class_or_union_sptr& second);
52 
53 bool
54 is_decl_only_class_with_size_change(const diff *diff);
55 
56 bool
57 has_decl_only_def_change(const decl_base_sptr& first,
58  const decl_base_sptr& second);
59 
60 bool
61 has_decl_only_def_change(const diff *d);
62 
63 bool
64 has_class_decl_only_def_change(const class_or_union_sptr& first,
65  const class_or_union_sptr& second);
66 
67 bool
69  const enum_type_decl_sptr& second);
70 
71 bool
72 has_class_decl_only_def_change(const diff *diff);
73 
74 bool
75 has_enum_decl_only_def_change(const diff *diff);
76 
77 bool
78 has_basic_type_name_change(const diff *);
79 
80 bool
82 
83 bool
85 
86 bool
87 is_mostly_distinct_diff(const diff *d);
88 
89 bool
91 
92 bool
94 
95 bool
96 has_data_member_replaced_by_anon_dm(const diff* diff);
97 
98 bool
100 
101 bool
103  const var_decl_sptr& var2);
104 
105 bool
107  const class_decl_sptr& second);
108 
109 bool
110 has_strict_fam_conversion(const diff *d);
111 
112 bool
113 has_lvalue_reference_ness_change(const diff *d);
114 
115 bool
116 has_void_ptr_to_ptr_change(const diff* d);
117 
118 bool
119 has_void_to_non_void_change(const diff* d);
120 
121 bool
123 
124 bool
125 has_harmless_enum_to_int_change(const diff* d);
126 
127 bool
129 
132 
134 has_var_harmful_local_change(const diff* d);
135 
138 
139 bool
140 has_fn_with_virtual_offset_change(const diff* d);
141 
142 bool
144 
145 bool
146 has_incompatible_fn_or_var_change(const diff* d);
147 
148 bool
150 
151 bool
153 
154 bool
156 
157 bool
158 is_type_to_compatible_anonymous_type_change(const type_base_sptr&,
159  const type_base_sptr&);
160 
161 bool
163 
164 bool
166 
167 bool
169  const decl_base_sptr&);
170 
171 struct filter_base;
172 /// Convenience typedef for a shared pointer to filter_base
173 typedef shared_ptr<filter_base> filter_base_sptr;
174 /// Convenience typedef for a vector of filter_base_sptr
175 typedef std::vector<filter_base_sptr> filters;
176 
177 /// The base class for the diff tree node filter.
178 ///
179 /// It's intended to walk a tree of diff nodes and tag each relevant
180 /// name into one or several categories depending on well choosen
181 /// properties of the diff nodes.
183 {
184  friend void
185  apply_filter(filter_base_sptr f, diff_sptr deef);
186 }; //end class filter_base
187 
188 void
190 
191 void
193 
194 void
195 apply_filter(filter_base_sptr filter, diff_sptr d);
196 
198 /// Convenience typedef for a shared pointer to a harmless_filter.
199 typedef shared_ptr<harmless_filter> harmless_filter_sptr;
200 
201 /// A filter that walks the diff nodes tree and tags relevant diff
202 /// nodes into categories considered to represent harmless changes.
204 {
205  virtual bool
206  visit(diff*, bool);
207 
208  virtual void
209  visit_end(diff*);
210 }; // end class harmless_filter
211 
213 /// A convenience typedef for a shared pointer to harmful_filter.
214 typedef shared_ptr<harmless_harmful_filter> harmful_harmless_filter_sptr;
215 
216 /// A filter that walks the diff nodes tree and tags relevant diff
217 /// nodes into categories considered to represent potentially harmless
218 /// or harmful changes.
220 {
221  virtual bool
222  visit(diff*, bool);
223 
224  virtual void
225  visit_end(diff*);
226 }; // end class harmless_harmful_filter
227 
228 } // end namespace filtering
229 } // end namespace comparison
230 } // end namespace abigail
231 
232 #endif // __ABG_COMP_FILTER_H__
bool has_harmless_enum_to_int_change(const diff *diff)
Test if a diff node carries a harmless change of an enum into an integer (or vice-versa).
The abstraction of a change between two ABI artifacts, a.k.a an artifact change.
diff_category has_fn_return_or_parm_harmful_change(const diff *d)
Test if a diff node is a function diff node that carries either a return or a parameter type change t...
shared_ptr< harmless_filter > harmless_filter_sptr
Convenience typedef for a shared pointer to a harmless_filter.
bool has_virtual_mem_fn_change(const function_decl_diff *diff)
Test if the function_decl_diff node has a change involving virtual member functions.
shared_ptr< diff_context > diff_context_sptr
Convenience typedef for a shared pointer of diff_context.
Definition: abg-fwd.h:67
bool is_mostly_distinct_diff(const diff *d)
Test if a diff node carries a distinct type change or a pointer/reference/typedef to distinct type ch...
shared_ptr< var_decl > var_decl_sptr
Convenience typedef for a shared pointer on a var_decl.
Definition: abg-fwd.h:253
bool has_decl_only_def_change(const decl_base_sptr &first, const decl_base_sptr &second)
Test if two decl_base_sptr are different just by the fact that one is decl-only and the other one is ...
bool has_void_to_non_void_change(const diff *d)
Test if a diff node carries a "void-to-non-void" type change.
bool is_type_to_compatible_anonymous_type_change(const diff_sptr &d)
Test if a diff node carries a change where a type T is modified into an anonymous type T' of the same...
bool has_void_ptr_to_ptr_change(const diff *dif)
Test if a diff node carries a void* to pointer type change.
diff_category has_var_harmful_local_change(const diff *d)
Test if a diff node carries a harmful local change to a variable.
bool has_anonymous_data_member_change(const diff *d)
Test if a diff node carries a non-anonymous data member to anonymous data member change, or vice-versa.
bool has_strict_fam_conversion(const class_decl_sptr &first, const class_decl_sptr &second)
Test if a class with a fake flexible data member got changed into a class with a real fexible data me...
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 has_benign_array_of_unknown_size_change(const diff *dif)
Test if a diff node carries a benign change to the size of a variable of type array.
bool has_basic_type_name_change(const diff *d)
Test if a diff node carries a basic type name change.
bool has_class_decl_only_def_change(const class_or_union_sptr &first, const class_or_union_sptr &second)
Test if two class_or_union_sptr are different just by the fact that one is decl-only and the other on...
bool has_data_member_replaced_by_anon_dm(const diff *diff)
Test if a class_or_union_diff has a data member replaced by an anonymous data member in a harmless wa...
bool has_lvalue_reference_ness_change(const diff *dif)
Test if a diff node carries a change where an lvalue reference changed into a rvalue reference...
bool is_data_member_to_compatible_anonymous_dm_change(const diff *d)
Test if a diff node carries a change where a data member F is modified into an anonymous data member ...
void apply_filter(filter_base &filter, corpus_diff_sptr d)
Walk the diff sub-trees of a a corpus_diff and apply a filter to the nodes visted. The filter categorizes each node, assigning it into one or several categories.
bool union_diff_has_harmless_changes(const diff *d)
Test if a union diff node does have changes that don't impact its size.
shared_ptr< harmless_harmful_filter > harmful_harmless_filter_sptr
A convenience typedef for a shared pointer to harmful_filter.
bool has_fn_with_virtual_offset_change(const diff *d)
Test if a diff node carries a change to the offset of a virtual function.
bool has_incompatible_fn_or_var_change(const diff *d)
Test if a diff node carries an incompatible ABI change.
friend void apply_filter(filter_base_sptr f, diff_sptr deef)
Walk a diff sub-tree and apply a filter to the nodes visted. The filter categorizes each node...
The base class for the node visitors. These are the types used to visit each node traversed by the di...
A filter that walks the diff nodes tree and tags relevant diff nodes into categories considered to re...
shared_ptr< enum_type_decl > enum_type_decl_sptr
Convenience typedef for shared pointer to a enum_type_decl.
Definition: abg-fwd.h:172
shared_ptr< class_decl > class_decl_sptr
Convenience typedef for a shared pointer on a class_decl.
Definition: abg-fwd.h:190
bool has_harmful_name_change(const decl_base_sptr &f, const decl_base_sptr &s, const diff_context_sptr &ctxt)
Test if two decls represent a harmful name change.
shared_ptr< corpus_diff > corpus_diff_sptr
A convenience typedef for a shared pointer to corpus_diff.
bool has_class_or_union_type_name_change(const diff *d)
Test if a diff node carries a class or union type name change.
bool is_var_1_dim_unknown_size_array_change(const var_decl_sptr &var1, const var_decl_sptr &var2)
Test if we are looking at two variables which types are both one dimension array, with one of them be...
The base class for the diff tree node filter.
A filter that walks the diff nodes tree and tags relevant diff nodes into categories considered to re...
bool has_basic_or_class_type_name_change(const diff *d)
Test if a diff node carries a basic or class type name change.
std::vector< filter_base_sptr > filters
Convenience typedef for a vector of filter_base_sptr.
shared_ptr< diff > diff_sptr
Convenience typedef for a shared_ptr for the diff class.
Definition: abg-fwd.h:75
bool has_enum_decl_only_def_change(const enum_type_decl_sptr &first, const enum_type_decl_sptr &second)
Test if two enum_sptr are different just by the fact that one is decl-only and the other one is defin...
bool has_harmless_name_change(const decl_base_sptr &f, const decl_base_sptr &s, const diff_context_sptr &ctxt)
Test if two decls represents a harmless name change.
bool is_decl_only_class_with_size_change(const class_or_union &first, const class_or_union &second)
Test if two classes that are decl-only (have the decl-only flag and carry no data members) but are di...
shared_ptr< filter_base > filter_base_sptr
Convenience typedef for a shared pointer to filter_base.