[all-commits] [llvm/llvm-project] f964e8: [clang-tidy] bugprone-implicit-widening ignores co...
Chris Warner via All-commits
all-commits at lists.llvm.org
Mon Jul 15 12:36:21 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f964e8a3f9ef9789f9075694cb887d0b3986d304
https://github.com/llvm/llvm-project/commit/f964e8a3f9ef9789f9075694cb887d0b3986d304
Author: Chris Warner <73851242+cwarner-8702 at users.noreply.github.com>
Date: 2024-07-15 (Mon, 15 Jul 2024)
Changed paths:
M clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp
M clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.h
M clang-tools-extra/docs/ReleaseNotes.rst
M clang-tools-extra/docs/clang-tidy/checks/bugprone/implicit-widening-of-multiplication-result.rst
A clang-tools-extra/test/clang-tidy/checkers/bugprone/implicit-widening-of-multiplication-result-constants.cpp
Log Message:
-----------
[clang-tidy] bugprone-implicit-widening ignores const exprs that fit (#98352)
Add an option to the
`bugprone-implicit-widening-of-multiplication-result` clang-tidy checker
to suppress warnings when the expression is made up of all compile-time
constants (literals, `constexpr` values or results, etc.) and the result
of the multiplication is guaranteed to fit in both the source and
destination types.
This currently only works for signed integer types:
* For unsigned integers, the well-defined rollover behavior on overflow
prevents the checker from detecting that the expression does not
actually fit in the source expr type, and would produce false negatives.
I have a somewhat-hacky stab at addressing this I'd like to submit as a
follow-on PR
* For floating-point types, there's probably a little additional work to
be done to `Expr` to calculate the result at compile time
Even still, this seems like a helpful addition just for signed types,
and additional types can be added.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list