tool/misc: new append_u_to_constants.cocci

This commit is contained in:
Matthias Ringwald 2020-07-20 23:37:06 +02:00
parent 45a92aba53
commit 6c87a5c39f

View File

@ -0,0 +1,25 @@
//
// append 'u' suffix to decimal or hexadecimal constants
//
@r1@
// match decimal or hexadecimal constant without suffix 'u'
constant C =~ "^[(0x)0-9a-fA-F]+$";
@@
C
@script:python p@
// define Cu := C + 'u'
C << r1.C;
Cu;
@@
coccinelle.Cu = coccinelle.C + 'u'
@@
// replace C with Cu
constant r1.C;
identifier p.Cu;
@@
- C
+ Cu