clang_getFieldDeclBitWidth checks if the provided cursor is a bitfield declaration then proceeds to call FieldDecl::getBitWidthValue which in turn calls Expr::EvaluateKnownConstInt on the bit width expression.
EvaluateKnownConstInt requires the expression not be dependent on any template parameters. However, clang_getFieldDeclBitWidth doesn't account for this, and libclang does not expose an obvious way to check if an expression's value depends on a template parameter.
rust-lang/rust-bindgen#2239 is related