Implemented support for bit-field members as a loop variable
or upper limit. Supporting also non bit-field integer members.
Fixes issues: https://github.com/llvm/llvm-project/issues/58614
Differential D142587
[clang-tidy] Improved too-small-loop-variable with bit-field support PiotrZSL on Jan 25 2023, 3:05 PM. Authored by
Details Implemented support for bit-field members as a loop variable Fixes issues: https://github.com/llvm/llvm-project/issues/58614
Diff Detail
Event TimelineComment Actions Thanks for the fix! I have some suggestions for improved readability.
Comment Actions @carlosgalvezp: Sorry, there are too much Clang specifics in this patch, so I could not be reviewer. Comment Actions Hi typedef struct S { int x:4; } S; void foo(S s) { for (int i=10; i > s.x; --i) ; } loop_var.c:6:22: warning: loop variable has narrower type 'int:4' than iteration's upper bound 'int' [bugprone-too-small-loop-variable] for (int i=10; i > s.x; --i) ; ^ Looks like the logic i reversed here, so the loop variable gets the bit field type. Comment Actions Thank you for information, I will look into this.... |