[PATCH] D39462: [Sema] Implement -Wmaybe-tautological-constant-compare for when the tautologicalness is data model dependent

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 6 18:29:09 PST 2017

rjmccall added a comment.

So, that change makes this very interesting, because I think the right way of looking at it is as the first in a larger family of warnings that attempt to treat typedefs as if they were a much stronger type-system feature, i.e. that warn about all sorts of conversions between different typedef types.  That should be good enough to serve as a basic rule for a stronger portability warning, as well as generally pointing out all sorts of potential logical errors like passing a bit_offset_t off as a byte_offset_t.

Such a warning really needs more exceptions than a simple exact-type-spelling rule would give you.  There are several language features that add type sugar which should really be ignored for the purposes of the warning, such as typeof and decltype; and conversely, there are several features that remove (or just never add) type sugar that also shouldn't cause problems, like literals or C++ templates.

I think that feature could be really useful as a major new diagnostic, but I do want to warn you that it's probably a pretty large project, somewhat on the scale of implementing -Wconversion in the first place.  Also, yeah, my first thought is that it's probably outside of a reasonable rubric for even -Wextra, especially while it's being actively developed.



More information about the cfe-commits mailing list