Age | Commit message (Collapse) | Author |
|
remove `clap` dependency :tada:
update the book installation instructions
|
|
This doesn't change behavior but makes the code make more sense.
|
|
|
|
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.
|
|
|
|
complete type.
It might not if we had to avoid recursion when processing types. Detect that
case and bail out. This bug was being masked by the fact that we didn't always
find definitions for the recursion check and so it didn't trigger, but now that
this check is more reliable we have to be careful in more places.
The test case was reduced from the GCC STL allocator definition.
|
|
Fixes #2067
|
|
|
|
Instead of always generating the _bindgen_union_align method (which
shouldn't be needed at all for Rust structs, since the struct layout
tracker already deals with adding repr(align) as necessary) make sure to
visit all fields appropriately to generate the correct alignment.
|
|
|
|
space.
Fixes #1947.
There are two separate issues here: First, the change in comp.rs ensures
that we don't round up the amount of storage to the alignment of the
bitfield. That generates the "expected" output in #1947
(`__BindgenBitfieldUnit<[u8; 3], u16>`).
But that's still not enough to fix that test-case because
__BindgenBitfieldUnit would be aligned and have padding, and Rust won't
put the extra field in the padding.
In order to ensure the bitfield starts at the right alignment, but that
Rust can put stuff in the extra field, we need to make a breaking change
and split the generated fields in two: One preceding that guarantees
alignment, and the actual storage, bit-aligned.
This keeps the existing behavior while fixing that test-case.
|
|
|
|
This can cause unnecessary padding to be computed otherwise at the end
of the struct.
With repr(packed(n)), a field can have padding to adjacent fields as
long as its alignment is less than n. So reuse the code we have to align
to a field layout, aligning to the struct layout instead.
Fixes #1934
|
|
|
|
Allow to use the given prefix for the anon fields instead of `__bindgen_anon_`.
|
|
In Rust 1.45.0, `std::mem::replace` gained the `#[must_use]` attribute,
causing a new diagnostic for some `bindgen` code :
error: unused return value of `std::mem::replace` that must be used
--> src/ir/comp.rs:751:17
|
751 | / mem::replace(
752 | | self,
753 | | CompFields::AfterComputingBitfieldUnits {
754 | | fields,
755 | | has_bitfield_units,
756 | | },
757 | | );
| |__________________^
|
= note: `-D unused-must-use` implied by `-D warnings`
= note: if you don't need the old value, you can just assign the new value directly
error: unused return value of `std::mem::replace` that must be used
--> src/ir/comp.rs:760:17
|
760 | mem::replace(self, CompFields::ErrorComputingBitfieldUnits);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: if you don't need the old value, you can just assign the new value directly
error: aborting due to 2 previous errors
|
|
|
|
|
|
|
|
|
|
By not generating various code for it.
In the future, we could improve on this by splitting contiguous bitfield units,
if needed, so that we can implement them without dealing with rust array derive
limits.
Fixes #1718
|
|
Fixes #1716
|
|
|
|
|
|
|
|
|
|
|
|
I noticed that a `#pragma packed` class that has only a vtable but no
data members is not marked repr(packed). The bug is that is_packed
examines data members but not the vtable when applying its heuristic.
|
|
Fixes https://github.com/rust-lang/rust-bindgen/issues/537.
|
|
This isn't such a massive win as I'd have hoped, but it is consistently faster,
so there's no reason not to.
> ./bindgen-old tests/stylo.hpp --no-rustfmt-bindings > /dev/null 2>&1
6.17s user 0.84s system 98% cpu 7.079 total
> ./target/release/bindgen tests/stylo.hpp --no-rustfmt-bindings > /dev/null 2>
5.92s user 0.87s system 98% cpu 6.866 total
Which isn't _that_ much but it's quite a bit.
|
|
|
|
|
|
|
|
You can define a struct declared in an outer scope inside another struct, and
the compiler won't even complain...
C, what a language.
Fixes #1281
|
|
Otherwise we can't use repr(align) on stylo.
|
|
Use the ? operator instead of try, and add some more uses of it on Option<> that
were straight-forward.
|
|
Instead of special-casing.
This allows to use the normal flags to control what can be or not derived for
them.
Arguably deriving Copy / Clone is kind of busted for those, but changing this by
default broke tests (RefPtr<ForwardDeclaredType> stopped working for example).
So I think this is a good compromise.
Fixes #1238
|
|
Fixes #1197.
|
|
Instead of panicking when we see a bitfield that does not have a layout, return
an error up the stack. If we get an error when allocating bitfields into units,
then make the whole struct opaque.
Fixes #1140
|
|
This is a bandaid for #537. It does *not* fix the underlying issue, which
requires `#[repr(packed = "N")]` support in Rust. However, it does make sure
that we don't generate type definitions with the wrong layout, or fail our
generated layout tests.
|
|
According to the x86[-64] ABI spec: "Unnamed bit-fields’ types do not affect the
alignment of a structure or union". This makes sense: such bit-fields are only
used for padding, and we can't perform an un-aligned read of something we can't
read because we can't even name it.
Fixes #1076
|
|
|
|
This fixes a couple bugs where we weren't properly adding an `_address`
byte. It also helps pave the way for computing implicit fields (such as padding,
`_address`, vtable pointers, etc) in its own pass, before codegen.
Fixes #768
|
|
ir: Cleanup a bunch of constructors
Should be no change in behavior.
|
|
To use the shorthand initialization syntax.
|
|
instead
|
|
pointer
|
|
Its more clear what the methods/fields are returning/storing when we add "width"
to the name.
|
|
|
|
|