Submitting a patch to Bugzilla 20951.
Simply replaced the function call IgnoreImpCasts to IgnoreParenImpCasts which seems to more appropriate.
I also had to modify a test cast in test/Sema/conditional-expr.c
I think a test for -Wtautological-pointer-compare should be added that shows that the bug is fixed.
no test is removed. The expected-warning is unchanged.
the problem with the test was that this comparison is always true:
(&x) != ((void *)0)
the address of x is never 0!
Fixing https://bugs.llvm.org/show_bug.cgi?id=20951 means Clang will warn:
warning: comparison of address of 'x' not equal to a null pointer is always true [-Wtautological-pointer-compare]
We changed the test so the -Wtautological-pointer-compare is not reported... but the original warning is still reported.
LGTM! However I would like to see a review from somebody else also.
There are a number of diagnostics that might be affected. The Sema::DiagnoseAlwaysNonNullPointer diagnoses these:
diag::warn_null_pointer_compare <-- I think this is the one bug 20951 is about
It seems to me that it is an improvement for all these warnings to skip the parentheses. However there is a danger that parentheses should hide some warnings to make it possible for users to hide unwanted warnings. But if that was the design decision then some regression test should complain when we skip the parentheses.