[PATCH] D114105: [clang-tidy] Ignore narrowing conversions in case of bitfields

Whisperity via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 18 00:06:14 PST 2021


whisperity added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:87
+  // Reading a small unsigned bitfield member will be wrapped by an implicit
+  // cast to 'int' triggering this checker. But this is known to be safe by the
+  // compiler since it chose 'int' instead of 'unsigned int' as the type of the
----------------
(Terminology... 😕)


================
Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:100
+  // `-IntegerLiteral 'int' 1
+  const auto ShiftingWidenedBitfieldValue = castExpr(
+      hasCastKind(CK_IntegralCast), hasType(asString("int")),
----------------
`IntWidened`? Just to point out that so far this is the only case we've found where the warning is superfluous.


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

https://reviews.llvm.org/D114105



More information about the cfe-commits mailing list