This is a new clang-tidy checker that warns when there is side effects in a macro argument that is repeated in the macro expansion.
I am running tests. Right now it has been tested on 7678 files in 180 projects. And there has been in total 7 warnings. As far as I see all these 7 warnings are real bugs.
Interestingly I get a couple of warnings for standard functions that are implemented as macros. As far as I see my headers are not standard-compliant:
format.c:774:28: warning: Side effects in macro argument is repeated in macro expansion [misc-macro-repeated-side-effects] tblt->instr[0] = toupper(*p++); ^ /usr/include/ctype.h:229:11: note: 'toupper' macro defined here # define toupper(c) __tobody (c, toupper, *__ctype_toupper_loc (), (c)) ^
tunnel.c:73:25: warning: Side effects in macro argument is repeated in macro expansion [misc-macro-repeated-side-effects] char *q = strchr (++p, '"'); ^ /usr/include/x86_64-linux-gnu/bits/string2.h:395:11: note: 'strchr' macro defined here # define strchr(s, c) \ (__extension__ (__builtin_constant_p (c) && !__builtin_constant_p (s) \ && (c) == '\0' \ ? (char *) __rawmemchr (s, c) \ : __builtin_strchr (s, c)))
The clang:: qualifier is not needed here and below.