rust-bindgen icon indicating copy to clipboard operation
rust-bindgen copied to clipboard

Generate opaque type for template param dependent bit field width

Open chbaker0 opened this issue 3 years ago • 0 comments

libclang's API does not provide a straightforward way to check for this, and calling clang_getFieldDeclBitWidth is actively unsafe in this case. See https://github.com/llvm/llvm-project/issues/56644

We probably can't generate reasonable bindings for such a type, so make the binding opaque.

Ideally libclang would report if the bit width could not be evaluated. Unfortunately making such a change would mean bumping the minimum libclang version from 6.0 to 15.0.

Instead, add logic to traverse the AST subtree starting from the field's bit width specifier looking for template parameters. If we find one, we make the resulting type opaque

Workaround for https://github.com/rust-lang/rust-bindgen/issues/2239

chbaker0 avatar Jul 22 '22 18:07 chbaker0

Not sure what happened here... I guess I accidentally changed my master branch then it auto-merged because there were no changes?

chbaker0 avatar Aug 15 '22 20:08 chbaker0