[PATCH] D66045: Improve detection of same value in comparisons

JF Bastien via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 10 08:58:17 PDT 2019


jfb added a comment.

Does this work for unions as well?



================
Comment at: test/Analysis/array-struct-region.cpp:31
+  bool check() const { return this == this + 0; }
+  bool operator !() const { return this != this + 0; }
 
----------------
Is this the only way? Or do casts also disable the diagnostic?


================
Comment at: test/SemaCXX/self-comparison.cpp:78
+  return S::static_field == s1.static_field;  // expected-warning {{self-comparison always evaluates to true}}
+  return s1.array == s1.array;  // expected-warning {{self-comparison always evaluates to true}}
+  return t.s.static_field == S::static_field;  // expected-warning {{self-comparison always evaluates to true}}
----------------
`s1.array[0] == s1.array[0]`?


================
Comment at: test/SemaCXX/self-comparison.cpp:87
+};
+} // namespace member_tests
----------------
The test only has `==`. Do other operators trigger?


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

https://reviews.llvm.org/D66045





More information about the cfe-commits mailing list