[PATCH] D47687: [Sema] Missing -Wlogical-op-parentheses warnings in macros (PR18971)

Xing via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 15 00:08:21 PDT 2018


Higuoxing updated this revision to Diff 151460.
Higuoxing added a comment.

I think I am almost there.

Here, In my sight

  #define foo(op0, op1, x, y, z) ( (void)(x op0 y op1 z) )

is un-actionable, because `x op0 y op1 z` are from different arguments of function-like macro, so, we will not check parentheses for op0 or op1 when we call it by

  foo(&&, ||, x, y, z)

but if we call it by

  foo(&&, ||, x && y ||z, y, z)

it is actionable, because argument (x && y || z) is from the same arg position of macro foo;
hence we should check `x && y || z` but shouldn't check parentheses for the first argument (&&) and second argument (||)

I think this could cover bunch of cases. But I think my code is not so beautiful... So, is there any suggestion?


https://reviews.llvm.org/D47687

Files:
  lib/Sema/SemaExpr.cpp
  test/Sema/logical-op-parentheses-in-macros.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47687.151460.patch
Type: text/x-patch
Size: 6021 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180615/1e0b164f/attachment.bin>


More information about the cfe-commits mailing list