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

Xing via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 19 03:02:55 PDT 2018


Higuoxing added a comment.

Sorry, It seems a little bit difficult for me to add a proper fix-it hint for expressions in macros, because I cannot find the exact position of the last char of the token on right hand side of operator. Any suggestion?

Actually, in gcc, it will emit warning for everything without a fix-it hint, let alone expressions in nested macros... I think that our warning note is enough for us to diagnose the lacking parentheses, as you see in my inline comment

  llvm/tools/clang/test/Sema/parentheses.c:109:15: note: place parentheses around the '&&' expression to silence this warning
    VOID_CAST(i && i || i); // expected-warning {{'&&' within '||'}} \
              ~~^~~~
  llvm/tools/clang/test/Sema/parentheses.c:17:34: note: expanded from macro 'VOID_CAST'
  #define VOID_CAST(cond) ( (void)(cond) )
                                   ^~~~

So, it depends on you whether the parentheses checking in macros should be reserved. Both OK for me... Thanks for your reviewing :)


https://reviews.llvm.org/D47687





More information about the cfe-commits mailing list