Turns out it is needed.
/home/florin/tools/llvm-project/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp:48:38: error: use of undeclared identifier 'FieldDecl'; did you mean 'fieldDecl'? const auto *AsFieldDecl = Node.get<FieldDecl>(); ^~~~~~~~~ fieldDecl
I think the function should be made static and put into the clang namespace below (the same is true of the previous function in the anonymous namespace as well, but that doesn't need to be changed as part of this patch).
I feel like there should be an assertion/unreachable in here -- there's no way for a bit-field width to be specified with a floating literal.
Is the default false because you want to preserve existing functionality? Or do you think bit-field widths as integer literals really are magic numbers?
Can you also add a test for unsigned int: 0; to make sure it does not warn about this value? IMO it shouldn't warn since it is a special case with a well defined behaviour.
This follows the pattern with isSyntheticValue. It allows the checkBoundMatch template to be called with either. It is a hack (to keep most of the checks aligned between ints and float), that is getting close to the end of its useful life. But I'll break up that function on the next change.
The default is false to preserve the old behavior. I don't think the old behavior is that great so if somebody really wants it flipped I could easily go for it.
The bit fields as integer literals are magic, but I am not sure of the value of warning over them in code that accesses hardware directly and makes use of generated files. I would prefer people to use this check for the regular code, and not be scared away by many warnings that they can't fix anyway because it is vendor code.
0 is a special value anyway, but I will add the test.