[PATCH] D53488: [clang-tidy] Improving narrowing conversions
Guillaume Chatelet via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 16 08:08:51 PST 2018
gchatelet added inline comments.
================
Comment at: test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp:79-81
+ // TODO: Provide an automatic fix if the number is exactly representable in the destination type.
+ f += 2.0;
+ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from constant 'double' to 'float' [cppcoreguidelines-narrowing-conversions]
----------------
aaron.ballman wrote:
> gchatelet wrote:
> > aaron.ballman wrote:
> > > This is not a narrowing conversion -- there should be no diagnostic here. See [dcl.init.list]p7.
> > Thx for pointing this out.
> > I would like to keep the diagnostic (without mentioning the narrowing) because there is no reason to write `2.0` instead of `2.0f`. WDYT?
> I see no reason to warn on a literal value that isn't changed as a result of the notional narrowing. The standard clearly defines the behavior, so I think that would be needlessly chatty.
Done. Plus added som tests.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D53488
More information about the cfe-commits
mailing list