[PATCH] clang-tidy: check for repeated side effects in macro

Daniel Marjamäki daniel.marjamaki at evidente.se
Fri May 8 05:59:11 PDT 2015


Now it doesn't warn about macros in system headers.

I have now tested it on 18045 files in 381 debian projects.

I saw warnings in 4 projects. In two projects I believe there are bugs. Imo the other two projects had false positives for these reasons:

1. repeated side effects is intended.
2. argument with side effects is repeated in macro, but in different conditional code paths, side effect is not repeated

For #1 I think the only reasonable solution is that this checker must be disabled by the user.

For #2 I think we could maybe fix some FPs in clang tidy by analysing the tokens. But it's not going to be easy and solid imho. I recommend that these users disable this warning. If we bailout when there are different conditional code paths there will be false negatives.


http://reviews.llvm.org/D9496

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp
  clang-tidy/misc/MacroRepeatedSideEffectsCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  test/clang-tidy/misc-repeated-side-effects-in-macro.c

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9496.25316.patch
Type: text/x-patch
Size: 7682 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150508/de6cc6a3/attachment.bin>


More information about the cfe-commits mailing list