================
@@ -0,0 +1,26 @@
+// RUN: %check_clang_tidy -std=c++17-or-later %s misc-redundant-expression %t
+
+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;
+} // namespace std
+
+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]
----------------
vbvictor wrote:

Please use real line + column numbers

https://github.com/llvm/llvm-project/pull/198085
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to