[PATCH] D80896: [clang-tidy][misc-redundant-expression] Support for CXXFoldExpr

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 4 02:07:57 PDT 2020


njames93 added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp:31
+struct Bar2 {
+  static_assert((... && (sizeof(Values) > 0)) || (... && (sizeof(Values) > 0)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:47: warning: both sides of operator are equivalent [misc-redundant-expression]
----------------
See other comment but if you change this to use `==` instead of `||` you can move this all back to the bottom simplifying the changes in this PR.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp:196
 bool operator>(const MyStruct& lhs, MyStruct& rhs) { rhs.x--; return lhs.x > rhs.x; }
 bool operator||(MyStruct& lhs, const MyStruct& rhs) { lhs.x++; return lhs.x || rhs.x; }
 
----------------
This is why you aren't getting warnings issued when the test case is at the bottom. You have defined a `||` operator at global namespace level which I'm guessing leads to ambiguity when checking the `static_assert` operator in your test case - It'll have a dependent type.
Simple fix is to change the static_assert to use say `operator==` as that isn't defined globally.


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

https://reviews.llvm.org/D80896





More information about the cfe-commits mailing list