Self comparison under -Wtautological-compare and -Wtautological-overlap-compare work by detecting that two operands refer to the same value. The easy cases of operands referring to the same Decl are already handled. This change extends the detection to look through variable members, as well as detecting static member access via different routes. Also unify the detection method to one location as previously, each warning had its own.
struct S {
int x; static int y;
};
bool foo(S s) {
return s.x == 1 && s.x == 2; // detects this is always false return S::y == s.y; // detects this is always true
}