Commit Graph

3312 Commits

Author SHA1 Message Date
Darren Kulp
d6714c6be6 tests: Stop testing libclang 4.0 2022-03-15 03:53:10 +01:00
Darren Kulp
638729fdba tests: Enable a test with a const template param
This should have been added in #2155 but was missed then.
2022-03-15 03:53:10 +01:00
Emilio Cobos Álvarez
91b5371df6 codegen: Simplify abi support condition. 2022-03-15 03:48:15 +01:00
David Cole
1b66dcf876 Added support for vectorcall ABI 2022-03-15 03:39:58 +01:00
Sebastian Imlay
6a169f2134 Fix macOS test expectations
* Updated tests/expectations/Cargo.toml to use 2018 rust.
* Added Debug and Copy to objective-c structs.
* Fixed lifetimes in objective-c trait templates.
* Fixed imports for objective-c expectations tests.
2022-03-15 03:38:57 +01:00
Nicklas Boman
f34e4103f3 BINDGEN_EXTRA_CLANG_ARGS for dump_preprocessed_input.
Fixes #1723
2022-02-18 20:29:24 +01:00
Emilio Cobos Álvarez
cd78b65407 codegen: Use raw pointers rather than references in vtable functions.
Closes #2163
2022-02-18 20:11:57 +01:00
Emilio Cobos Álvarez
68d2b0e0f8 Put vtable generation behind a flag for now. 2022-02-18 20:11:57 +01:00
David Drysdale
e180d145a4 Add --allowlist-file option 2022-02-18 19:34:58 +01:00
Darren Kulp
ddfa28f91f docs: Update CONTRIBUTING.md for clang versions 2022-02-18 19:33:25 +01:00
Darren Kulp
f985aa5f29 book: Update Clang references from 3.9 -> 4.0 2022-02-18 19:33:25 +01:00
Darren Kulp
8be556a08e tests: Remove clang-3.9 expectations 2022-02-18 19:33:25 +01:00
Darren Kulp
c4532e0c17 parser: Simplify handle_function_macro for clang 4.0+ 2022-02-18 19:33:25 +01:00
Darren Kulp
69ee6fb243 parser: Simplify parse_macro for clang 4.0+
Here we delete a workaround that is no longer needed.
2022-02-18 19:33:25 +01:00
Darren Kulp
fdb762a9d4 clang: Stop accommodating libclang 3.9 2022-02-18 19:33:25 +01:00
Darren Kulp
5f5f6fa193 ci: Stop testing libclang 3.9 2022-02-18 19:33:25 +01:00
Jake Merdich
b3e6a9882f Allow fully-qualified derives
Adding a custom derive like "serde::Deserialize" results in a panic complaining
that it is not a valid Ident. Derive params are not identifiers, so treat it as
a token stream instead.
2022-02-18 19:32:08 +01:00
Adrian Taylor
71fe5fdcb6 Fix an erroneous +x bit on a source code file. 2022-02-18 19:31:42 +01:00
Mateusz Mikuła
ca78ae9c41 Bump MSRV to 1.54 2022-01-29 11:30:39 +01:00
Mateusz Mikuła
3bc4044c78 Upgrade Clap to version 3 2022-01-29 11:30:39 +01:00
Justin Moore
be6d07ac2c Mark all vtable functions as unsafe extern "C" 2022-01-29 11:29:00 +01:00
Dr. Chat
0587ff95a9 On second thought, don't generate virtual destructors 2022-01-29 11:29:00 +01:00
Dr. Chat
f578b0b450 Mark all vtable functions as pub 2022-01-29 11:29:00 +01:00
Dr. Chat
604792310e Account for virtual destructors 2022-01-29 11:29:00 +01:00
Dr. Chat
acfc9ac95b Pass the vtable's base class as the first parameter 2022-01-29 11:29:00 +01:00
Dr. Chat
e755ea4a6d Extremely basic Vtable generation 2022-01-29 11:29:00 +01:00
MikuroXina
e24afad6a1 Change into PathBuf 2021-12-29 20:39:01 +01:00
MikuroXina
0d95ea126a Derive some traits 2021-12-29 20:39:01 +01:00
MikuroXina
fc5ac7b439 More detailed error 2021-12-29 20:39:01 +01:00
MikuroXina
24cfccd9c5 Remove deprecation and Replace 2021-12-29 20:39:01 +01:00
MikuroXina
5685440dbb Add non_exhaustive 2021-12-29 20:39:01 +01:00
MikuroXina
c9495faa48 Remove 'error: ' part 2021-12-29 20:39:01 +01:00
MikuroXina
b5e39bce5d Merge into new one 2021-12-29 20:39:01 +01:00
MikuroXina
66cc4598e4 Replace generate with gen in test 2021-12-29 20:39:01 +01:00
MikuroXina
c97169673b Impl Error trait for BindgenError 2021-12-29 20:39:01 +01:00
MikuroXina
c8f11665d4 Add BindgenError 2021-12-29 20:39:01 +01:00
Emilio Cobos Álvarez
ada0ac5210 codegen: Don't automatically derive Debug and Copy for non-rust enums.
Fixes #2143
2021-12-29 20:20:19 +01:00
Triss Healy
bcbd72d7f8 Handle difference between clang and rust targets on RISC-V. 2021-12-12 13:38:56 +01:00
MikuroXina
1d250491fc Add args 2021-12-07 00:21:16 +01:00
MikuroXina
949e610f6b Fix warnings on tests 2021-12-07 00:21:16 +01:00
Aapo Alasuutari
421e0eea16 Add note about RVO in cpp.md
`bindgen`'s inability to currently support RVO should be noted in C++ bindings generation document.
2021-12-07 00:19:02 +01:00
MikuroXina
b1af6a42f5 Remove fields never read 2021-12-07 00:18:32 +01:00
Emilio Cobos Álvarez
8903264904 Bump version.
* cexpr+env_logger bump.
 * Various fixes for C++ crashes / hangs.
 * Enums now respect annotations and derives properly in more cases.
 * Some more APIs (blocklist-file, etc).
 * 'static lifetime is elided when appropriate.
2021-11-26 02:53:18 +01:00
David Drysdale
7bd23291e2
Add --blocklist-file option (#2097)
Update Item to hold a `clang::SourceLocation` and use this to allow
blocklisting based on filename.

The existing code has a special case that always maps <stdint.h> integer
types to corresponding Rust integer types, even if the C types are
blocklisted.  To match this special case behaviour, also treat these
C <stdint.h> types as being eligible for derived Copy/Clone/Debug
traits.

Fixes #2096
2021-11-26 02:42:47 +01:00
Alberto Planas
04f5c07158 Drop 'static for pub const strings for rustc>1.17
Constant and static declaration have a 'static live time by default,
that is already elided since 1.17.

Clippy complains on this kind of strings that are present in the
generated code.

This patch remove the 'static live time for those strings when rustc >
1.17 via a new added RustFeature.

Fix #1612

Signed-off-by: Alberto Planas <aplanas@suse.com>
2021-11-26 02:36:23 +01:00
follower
302b4842a3 Typo fix: "in side" -> "inside" 2021-11-26 02:33:53 +01:00
Eric Seppanen
0a24ab3a30 allow custom derives on enums
Custom derives are just as useful on enums as they are on structs; not
supporting this was an oversight.

Adds a test that will fail to compile if the custom derive doesn't work
on enums. This test fails without the codegen fix.
2021-11-26 02:33:39 +01:00
Fionera
2aed6b0216 context: Escape the try keyword properly 2021-10-30 02:10:46 +02:00
Adrian Taylor
da3f3a3ab1 Avoid case of a self-referential type alias.
This previously produced a type alias which referred to itself,
which was clearly wrong and resulted in downstream code recursing
infinitely.

The problem case (per bug #2102) is:

  template <typename> class B{};
  template <typename c> class C {
  public:
    using U = B<c>;
  };
  class A : C<A> {
    U u;
  };

As far as I can tell, we parse clang's definition of B<A>; that leads
us to parse A; to find it has a field U which turns out to be of type
B<A>. And so we hit the line in item.rs which says:
  debug!("Avoiding recursion parsing type: {:?}", ty);
and bail out, returning the original item ID: hence, a self-
referential typedef is created.

The 'fix' in this PR creates an opaque type in this case instead,
to avoid later infinite loops. It would be preferable to avoid this
situation in the first place, but presumably that would require
us to split the parsing phase into two:
1) types
2) fields within those types.

Fixes #2102.
2021-10-27 19:23:31 +02:00
Theodore Dubois
5785340546 Don't generate 2^64 byte padding fields on unions
The --explicit-padding flag would make bindgen try to add tail padding
to rust unions, by adding up the size of all the union fields and
subtracting from the size of the union as given by clang. The total size
of a union's fields is always larger than the union, so the subtraction
underflowed and bindgen produced padding fields larger than addressable
RAM.
2021-10-27 19:22:51 +02:00