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 /// @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, const decl_base_sptr& s); 29 30 bool union_diff_has_harmless_changes(const diff *d); 31 32 bool 33 has_harmful_name_change(const decl_base_sptr& f, const decl_base_sptr& s); 34 35 bool 36 has_harmful_name_change(const diff* dif); 37 38 bool 39 has_virtual_mem_fn_change(const function_decl_diff* diff); 40 41 bool 42 is_decl_only_class_with_size_change(const class_or_union& first, 43 const class_or_union& second); 44 45 bool 46 is_decl_only_class_with_size_change(const class_or_union_sptr& first, 47 const class_or_union_sptr& second); 48 49 bool 50 is_decl_only_class_with_size_change(const diff *diff); 51 52 bool 53 has_decl_only_def_change(const decl_base_sptr& first, 54 const decl_base_sptr& second); 55 56 bool 57 has_decl_only_def_change(const diff *d); 58 59 bool 60 has_class_decl_only_def_change(const class_or_union_sptr& first, 61 const class_or_union_sptr& second); 62 63 bool 64 has_enum_decl_only_def_change(const enum_type_decl_sptr& first, 65 const enum_type_decl_sptr& second); 66 67 bool 68 has_class_decl_only_def_change(const diff *diff); 69 70 bool 71 has_enum_decl_only_def_change(const diff *diff); 72 73 bool 74 has_basic_type_name_change(const diff *); 75 76 bool 77 has_class_or_union_type_name_change(const diff *d); 78 79 bool 80 has_basic_or_class_type_name_change(const diff *d); 81 82 bool 83 is_mostly_distinct_diff(const diff *d); 84 85 bool 86 has_anonymous_data_member_change(const diff *d); 87 88 bool 89 has_anonymous_data_member_change(const diff_sptr &d); 90 91 bool 92 has_data_member_replaced_by_anon_dm(const diff* diff); 93 94 struct filter_base; 95 /// Convenience typedef for a shared pointer to filter_base 96 typedef shared_ptr<filter_base> filter_base_sptr; 97 /// Convenience typedef for a vector of filter_base_sptr 98 typedef std::vector<filter_base_sptr> filters; 99 100 /// The base class for the diff tree node filter. 101 /// 102 /// It's intended to walk a tree of diff nodes and tag each relevant 103 /// name into one or several categories depending on well choosen 104 /// properties of the diff nodes. 105 struct filter_base : public diff_node_visitor 106 { 107 friend void 108 apply_filter(filter_base_sptr f, diff_sptr deef); 109 }; //end class filter_base 110 111 void 112 apply_filter(filter_base& filter, diff_sptr d); 113 114 void 115 apply_filter(filter_base& filter, corpus_diff_sptr d); 116 117 void 118 apply_filter(filter_base_sptr filter, diff_sptr d); 119 120 class harmless_filter; 121 /// Convenience typedef for a shared pointer to a harmless_filter. 122 typedef shared_ptr<harmless_filter> harmless_filter_sptr; 123 124 /// A filter that walks the diff nodes tree and tags relevant diff 125 /// nodes into categories considered to represent harmless changes. 126 class harmless_filter : public filter_base 127 { 128 virtual bool 129 visit(diff*, bool); 130 131 virtual void 132 visit_end(diff*); 133 }; // end class harmless_filter 134 135 class harmless_harmful_filter; 136 /// A convenience typedef for a shared pointer to harmful_filter. 137 typedef shared_ptr<harmless_harmful_filter> harmful_harmless_filter_sptr; 138 139 /// A filter that walks the diff nodes tree and tags relevant diff 140 /// nodes into categories considered to represent potentially harmless 141 /// or harmful changes. 142 class harmless_harmful_filter : public filter_base 143 { 144 virtual bool 145 visit(diff*, bool); 146 147 virtual void 148 visit_end(diff*); 149 }; // end class harmless_harmful_filter 150 151 } // end namespace filtering 152 } // end namespace comparison 153 } // end namespace abigail 154 155 #endif // __ABG_COMP_FILTER_H__ 156