qom-parent-type.cocci (491B)
1// Highlight object declarations that don't look like object class but 2// accidentally inherit from it. 3 4@match@ 5identifier obj_t, fld; 6type parent_t =~ ".*Class$"; 7@@ 8struct obj_t { 9 parent_t fld; 10 ... 11}; 12 13@script:python filter depends on match@ 14obj_t << match.obj_t; 15@@ 16is_class_obj = obj_t.endswith('Class') 17cocci.include_match(not is_class_obj) 18 19@replacement depends on filter@ 20identifier match.obj_t, match.fld; 21type match.parent_t; 22@@ 23struct obj_t { 24* parent_t fld; 25 ... 26};