================
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s misc-redundant-expression %t -- -- -std=c++17
+
+namespace std {
+ template<class T, int N> struct array { };
+ template<class T> struct tuple_size;
+ template<class T, int N> struct tuple_size<array<T, N>> { static constexpr
int value = N; };
+ template<class T> constexpr int tuple_size_v = tuple_size<T>::value;
+}
+
+using MonthArray = std::array<int, 12>;
+using ZodiacArray = std::array<int, 12>;
+
+void test() {
+ // False positive cases (Should NOT warn):
+ bool b1 = std::tuple_size<MonthArray>::value ==
std::tuple_size<ZodiacArray>::value;
+ bool b2 = std::tuple_size_v<MonthArray> == std::tuple_size_v<ZodiacArray>;
+
+ // True positive cases (Should warn):
+ bool b3 = std::tuple_size<MonthArray>::value ==
std::tuple_size<MonthArray>::value;
+ // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: both sides of operator
are equivalent [misc-redundant-expression]
+
+ bool b4 = std::tuple_size_v<MonthArray> == std::tuple_size_v<MonthArray>;
+ // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: both sides of operator
are equivalent [misc-redundant-expression]
+}
----------------
zeyi2 wrote:
Please add new line at EOF
https://github.com/llvm/llvm-project/pull/198085
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits