[clang] Check if clang::FieldDecl has constant-integer bit width before getting the width (PR #148692)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 16 19:02:24 PDT 2025
================
@@ -709,7 +709,8 @@ AST_MATCHER(FieldDecl, isBitField) {
/// fieldDecl(hasBitWidth(2))
/// matches 'int a;' and 'int c;' but not 'int b;'.
AST_MATCHER_P(FieldDecl, hasBitWidth, unsigned, Width) {
- return Node.isBitField() && Node.getBitWidthValue() == Width;
+ return Node.isBitField() && Node.hasConstantIntegerBitWidth() &&
----------------
shafik wrote:
It looks like you are only testing the `Node.hasConstantIntegerBitWidth() == true` case in the test below. If that is correct we should add a test that covers both cases and any other combinations of these conditions not covered by testing.
https://github.com/llvm/llvm-project/pull/148692
More information about the cfe-commits
mailing list