[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`?
Repository:
rL LLVM
https://reviews.llvm.org/D39462
Files:
docs/ReleaseNotes.rst
include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaChecking.cpp
test/Sema/maybe-tautological-constant-compare.c
test/Sema/maybe-tautological-constant-compare.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39462.121743.patch
Type: text/x-patch
Size: 25062 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171106/8bef91f0/attachment-0001.bin>
More information about the cfe-commits
mailing list