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