[PATCH] D142800: [Clang][Diagnostic] Add `-Wcomparison-op-parentheses` to warn on chained comparisons

Takuya Shimizu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 3 07:39:19 PST 2023


hazohelet updated this revision to Diff 494635.
hazohelet added a comment.

Address comments from erichkeane:

- Fix comment wording
- Avoid using macro in test file

Implement my proposal for fix-it hint:

- In the case of chained relational operators (`<`, `>`, `<=`, `>=`), suggest adding `&&`.
- In other cases, suggest parentheses.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142800/new/

https://reviews.llvm.org/D142800

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Misc/warning-wall.c
  clang/test/Sema/comparison-op-parentheses.c
  libcxx/test/support/test_comparisons.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142800.494635.patch
Type: text/x-patch
Size: 11291 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230203/4f935991/attachment-0001.bin>


More information about the cfe-commits mailing list