[PATCH] D73775: [clang-tidy] Cover cases like (b && c && b) in the redundant expression check
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 3 05:13:21 PST 2020
aaron.ballman added inline comments.
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp:114
if (P.a[X++] != P.a[X++]) return 1;
+ if (X && X++ && X) return 1;
----------------
What do you think about the following?
```
bool foo(int&);
bool bar();
int i;
if (foo(i) && bar() && foo(i)) return 1;
```
I think that this should not be warned on (under the assumption that the reference variable can be modified by the call and thus may or may not be duplicate), but didn't see a test covering it.
It also brings up an interesting question about what to do if those were non-const pointers rather than references, because the data being pointed to could be modified as well.
(If you think this should be done separately from this review, that's totally fine by me, it looks like it would be an issue with the original code as well.)
One thing that is missing from this review are tests for the overloaded operator functionality.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73775/new/
https://reviews.llvm.org/D73775
More information about the cfe-commits
mailing list