This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] cppcoreguidelines Narrowing Conversions Check: detect narrowing conversions involving typedefs
ClosedPublic

Authored by gridaphobe on Nov 23 2020, 9:33 AM.

Details

Summary

The check 'cppcoreguidelines-narrowing-conversions' does not detect conversions
involving typedef. This notably includes the standard fixed-width integer types
like int32_t, uint64_t, etc.

Diff Detail

Event Timeline

gridaphobe created this revision.Nov 23 2020, 9:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 23 2020, 9:33 AM
gridaphobe requested review of this revision.Nov 23 2020, 9:33 AM
gchatelet accepted this revision.Nov 23 2020, 9:40 AM

Thx for the patch!

This revision is now accepted and ready to land.Nov 23 2020, 9:40 AM
lebedev.ri added subscribers: gchatelet, courbet, lebedev.ri.

Whoa, that's a fun bug :)

This revision now requires review to proceed.Nov 23 2020, 10:28 AM
lebedev.ri retitled this revision from clang-tidy: detect narrowing conversions involving typedefs to [clang-tidy] cppcoreguidelines Narrowing Conversions Check: detect narrowing conversions involving typedefs.Nov 23 2020, 10:29 AM
aaron.ballman accepted this revision.Nov 24 2020, 6:18 AM

LGTM aside from some small nits, thank you for the fix!

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions.cpp
346
351
This revision is now accepted and ready to land.Nov 24 2020, 6:18 AM

Add a couple passing tests involving typedefs.

gridaphobe marked 2 inline comments as done.Dec 6 2020, 4:37 PM

I've added the non-narrowing tests, are we good to merge?

I've added the non-narrowing tests, are we good to merge?

Yes, this still LGTM! Thank you! Do you need someone to commit on your behalf?

Yes please! I don't have commit rights.

aaron.ballman closed this revision.Dec 8 2020, 10:11 AM

Yes please! I don't have commit rights.

I've commit on your behalf in c6348e8c95ee1eaa9dd2322b278def7a4127ff26, thank you for the patch!