[PATCH] D155457: [clang] Skip tautological comparison if the comparison involves the 'size_t' type

Shivam Gupta via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 23 11:48:35 PDT 2023


xgupta added a comment.

In D155457#4523388 <https://reviews.llvm.org/D155457#4523388>, @cor3ntin wrote:

> I'm not sure I understand the motivation for this change. Sure, people do that but they also might do the same thing for ssize_t, intmax_t, or to compare int to int32_t.
> I think a better heuristic would be to not emit a warning for any integral (and floating point?) type that have the same canonical types (but we probably still want one if their non-canonical type if the same)

I am not sure but are you expecting these changes -

  // Don't warn if the comparison involves integral or floating-point types with the same canonical types.
  QualType LHSCanonical = Constant->getType().getCanonicalType();
  QualType RHSCanonical = Other->getType().getCanonicalType();
  if ((LHSCanonical->isIntegralOrEnumerationType() || LHSCanonical->isFloatingType()) &&
      S.Context.hasSameType(LHSCanonical, RHSCanonical)) {
    return false;
  }

This will silence a lot of warnings and a total 5 test case fails.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155457/new/

https://reviews.llvm.org/D155457



More information about the cfe-commits mailing list