[PATCH] D39462: [Sema] Implement -Wmaybe-tautological-constant-compare for when the tautologicalness is data model dependent
Roman Lebedev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 6 08:43:55 PST 2017
lebedev.ri updated this revision to Diff 121743.
lebedev.ri edited the summary of this revision.
lebedev.ri added a comment.
In https://reviews.llvm.org/D39462#912011, @rjmccall wrote:
> The actual choice of integer type is not stable across targets any more than the size is. In practice, people often don't use int and long, they use standard typedefs like size_t and uint64_t, but the actual type chosen for size_t is arbitrary when there are multiple types at that bit-width.
In https://reviews.llvm.org/D39462#912387, @efriedma wrote:
> > The internal canonical types are compared, so all this typedef sugar will be silently ignored.
> Yes, and that's precisely the problem. On many 32-bit platforms, both "size_t" and "uint32_t" are typedefs for "unsigned int"; on some 32-bit platforms, "size_t" is an "unsigned long". So whether this patch suppresses the warning for a comparison between size_t and uint32_t depends on the target ABI.
Okay, changed the code to compare not the internal canonical types, but just the types.
Added tests that show that it does detect&complain about comparing two different types, that point to the same type.
Also. should it really not be in `-Wextra`?
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 25062 bytes
Desc: not available
More information about the cfe-commits