[PATCH] D93822: [clang-tidy] Add check for implicit widening of multiplication result

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 12 15:30:14 PDT 2021


lebedev.ri added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp:130
+  StringRef TyAsString =
+      IndexExprType->isSignedIntegerType() ? "ssize_t" : "size_t";
+
----------------
aaron.ballman wrote:
> aaron.ballman wrote:
> > One thing that's awkward about this is that there's no portable `ssize_t` type -- that's a POSIX type but it doesn't exist on all platforms (like Windows). We shouldn't print out a typecast that's going to cause compile errors, but we also shouldn't use the underlying type for `ssize_t` as that may be incorrect for other target architectures.
> I'm still not quite certain what to do about this. Would it make sense to use the underlying type on platforms that don't have `ssize_t`? Relatedly, if we're going to suggest this as a replacement, we should also insert an include for the correct header file.
I've been thinking about this, and i really can't come up with a better fix than using `ptrdiff_t`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93822



More information about the cfe-commits mailing list