Proto commits in google/crubit

These commits are when the Protocol Buffers files have changed: (only the last 100 relevant commits are shown)

Commit:77d2137
Author:Ethan Smith
Committer:Copybara-Service

Internal change. PiperOrigin-RevId: 1019254167

Commit:38833ad
Author:Ethan Smith
Committer:Copybara-Service

Internal change. PiperOrigin-RevId: 1018517366

Commit:5b46483
Author:Ethan Smith
Committer:Copybara-Service

Align Copybara exclusions and path rewrites for OSS Bazel tests PiperOrigin-RevId: 1018440015

Commit:c17ebc9
Author:Ethan Smith
Committer:Copybara-Service

Align Copybara exclusions and path rewrites for OSS Bazel tests PiperOrigin-RevId: 1017347040

Commit:1d4b9f8
Author:Taylor Cramer
Committer:Copybara-Service

Fix E0259 in cc_bindings_from_rs glue for same-named proto_library deps. A `rust_proto_library` reuses the rlib of its `proto_library`, so rustc's name for the crate is the `proto_library` name (e.g. `extension`), while users refer to it by the `rust_proto_library` name (e.g. `a_extension_rust_proto`). The generated `*_cc_api_impl.rs` spelled paths using rustc's crate name and emitted `extern crate a_extension_rust_proto as extension;` to make that resolve. When a crate depends on two `rust_proto_library` targets whose `proto_library` targets share a name, the aliases collide (`E0259`) and both crates' items are spelled `::extension::...`. `cc_bindings_from_rs` now maps each dependency `CrateNum` to the name it was passed under via `--extern` (matched by file stem of the loaded crate) and uses that name when spelling Rust paths. The `extern crate ... as ...;` aliases that are no longer needed are not emitted. PiperOrigin-RevId: 1013306145

Commit:9a91302
Author:Ethan Smith
Committer:Copybara-Service

Remove unused Protobuf IR schemas, FFI shims, and Cargo crates. Now that we use the ad-hoc IR everywhere in rs_bindings_from_cc, we can start cleaning up the protobuf and proto related code. PiperOrigin-RevId: 1012141974

Commit:3bbbc45
Author:Taylor Cramer
Committer:Copybara-Service

rs_bindings_from_cc: treat C++ records containing rs boxes as Rust-movable. Annotates `rs::Box`, `rs::PinBox`, `rs::SliceBox`, and `rs::StrBox` with `CRUBIT_UNSAFE_BITWISE_RELOCATABLE` so Crubit recognizes them as Rust-movable even though their C++ copy and move constructors are deleted. Updates `CheckOwnSpecialMembers` in `bitwise_relocatable.cc` (following C++26 P2786 trivial-relocatability composition rules) so that an unannotated record or union whose subobjects are all bitwise-relocatable remains bitwise-relocatable when its defaulted copy or move constructor is implicitly deleted due to a subobject. Records made Rust-movable this way can be moved and returned by value in Rust, while passing them by value *to* C++ as a parameter is rejected because the generated C++ thunk cannot relocate them without a C++ copy or move constructor. PiperOrigin-RevId: 1005101173

Commit:ade1da6
Author:Ethan Smith
Committer:Copybara-Service

Remove unused Protobuf IR schemas, FFI shims, and Cargo crates. Now that we use the ad-hoc IR everywhere in rs_bindings_from_cc, we can start cleaning up the protobuf and proto related code. PiperOrigin-RevId: 1004330989

Commit:946f877
Author:Taylor Cramer
Committer:Copybara-Service

Move template instantiations with mangled names into a zz_template_instantiations module. Class template instantiations that aren't named after a C++ type alias have a mangled `__CcTemplateInst...` name. Instead of hiding them from rustdoc with `#[doc(hidden)]`, which leaves functions that take or return them with unlinked types, they are now generated in a `zz_template_instantiations` module (which sorts last in rustdoc), together with their nested-item modules and the mangled names of the instantiations that are named after an alias. This keeps them documented without cluttering the rest of the API. A `#[doc(hidden)] pub use self::zz_template_instantiations::*;` keeps them available at their old path in the crate root. The generated C++ code is unchanged. PiperOrigin-RevId: 1009981439

Commit:420938c
Author:Taylor Cramer
Committer:Copybara-Service

Name template instantiations after type aliases, and hide mangled names from rustdoc. Previously, every class template instantiation was generated as a struct with a mangled name (e.g. `__CcTemplateInstN2ns10MyTemplateIiEE`) in the crate root, and type aliases to it as `pub type MyAlias = crate::__CcTemplateInst...;`. This clutters the rustdoc output of the bindings, and since rustdoc doesn't show the fields or methods of a hidden type on the page of an alias to it, the mangled structs couldn't simply be hidden. Now, an instantiation is generated under the name of the first type alias for it in the current target, in the module of that alias: * Only namespace-scope aliases that are not in an anonymous namespace, not deprecated, and that name the instantiation exactly (e.g. not `const`) are used. Instantiations in `std`, bridge types, instantiations with special handling (e.g. `std::vector`), and instantiations with lifetime parameters keep their mangled name. * Other aliases for the same instantiation become aliases of the renamed struct. * The C++ name of the struct is unchanged, so the generated C++ code and the `forward_declare` symbols are the same as before. * The mangled name is kept as a `#[doc(hidden)]` alias in the crate root, so existing references to it keep working. Structs that still have a mangled name (instantiations without an eligible alias) are now `#[doc(hidden)]`. PiperOrigin-RevId: 1009793794

Commit:e8bc9ff
Author:Lukasz Anforowicz
Committer:Copybara-Service

Don't require experimental for the default calling convention. On 32-bit x86 Windows, `__thiscall` is the default calling convention of non-variadic instance methods (including constructors and operators). Before this CL, `rs_bindings_from_cc` required the `experimental` feature for all functions that don't use the C calling convention. Therefore, with the `supported` feature set, no instance method got bindings on this platform ("non-C calling convention"). This blocked Chromium from using `rs_bindings_from_cc` on Windows - see https://ci.chromium.org/ui/p/chromium/builders/try/win_chromium_compile_dbg_ng/3084387/overview ``` error[E0599]: no method named `InMicroseconds` found for struct `TestTimeDelta` in the current scope --> gen/build/rust/tests/test_rust_api_from_cpp/extra_rust_sources/time_delta.rs:20:38 | 20 | let us = u64::try_from(delta.InMicroseconds())?; | ^^^^^^^^^^^^^^ method not found in `TestTimeDelta` | ``` The Rust side never calls such functions directly: `can_skip_cc_thunk` always uses an `extern "C"` C++ thunk for them, and the thunk calls the C++ function with the right calling convention. Therefore after this CL, only a non-default calling convention (e.g. an explicit `[[clang::vectorcall]]`) requires the `experimental` feature. PiperOrigin-RevId: 1009109526

Commit:935d9f7
Author:Luke Zarko
Committer:Copybara-Service

[crubit] Generate setter-shaped constructors without a C++ thunk. Under the `thunkless_accessors` feature, a user-provided inline constructor whose body is empty, and whose only written initializers copy scalar parameters into fields, e.g. ```c++ S(int a, const int* p) : a_(a), p_(p) {} ``` is now implemented in Rust by zero-filling the object and then writing each parameter into its field at the field's offset, instead of by calling a C++ thunk. This includes `S() {}`. `!Unpin` records get the same body inside the `FnCtor` closure. The importer extends `MemberFuncSemantic.Constructor` with a list of `FieldInit { type, offset, param_index }`, and only fills it in if: * the record is not polymorphic, has no virtual bases, and zero-initializing it produces all zero bytes (as for trivial default constructors); * the constructor is not deleted, defaulted, delegating, or variadic, and is defined in a header with an empty body (no function-try-block); * every parameter has a scalar type (no references or records); * every written initializer is `field(param)` or `field{param}`, for a field of the record itself (not a base, not an anonymous union member, not volatile, not a bitfield, not protected by pointer field protection, suitably aligned), with the field and parameter types the same up to cv-qualifiers and aliases; * every other initializer is an implicit call of a trivial default constructor (so no default member initializers). The generator additionally requires each field and parameter to pass the same check as a thunkless setter (primitives and plain C++ pointers only), and otherwise keeps the thunk. C++ leaves the fields that such a constructor doesn't initialize with an indeterminate value, so zero is a valid value for them. C++ initializes fields in declaration order rather than initializer order, which is unobservable here since the initializers have no side effects. PiperOrigin-RevId: 1009165560

Commit:1b8506f
Author:Luke Zarko
Committer:Copybara-Service

Implement trivial default constructors without a C++ thunk. With `thunkless_accessors`, a trivial default constructor is now generated as a zero-fill in Rust, rather than as a call to a C++ thunk: * For an `Unpin` type: `MaybeUninit::<Self>::zeroed().assume_init()`. * For a `!Unpin` type: an `FnCtor` that calls `write_bytes(0, 1)` on the destination. The C++ thunk value-initializes the object (`crubit::construct_at(p)`), which, for a trivial default constructor, zero-initializes it. That is the same as zero-filling it, unless zero-initialization produces a bit pattern other than all zero bytes. The importer therefore excludes records which contain, directly or through arrays, fields, or bases: * pointers to members, whose null value is not all zero bytes in common ABIs, * pointers whose null value is not all zero bytes on the target, or * fields protected by pointer field protection. The importer marks eligible constructors with a new, empty `Constructor` `MemberFuncSemantic`. Other constructors still get no semantic (see https://github.com/google/crubit/commit/a1ecb459ca855ffcf7481ed4b44f925840845f73). The `FuncsWithSemantic` test helper now only collects getters and setters, since default constructors can now have a semantic too. PiperOrigin-RevId: 1008610985

Commit:22df82f
Author:Luke Zarko
Committer:Copybara-Service

Implement trivial default constructors without a C++ thunk. With `thunkless_accessors`, a trivial default constructor is now generated as a zero-fill in Rust, rather than as a call to a C++ thunk: * For an `Unpin` type: `MaybeUninit::<Self>::zeroed().assume_init()`. * For a `!Unpin` type: an `FnCtor` that calls `write_bytes(0, 1)` on the destination. The C++ thunk value-initializes the object (`crubit::construct_at(p)`), which, for a trivial default constructor, zero-initializes it. That is the same as zero-filling it, unless zero-initialization produces a bit pattern other than all zero bytes. The importer therefore excludes records which contain, directly or through arrays, fields, or bases: * pointers to members, whose null value is not all zero bytes in common ABIs, * pointers whose null value is not all zero bytes on the target, or * fields protected by pointer field protection. The importer marks eligible constructors with a new, empty `Constructor` `MemberFuncSemantic`. This also stops constructors from being treated as setters, as in unknown commit. PiperOrigin-RevId: 1006726973

Commit:2c87a02
Author:Googler
Committer:Copybara-Service

Remove the unstructured `source_loc` from rs_bindings_from_cc's IR. Everything now reads an item's location from the structured `decl_loc`, so remove the `source_loc` text: the IR fields (now reserved), the importer's `ConvertSourceLocation`, and `GenericItem::source_loc`. The text that goes into generated doc comments is produced by `DeclLocation`'s `Display` instead, and the tests of that text now check it. Generated bindings don't change (all golden tests pass unchanged). PiperOrigin-RevId: 1007326160

Commit:bd906ea
Author:Googler
Committer:Copybara-Service

Add a structured declaration location to rs_bindings_from_cc's IR. Each item's location is stored in the IR only as `source_loc`, the text that goes into generated doc comments, e.g. Generated from: path/to/macro.h;l=3[34,37] Expanded at: path/to/header.h;l=12[0,0] The values it is formatted from aren't kept, so code that needs them parses the text back (e.g. `parse_extended_source_loc` for the Kythe offsets, or checking whether the location contains `libcxx`). Add `DeclLocation` to the IR, set as `decl_loc` on every item that has a `source_loc`: the spelling location (path and line), where the macro is expanded for declarations produced by a macro expansion, and the name's byte offsets when generating Kythe annotations. The importer fills it with the new `ConvertDeclLocation`. In Rust, it is exposed as `GenericItem::decl_loc`, backed directly by the proto view, and displays as the existing `source_loc` text; a test checks this for each kind of item, with and without Kythe annotations, including macro expansions. (The one difference: for a macro expansion whose expansion file is unknown, the old text ended with a `<unknown location>` line, which is now omitted.) Nothing reads `decl_loc` yet. Follow-ups move the readers of `source_loc` over to it and then remove `source_loc`. PiperOrigin-RevId: 1007214143

Commit:4082dfb
Author:Googler
Committer:Copybara-Service

Add a structured declaration location to rs_bindings_from_cc's IR. Each item's location is stored in the IR only as `source_loc`, the text that goes into generated doc comments, e.g. Generated from: path/to/macro.h;l=3[34,37] Expanded at: path/to/header.h;l=12[0,0] The values it is formatted from aren't kept, so code that needs them parses the text back (e.g. `parse_extended_source_loc` for the Kythe offsets, or checking whether the location contains `libcxx`). Add `DeclLocation` to the IR, set as `decl_loc` on every item that has a `source_loc`: the spelling location (path and line), where the macro is expanded for declarations produced by a macro expansion, and the name's byte offsets when generating Kythe annotations. The importer fills it with the new `ConvertDeclLocation`. In Rust, it is exposed as `GenericItem::decl_loc`, backed directly by the proto view, and displays as the existing `source_loc` text; a test checks this for each kind of item, with and without Kythe annotations, including macro expansions. (The one difference: for a macro expansion whose expansion file is unknown, the old text ended with a `<unknown location>` line, which is now omitted.) Nothing reads `decl_loc` yet. Follow-ups move the readers of `source_loc` over to it and then remove `source_loc`. PiperOrigin-RevId: 1002584273

Commit:b983ec6
Author:Luke Zarko
Committer:Copybara-Service

Implement trivial default constructors without a C++ thunk. With `thunkless_accessors`, a trivial default constructor is now generated as a zero-fill in Rust, rather than as a call to a C++ thunk: * For an `Unpin` type: `MaybeUninit::<Self>::zeroed().assume_init()`. * For a `!Unpin` type: an `FnCtor` that calls `write_bytes(0, 1)` on the destination. The C++ thunk value-initializes the object (`crubit::construct_at(p)`), which, for a trivial default constructor, zero-initializes it. That is the same as zero-filling it, unless zero-initialization produces a bit pattern other than all zero bytes. The importer therefore excludes records which contain, directly or through arrays, fields, or bases: * pointers to members, whose null value is not all zero bytes in common ABIs, * pointers whose null value is not all zero bytes on the target, or * fields protected by pointer field protection. The importer marks eligible constructors with a new, empty `Constructor` `MemberFuncSemantic`. This also stops constructors from being treated as setters, as in unknown commit. PiperOrigin-RevId: 1006726973

Commit:820c33c
Author:Googler
Committer:Copybara-Service

Add a structured declaration location to rs_bindings_from_cc's IR. Each item's location is stored in the IR only as `source_loc`, the text that goes into generated doc comments, e.g. Generated from: path/to/macro.h;l=3[34,37] Expanded at: path/to/header.h;l=12[0,0] The values it is formatted from aren't kept, so code that needs them parses the text back (e.g. `parse_extended_source_loc` for the Kythe offsets, or checking whether the location contains `libcxx`). Add `DeclLocation` to the IR, set as `decl_loc` on every item that has a `source_loc`: the spelling location (path and line), where the macro is expanded for declarations produced by a macro expansion, and the name's byte offsets when generating Kythe annotations. The importer fills it with the new `ConvertDeclLocation`. In Rust, it is exposed as `GenericItem::decl_loc`, backed directly by the proto view, and displays as the existing `source_loc` text; a test checks this for each kind of item, with and without Kythe annotations, including macro expansions. (The one difference: for a macro expansion whose expansion file is unknown, the old text ended with a `<unknown location>` line, which is now omitted.) Nothing reads `decl_loc` yet. Follow-ups move the readers of `source_loc` over to it and then remove `source_loc`. PiperOrigin-RevId: 1002584273

Commit:bb2cecb
Author:Googler
Committer:Copybara-Service

Import fixed-size C-style arrays into Crubit IR, but don't yet generate bindings - Add `ConstantArrayType` type to IR. - Update `Importer::ConvertUnattributedType` to import non-zero fixed-size C-style arrays of non-void primitives and enums (including nested multidimensional arrays) in the IR, while keeping `CcTypeVariant::ConstantArray` gated as unsupported in `rs_type_kind.rs` so generated Rust bindings are unchanged. The next commit will start generating bindings. PiperOrigin-RevId: 1005814743

Commit:b1fc5df
Author:Googler
Committer:Copybara-Service

Generate Rust bindings for constant-size array fields, but gate behind :experimental - Add RsTypeKind for constant arrays, generated from the IR / CCType for ConstantArray arrays from an earlier patch. - Gate `RsTypeKind::Array` field bindings on feature `experimental` so that we can review smaller patches, refine it, and test more before releasing. - Keep C-style array global variables and function signatures unsupported. PiperOrigin-RevId: 1004883736

Commit:43000c9
Author:Googler
Committer:Copybara-Service

Report the errors that an unsupported item was formatted from. When generating bindings for an item fails, `new_unsupported_item_with_cause` formats the error into a string and stores it as the `UnsupportedItem`'s `ir::FormattedError`, with `fmt` and `message` both set to that string. The error report then gets one error per failed item whose format string is the whole message, so it can't aggregate similar errors, and it loses the structure of the error: each reason in an `ErrorList`, and (with the error tree) which item without bindings caused each one. Keep the original error as a Rust-only `cause` on `ir::FormattedError`, and report it instead of the flattened message, via `error_report::because`. The generated comment still shows the same message. This changes the report for items that fail during bindings generation: an item that failed for several reasons now has one error per reason, each with its own format string, instead of a single error with the joined message. Errors from the C++ importer are unchanged. PiperOrigin-RevId: 1005522804

Commit:d5060a5
Author:Googler
Committer:Copybara-Service

Report which item without bindings caused each error in Crubit's error report. Many errors in the report aren't intrinsic to the item they're reported on: `void F(A*)` fails because `A` has no bindings, which may in turn be because of `B`. The report only has the message text, so tools that want to find root causes or count how many items a fix would unblock have to parse messages. Add an optional `blocked_by` (name, unique name, defining target) to each reported error, omitted when unset so existing readers are unaffected, and two ways to record it: * `blocked_by(item, error)`: an error that displays like `error` (the reason `item` has no bindings), and is reported as blocked by `item`. * `because(message, cause)`: an error that displays as `message`, but is reported as `cause`. Use it when formatting one error into another, so that the errors inside, and what they are blocked by, are still reported. A blocked error inside is reported with the `because` message (e.g. "Parameter #0 is not supported: ..."), which says where it occurred, rather than with the reason for the blocker, which is reported for the blocker. `blocked_by` is only the direct cause: `F`'s error is blocked by `A`, and `A`'s own error says what `A` is blocked by. Messages don't change. Nothing records blockers yet; that follows separately for `rs_bindings_from_cc`. PiperOrigin-RevId: 1001198322

Commit:49fb99d
Author:Taylor Cramer
Committer:Copybara-Service

Fix broken live-snippet and mdBook include directives in Crubit docs. * Export the example source files in `examples/types/absl_status/` (excluding only `examples/types/absl_status/BUILD` instead of `examples/types/absl_status/**`) so that the `{{ #include ../../examples/types/absl_status/... }}` directives in `docs/types/absl_status.md` resolve during `mdbook build`, and include `examples/` in Copybara's `.proto.h` to `.pb.h` header rewrite. * Unindent the four list-nested `live-snippet` code blocks in `g3doc/cpp/inline_cpp.md` and `g3doc/cpp/carcinize.md`. Indented `live-snippet` blocks were not matched by Copybara's `live-snippet` transform, and mdBook's `{{ #include ... }}` preprocessor inserts lines 2..N at column 0, which breaks out of list-indented fenced code blocks after blank lines. * Add a `core.verify_match` check in `copy.bara.sky` to ensure no untransformed `live-snippet` fences remain in exported `g3doc` files. PiperOrigin-RevId: 1005269980

Commit:3a6cd6c
Author:Ethan Smith
Committer:Copybara-Service

Clean up FFI IR and domain IR in C++ and Rust. - Remove `*View<'a>` types, duplicate `*Oneof<'a>` view enums, `AsView`, `RepeatedView`, and `MapView` from `ir_codegen.rs`, `ir_generated.rs`, and `ir_ffi_support.rs`; emit read accessors directly on owned FFI structs and rename setters to `set_*`. - Use `ir_generated::*` structs and enums directly as the domain IR types in `ir.rs`, removing duplicate domain wrapper structs, `self.proto`, `ProtoToIr`, `derive_debug_partialeq_eq_hash!`, and the `'pb` lifetime parameter across `ir.rs` and `generate_bindings/`. - Add `FfiRc<T>` (`#[repr(C)]` non-atomic reference-counted smart pointer) in `ir_ffi_support.{h,rs}` and wrap top-level `Item` variants in `FfiRc<...>` for zero-copy O(1) cloning in Salsa queries. - Unify C-style and algebraic tagged-union enums under `enum` and `Enum("...")` in `ir_codegen.rs`, and emit strongly-typed `ItemId`, `LifetimeId`, `BazelLabel`, `Usize`, and `Primitive` directly in the schema. - Rename `GenerateBindingsRequest::ir_proto` to `ir` and `GenerateBindingsProtoCall` to `GenerateBindingsCall`. - Eliminate `WriteToProto` and duplicate wrapper structs in `ir.h`/`ir.cc`, and emit C++ single-field constructors, `oneof` variant constructors, and `Unit` variant factory methods in `ir_generated.h` so C++ importers construct `ir_proto::*` (`ffi::*`) types directly. PiperOrigin-RevId: 1004330989

Commit:2b73a65
Author:Ethan Smith
Committer:Copybara-Service

Cut over C++ importers, Rust IR, and FFI boundary to ad-hoc FFI IR. - Migrate C++ importers (`ir.h`, `ir.cc`, `importer.cc`, `importers/*.cc`) from `ir.pb.h` to `::crubit::ffi` (`ir_generated.h`). - Pass `ffi::GenerateBindingsRequest`, `ffi::GenerateBindingsResponse`, and `ffi::IRProto` directly in-memory across `extern "C"` FFI without Protobuf serialization (`src_code_gen_ffi`, `cc_api_ffi`, `proto_from_cc`). - Remove `src_code_gen_ffi_native_proto.cc`, `src_code_gen_ffi_serialized_proto.cc`, `cc_api_ffi_native_proto.rs`, `cc_api_ffi_serialized_proto.rs`, `ir.proto`, and `generate_bindings.proto`. - Consolidate `proto_to_ir.rs` into `ir.rs` and migrate Rust IR and tests (`ir.rs`, `ir_matchers.rs`, `ir_from_cc_proto_test.rs`, `generate_bindings_test.rs`) to `ir_generated` and `ir::proto!`. - Update `importer_test.cc` to match `ffi::*` IR items directly with GoogleTest matchers. - Remove Protobuf dependencies from `third_party/crubit/cargo/` via `golden_update.sh`. PiperOrigin-RevId: 1004330994

Commit:26d0c3d
Author:Googler
Committer:Copybara-Service

Import fixed-size C-style arrays into Crubit IR, but don't yet generate bindings - Add `ConstantArrayType` type to IR. - Update `Importer::ConvertUnattributedType` to import non-zero fixed-size C-style arrays of non-void primitives and enums (including nested multidimensional arrays) in the IR, while keeping `CcTypeVariant::ConstantArray` gated as unsupported in `rs_type_kind.rs` so generated Rust bindings are unchanged. The next commit will start generating bindings. PiperOrigin-RevId: 1004883731

Commit:887b1b3
Author:Googler
Committer:Copybara-Service

Fix layout and codegen bugs for explicitly aligned fields, typedefs, and packed records - Reject `packed` records whose fields carry an explicit alignment attribute exceeding the record's packing alignment (`E0587` / mismatched `alignof`). - Mark fields with explicit alignment attributes (`alignas` / `__attribute__((aligned))`) as unsupported for field layout even when `:experimental` is enabled, so they fall back to padded byte blobs instead of losing field alignment. - Reject non-anonymous `typedef` / `using` type aliases and alias templates with explicit alignment attributes, since Rust `type` aliases do not preserve alignment. - Do not generate safe reference `[[no_unique_address]]` accessors on `packed` records, which would create unaligned references. PiperOrigin-RevId: 1004719575

Commit:4954e23
Author:Ethan Smith
Committer:Copybara-Service

Clean up FFI IR and domain IR in C++ and Rust. - Remove `*View<'a>` types, duplicate `*Oneof<'a>` view enums, `AsView`, `RepeatedView`, and `MapView` from `ir_codegen.rs`, `ir_generated.rs`, and `ir_ffi_support.rs`; emit read accessors directly on owned FFI structs and rename setters to `set_*`. - Use `ir_generated::*` structs and enums directly as the domain IR types in `ir.rs`, removing duplicate domain wrapper structs, `self.proto`, `ProtoToIr`, `derive_debug_partialeq_eq_hash!`, and the `'pb` lifetime parameter across `ir.rs` and `generate_bindings/`. - Add `FfiRc<T>` (`#[repr(C)]` non-atomic reference-counted smart pointer) in `ir_ffi_support.{h,rs}` and wrap top-level `Item` variants in `FfiRc<...>` for zero-copy O(1) cloning in Salsa queries. - Unify C-style and algebraic tagged-union enums under `enum` and `Enum("...")` in `ir_codegen.rs`, and emit strongly-typed `ItemId`, `LifetimeId`, `BazelLabel`, `Usize`, and `Primitive` directly in the schema. - Rename `GenerateBindingsRequest::ir_proto` to `ir` and `GenerateBindingsProtoCall` to `GenerateBindingsCall`. - Eliminate `WriteToProto` and duplicate wrapper structs in `ir.h`/`ir.cc`, and emit C++ single-field constructors, `oneof` variant constructors, and `Unit` variant factory methods in `ir_generated.h` so C++ importers construct `ir_proto::*` (`ffi::*`) types directly. PiperOrigin-RevId: 1004330989

Commit:5f6922c
Author:Ethan Smith
Committer:Copybara-Service

Cut over C++ importers, Rust IR, and FFI boundary to ad-hoc FFI IR. - Migrate C++ importers (`ir.h`, `ir.cc`, `importer.cc`, `importers/*.cc`) from `ir.pb.h` to `::crubit::ffi` (`ir_generated.h`). - Pass `ffi::GenerateBindingsRequest`, `ffi::GenerateBindingsResponse`, and `ffi::IRProto` directly in-memory across `extern "C"` FFI without Protobuf serialization (`src_code_gen_ffi`, `cc_api_ffi`, `proto_from_cc`). - Remove `src_code_gen_ffi_native_proto.cc`, `src_code_gen_ffi_serialized_proto.cc`, `cc_api_ffi_native_proto.rs`, `cc_api_ffi_serialized_proto.rs`, `ir.proto`, and `generate_bindings.proto`. - Consolidate `proto_to_ir.rs` into `ir.rs` and migrate Rust IR and tests (`ir.rs`, `ir_matchers.rs`, `ir_from_cc_proto_test.rs`, `generate_bindings_test.rs`) to `ir_generated` and `ir::proto!`. - Update `importer_test.cc` to match `ffi::*` IR items directly with GoogleTest matchers. - Remove Protobuf dependencies from `third_party/crubit/cargo/` via `golden_update.sh`. PiperOrigin-RevId: 1004330994

Commit:013108b
Author:Googler
Committer:Copybara-Service

Read declaration locations from the structured `decl_loc` in rs_bindings_from_cc. Move every reader of an item's `source_loc` text over to its structured `decl_loc`: * Doc comments and unsupported-item comments: `generate_doc_comment` takes a `DeclLocation`, which displays as the same text. * Kythe capture tags: `kythe_name_location` reads the name's byte offsets directly, replacing `parse_extended_source_loc` and its regex. * Skipping comments for unsupported libc++ items: checks the spelling and expansion paths instead of searching the text. * The fatal error for `CRUBIT_MUST_BIND` functions, `Display` for type aliases, and the hash in thunk names: use the displayed `decl_loc`, which is the same text. Generated bindings don't change (all golden tests pass unchanged). A follow-up removes `source_loc`. PiperOrigin-RevId: 1002722694

Commit:94f09a8
Author:Googler
Committer:Copybara-Service

Support packed structs in `rs_bindings_from_cc`. Enable Rust bindings for packed C++ structs (`__attribute__((packed))` and `#pragma pack(N)`), generating `#[repr(C, packed)]` and `#[repr(C, packed(N))]`. This guarantees matching memory layouts, alignments, field offsets, and array strides between C++ and Rust without requiring data copies or transformations. Structs with field-level packed attributes remain unsupported. PiperOrigin-RevId: 1004031561

Commit:6e95665
Author:Googler
Committer:Copybara-Service

Add a structured declaration location to rs_bindings_from_cc's IR. Each item's location is stored in the IR only as `source_loc`, the text that goes into generated doc comments, e.g. Generated from: path/to/macro.h;l=3[34,37] Expanded at: path/to/header.h;l=12[0,0] The values it is formatted from aren't kept, so code that needs them parses the text back (e.g. `parse_extended_source_loc` for the Kythe offsets, or checking whether the location contains `libcxx`). Add `DeclLocation` to the IR, set as `decl_loc` on every item that has a `source_loc`: the spelling location (path and line), where the macro is expanded for declarations produced by a macro expansion, and the name's byte offsets when generating Kythe annotations. The importer fills it with the new `ConvertDeclLocation`. In Rust, it is exposed as `GenericItem::decl_loc`, backed directly by the proto view, and displays as the existing `source_loc` text; a test checks this for each kind of item, with and without Kythe annotations, including macro expansions. (The one difference: for a macro expansion whose expansion file is unknown, the old text ended with a `<unknown location>` line, which is now omitted.) Nothing reads `decl_loc` yet. Follow-ups move the readers of `source_loc` over to it and then remove `source_loc`. PiperOrigin-RevId: 1002584273

Commit:cb9232c
Author:Googler
Committer:Copybara-Service

Add a structured declaration location to rs_bindings_from_cc's IR. Each item's location is stored in the IR only as `source_loc`, the text that goes into generated doc comments, e.g. Generated from: path/to/macro.h;l=3[34,37] Expanded at: path/to/header.h;l=12[0,0] The values it is formatted from aren't kept, so code that needs them parses the text back (e.g. `parse_extended_source_loc` for the Kythe offsets, or checking whether the location contains `libcxx`). Add `DeclLocation` to the IR, set as `decl_loc` on every item that has a `source_loc`: the spelling location (path and line), where the macro is expanded for declarations produced by a macro expansion, and the name's byte offsets when generating Kythe annotations. The importer fills it with the new `ConvertDeclLocation`. In Rust, it is exposed as `GenericItem::decl_loc`, backed directly by the proto view, and displays as the existing `source_loc` text; a test checks this for each kind of item, with and without Kythe annotations, including macro expansions. (The one difference: for a macro expansion whose expansion file is unknown, the old text ended with a `<unknown location>` line, which is now omitted.) Nothing reads `decl_loc` yet. Follow-ups move the readers of `source_loc` over to it and then remove `source_loc`. PiperOrigin-RevId: 1002584273

Commit:a426087
Author:Lukasz Anforowicz
Committer:Copybara-Service

Thunks for constructors and destructors of classes w/ virtual bases. Before this CL, the Rust bindings called non-inline constructors and destructors of classes with virtual bases directly (via `link_name`). This is wrong in the Microsoft C++ ABI: - Such constructors take an extra, hidden `is_most_derived` parameter [1] that the Rust code did not pass. - Normally only the callers emit the complete destructor ("vbase dtor") [2][3], so the link failed with an undefined symbol. After this CL, the IR records whether a class has virtual bases, and the bindings call constructors and destructors of such classes through a C++ thunk. This is done on all target platforms, so that the generated bindings do not depend on the target platform. [1] `MicrosoftCXXABI::buildStructorSignature`: https://github.com/llvm/llvm-project/blob/4fa92e8e51e6833f8d70ab9fa136d899e497f135/clang/lib/CodeGen/MicrosoftCXXABI.cpp#L1382-L1395 [2] `MicrosoftCXXABI::EmitCXXDestructors`: https://github.com/llvm/llvm-project/blob/4fa92e8e51e6833f8d70ab9fa136d899e497f135/clang/lib/CodeGen/MicrosoftCXXABI.cpp#L1453-L1464 [3] `linkonce_odr` linkage of `Dtor_Complete` in `MicrosoftCXXABI::getCXXDestructorLinkage`: https://github.com/llvm/llvm-project/blob/4fa92e8e51e6833f8d70ab9fa136d899e497f135/clang/lib/CodeGen/MicrosoftCXXABI.cpp#L1425-L1433 PiperOrigin-RevId: 1003461896

Commit:cb0304e
Author:Googler
Committer:Copybara-Service

Support packed structs in `rs_bindings_from_cc`. Enable Rust bindings for packed C++ structs (`__attribute__((packed))` and `#pragma pack(N)`), generating `#[repr(C, packed)]` and `#[repr(C, packed(N))]`. This guarantees matching memory layouts, alignments, field offsets, and array strides between C++ and Rust without requiring data copies or transformations. Structs with field-level packed attributes remain unsupported. PiperOrigin-RevId: 1000446993

Commit:3bb3eca
Author:Googler
Committer:Copybara-Service

rs_bindings_from_cc: Support std::string_view and absl::string_view constants Scalar C++ `std::string_view` and `absl::string_view` constants (`constexpr`, or `const`/`inline` with constant initialization) are now bound in Rust as `&'static str` when their contents are valid UTF-8, and as `&'static [u8]` otherwise. PiperOrigin-RevId: 1003249385

Commit:7da0757
Author:Googler
Committer:Copybara-Service

Build rs_bindings_from_cc doc comments in a single buffer. `generate_doc_comment` joined the comment, the safety section and the source location with blank lines by formatting intermediate strings and matching on which of them were present. Instead, write the sections that are present into one `String`, with a separator before each but the first. No change in behavior: generated doc comments are byte-identical. PiperOrigin-RevId: 1003139330

Commit:d2ca9a1
Author:Googler
Committer:Copybara-Service

Add `netinet/ether.h` to `LIBC_HEADERS` in `cc_std`. Generate Rust bindings for `<netinet/ether.h>`, enabling access to `ether_addr` and `ether_header` packed structs from `cc_std`. PiperOrigin-RevId: 1000484672

Commit:45f6f7d
Author:Luke Zarko
Committer:Copybara-Service

Give class template specializations a lifetime parameter for their template argument This is part of the resugaring-lite effort to make lifetimes+templates happy. Under assume_lifetimes, a lifetime written on a class template argument was ignored. Given template <class T> struct View { T value; }; View<int& $a> make(int& $a x); Crubit generated a `View` with no lifetime, so `make` returned a `View` that borrowed from nothing. The reason is that `View<int& $a>` and `View<int& $b>` are the same C++ type, `View<int&>`, so there was no place to record `$a`. This change gives `View<int&>` a lifetime parameter, `'T`, that stands for the lifetime of its argument: pub struct View<'T> { ... } // `T value` has lifetime 'T pub fn make<'a>(x: &'a mut c_int) -> View<'a> A specialization gets this parameter when it has a single type argument that carries a single lifetime: a reference, a pointer, or a record with one lifetime parameter. Writing a lifetime on both the argument and the type, `View<int& $a> $b`, is an error. Two rules keep `'T` from being chosen freely by the caller: * A constructor that takes a reference, pointer or lifetime-carrying record must take it as `T`/`const T&` or mark it `[[clang::lifetimebound]]`; otherwise the constructor gets no bindings. Without this, `Box(int& other)` would let safe Rust build a `Box<'static>` from a short-lived reference. * In member functions and in-class friends, `View` parameters and returned `View&` get `'T`. Without this, a copy constructor would turn a `View<'a>` into a `View<'b>`. Excluded: partial and explicit specializations, bridged types, templates in std/absl/c9/rs_std, and templates with their own LIFETIME_PARAMS. Not yet handled (the written lifetime is still dropped): more than one template argument, arguments with more than one lifetime (`View<int**>`), member typedefs (`Holder<int* $a>::type`), and type aliases with a lifetime (`using V = View<int& $a>`, b/498977848). The IR gets a new field, `Record.has_template_argument_lifetime`. No golden files change. Also fixes the importer test helper `IrFromCcWithoutAssumedLifetimes`: it enabled no Crubit features, so class templates were never instantiated and the tests using it passed without testing anything. It now enables `supported`. PiperOrigin-RevId: 1002852411

Commit:1186c00
Author:Googler
Committer:Copybara-Service

Add a structured declaration location to rs_bindings_from_cc's IR. Each item's location is stored in the IR only as `source_loc`, the text that goes into generated doc comments, e.g. Generated from: path/to/macro.h;l=3[34,37] Expanded at: path/to/header.h;l=12[0,0] The values it is formatted from aren't kept, so code that needs them parses the text back (e.g. `parse_extended_source_loc` for the Kythe offsets, or checking whether the location contains `libcxx`). Add `DeclLocation` to the IR, set as `decl_loc` on every item that has a `source_loc`: the spelling location (path and line), where the macro is expanded for declarations produced by a macro expansion, and the name's byte offsets when generating Kythe annotations. The importer fills it with the new `ConvertDeclLocation`. In Rust, it is exposed as `GenericItem::decl_loc`, backed directly by the proto view, and displays as the existing `source_loc` text; a test checks this for each kind of item, with and without Kythe annotations, including macro expansions. (The one difference: for a macro expansion whose expansion file is unknown, the old text ended with a `<unknown location>` line, which is now omitted.) Nothing reads `decl_loc` yet. Follow-ups move the readers of `source_loc` over to it and then remove `source_loc`. PiperOrigin-RevId: 1002584273

Commit:ce70dbc
Author:Googler
Committer:Copybara-Service

Support packed structs in `rs_bindings_from_cc`. Enable Rust bindings for packed C++ structs (`__attribute__((packed))` and `#pragma pack(N)`), generating `#[repr(C, packed)]` and `#[repr(C, packed(N))]`. This guarantees matching memory layouts, alignments, field offsets, and array strides between C++ and Rust without requiring data copies or transformations. Structs with field-level packed attributes remain unsupported. PiperOrigin-RevId: 1000446993

Commit:52ad833
Author:Taylor Cramer
Committer:Copybara-Service

Propagate `clang::AlwaysInlineAttr` (`__attribute__((always_inline))`) to generated C++ thunks. When a C++ function (or its template instantiation pattern) is annotated with `__attribute__((always_inline))` / `[[gnu::always_inline]]` / `[[clang::always_inline]]`, record `is_always_inline` in Crubit's `Func` IR and emit `__attribute__((always_inline))` on the generated `extern "C"` C++ thunk (`__rust_thunk_...`). This ensures Cross-Language ThinLTO honors explicit `always_inline` annotations across the FFI boundary without forcing aggressive inlining on unannotated thunks. PiperOrigin-RevId: 1001920548

Commit:fbaf63b
Author:Luke Zarko
Committer:Copybara-Service

Give class template specializations a lifetime parameter for their template argument Under assume_lifetimes, a lifetime written on a class template argument was ignored. Given template <class T> struct View { T value; }; View<int& $a> make(int& $a x); Crubit generated a `View` with no lifetime, so `make` returned a `View` that borrowed from nothing. The reason is that `View<int& $a>` and `View<int& $b>` are the same C++ type, `View<int&>`, so there was no place to record `$a`. This change gives `View<int&>` a lifetime parameter, `'T`, that stands for the lifetime of its argument: pub struct View<'T> { ... } // `T value` has lifetime 'T pub fn make<'a>(x: &'a mut c_int) -> View<'a> A specialization gets this parameter when it has a single type argument that carries a single lifetime: a reference, a pointer, or a record with one lifetime parameter. Writing a lifetime on both the argument and the type, `View<int& $a> $b`, is an error. Two rules keep `'T` from being chosen freely by the caller: * A constructor that takes a reference, pointer or lifetime-carrying record must take it as `T`/`const T&` or mark it `[[clang::lifetimebound]]`; otherwise the constructor gets no bindings. Without this, `Box(int& other)` would let safe Rust build a `Box<'static>` from a short-lived reference. * In member functions and in-class friends, `View` parameters and returned `View&` get `'T`. Without this, a copy constructor would turn a `View<'a>` into a `View<'b>`. Excluded: partial and explicit specializations, bridged types, templates in std/absl/c9/rs_std, and templates with their own LIFETIME_PARAMS. Not yet handled (the written lifetime is still dropped): more than one template argument, arguments with more than one lifetime (`View<int**>`), member typedefs (`Holder<int* $a>::type`), and type aliases with a lifetime (`using V = View<int& $a>`, b/498977848). The IR gets a new field, `Record.has_template_argument_lifetime`. No golden files change. PiperOrigin-RevId: 994707871

Commit:de47383
Author:Googler
Committer:Copybara-Service

rs_bindings_from_cc: Preserve primitive typedefs such as size_t in template arguments Clang shares one `ClassTemplateSpecializationDecl` per canonical argument list, so the specialization decl for `std::optional<size_t>` stores the canonical argument `unsigned long` (or `unsigned long long`), losing the `size_t` typedef sugar that Crubit maps to `usize`. Record the as-written template argument on the use-site `CcType` in `Importer::WithAsWrittenTemplateArgs` whenever it contains a primitive typedef (such as `size_t` or `ptrdiff_t`), and prefer `template_args` in `BridgeType::StdOptional` as `UniformReprTemplateType::StdOptional` already does. PiperOrigin-RevId: 1001113924

Commit:ffb7105
Author:Googler
Committer:Copybara-Service

rs_bindings_from_cc: Bind string literal rows of `char` array constants Rows of plain `char` C-array constants which are initialized by a string literal (e.g. `constexpr char kNames[][8] = {"NOOP", "DROP"};`) are now bound using `::crubit_support::array::c_char_array_from_string_literal`, instead of element by element. PiperOrigin-RevId: 1000812456

Commit:744ebc6
Author:Googler
Committer:Copybara-Service

rs_bindings_from_cc: Bind string literal rows of `char` array constants Rows of plain `char` C-array constants which are initialized by a string literal (e.g. `constexpr char kNames[][8] = {"NOOP", "DROP"};`) are now bound using `::crubit_support::array::c_char_array_from_string_literal`, instead of element by element. PiperOrigin-RevId: 1000976039

Commit:a4d141c
Author:Ethan Smith
Committer:Copybara-Service

Automatic code cleanup. PiperOrigin-RevId: 1000951549

Commit:496b3b9
Author:Googler
Committer:Copybara-Service

Automatic code cleanup. PiperOrigin-RevId: 1000975019

Commit:c86e85f
Author:Ethan Smith
Committer:Copybara-Service

Automatic code cleanup. PiperOrigin-RevId: 1000935981

Commit:a0979e7
Author:Googler
Committer:Copybara-Service

Automatic code cleanup. PiperOrigin-RevId: 1000425891

Commit:28bbfa7
Author:Taylor Cramer
Committer:Copybara-Service

Automatic code cleanup. PiperOrigin-RevId: 1000934326

Commit:dfbc4d8
Author:Taylor Cramer
Committer:Copybara-Service

Automatic code cleanup. PiperOrigin-RevId: 1000764356

Commit:6938b4b
Author:Taylor Cramer
Committer:Copybara-Service

Automatic code cleanup. PiperOrigin-RevId: 1000660349

Commit:8400da0
Author:Taylor Cramer
Committer:Copybara-Service

Automatic code cleanup. PiperOrigin-RevId: 1000894394

Commit:0cde34d
Author:Taylor Cramer
Committer:Copybara-Service

Automatic code cleanup. PiperOrigin-RevId: 1000893047

Commit:fe642a4
Author:Taylor Cramer
Committer:Copybara-Service

Automatic code cleanup. PiperOrigin-RevId: 1000660345

Commit:2e1ea85
Author:Googler
Committer:Copybara-Service

Automatic code cleanup. PiperOrigin-RevId: 1000446993

Commit:657eccd
Author:Luke Zarko
Committer:Copybara-Service

Bind lifetimes written on class template arguments Until now, under assume_lifetimes a lifetime written on a class template argument, as in `View<int& $a>`, was silently dropped: the specialization had no lifetime parameter, so uses of it produced a Rust type that did not carry `'a`. Now, when a class template specialization has exactly one type argument and that argument carries exactly one lifetime in total (a non-function pointer or reference to a lifetime-free type, or a record with a single lifetime parameter; not e.g. `int*&` or `Obj&`), the specialization gets a lifetime parameter named after the template parameter (e.g. `'T`): * Uses such as `View<int& $a>` bind that parameter to `'a`. Unannotated uses such as `View<int&>` get the usual elision/defaults. * Inside the specialization, members spelled directly as the template parameter (`T value; T get();`) use `'T`. So do references to it that collapse into a reference argument (`const T&` with `T = int&`). * Writing lifetimes both on the argument and on the specialization itself (`View<int& $a> $b`) is an error; write them only on the argument. The specialization's constructors don't say how their inputs relate to `'T`, so the generator makes sure that the bindings can't leave it unconstrained: * A constructor that takes a lifetime-carrying parameter must take it as `T` (or `const T&`), or mark it `[[clang::lifetimebound]]`. Otherwise, e.g. for `explicit Box(int& other)`, the constructor gets no bindings: they would let safe Rust build a `Box<'static>` from a short-lived reference. * Unannotated uses of the specialization in parameters of its member and in-class friend functions (copy/move constructors, `operator=`, `swap`), and in references returned by them, get `'T`, rather than converting between or exchanging values of arbitrary lifetimes. A new `Record.has_template_argument_lifetime` IR bit marks these records. This only applies to specializations of primary templates, not to partial or explicit specializations, bridge types, std/absl templates, or templates that declare their own LIFETIME_PARAMS. It works with or without template_instantiation. Known limitations, left as TODOs: * Templates with more than one argument. * Templates with their own LIFETIME_PARAMS still drop the argument lifetime. * Member typedefs inside the specialization (and `Holder<int* $a>::type` from outside) get no lifetime. * A lifetime nested below the argument's outermost type (`W<W<int* $a>*>`) is not hoisted. * Unannotated uses of the specialization in functions declared outside it (e.g. a namespace-scope `swap(Box<int&>&, Box<int&>&)`) get independent lifetimes, as for other records with lifetime parameters; annotate them (`Box<int& $a>&`) to tie them together. No golden files change. PiperOrigin-RevId: 994707871

Commit:12250ec
Author:Googler
Committer:Copybara-Service

rs_bindings_from_cc: Bind string literal rows of `char` array constants Rows of plain `char` C-array constants which are initialized by a string literal (e.g. `constexpr char kNames[][8] = {"NOOP", "DROP"};`) are now bound using `::crubit_support::array::c_char_array_from_string_literal`, instead of element by element. PiperOrigin-RevId: 997934105

Commit:48e949b
Author:Googler
Committer:Copybara-Service

Support C array constants C arrays of booleans and integers (including `char`) with constant initializers, e.g. `constexpr int kPrimes[] = {2, 3, 5};`, are now bound as Rust array consts: `pub const kPrimes: [c_int; 3] = [2, 3, 5];`. This includes multidimensional arrays and static data members. IR: for arrays, `Constant.value` is an `ArrayValue` and `Constant.type` is the innermost element type. An `ArrayValue` has a length, and either integer elements (innermost dimension) or nested `ArrayValue` elements (outer dimensions). Only the explicitly initialized elements are recorded individually; the value of the remaining (value-initialized) elements is recorded once, as the filler. This keeps e.g. `int x[100000] = {};` small. Each dimension is generated as one of: - all elements explicitly initialized: an array expression, `[1, 2, 3]`; - none: a repeat expression of the filler, `[0; 4]`; - some: `::crubit_support::array::padded_array(&[7, 8], 0)` (added in https://github.com/google/crubit/commit/94d901b880684e13a3cb7a52c0440b6200f43c2c), which pads the explicit elements with the filler. `char` arrays initialized by string literals are bound element by element for now; unknown commit binds them using `c_char_array_from_string_literal` (also from https://github.com/google/crubit/commit/94d901b880684e13a3cb7a52c0440b6200f43c2c). Zero-length arrays, dimensions over INT32_MAX, non-integer elements, and arrays with more than 1024 explicitly initialized elements (to bound the size of the generated bindings) are reported as unsupported. PiperOrigin-RevId: 1000107647

Commit:de697ed
Author:Googler
Committer:Copybara-Service

Support C array constants C arrays of booleans and integers (including `char`) with constant initializers, e.g. `constexpr int kPrimes[] = {2, 3, 5};`, are now bound as Rust array consts: `pub const kPrimes: [c_int; 3] = [2, 3, 5];`. This includes multidimensional arrays and static data members. IR: for arrays, `Constant.value` is an `ArrayValue` and `Constant.type` is the innermost element type. An `ArrayValue` has a length, and either integer elements (innermost dimension) or nested `ArrayValue` elements (outer dimensions). Only the explicitly initialized elements are recorded individually; the value of the remaining (value-initialized) elements is recorded once, as the filler. This keeps e.g. `int x[100000] = {};` small. Each dimension is generated as one of: - all elements explicitly initialized: an array expression, `[1, 2, 3]`; - none: a repeat expression of the filler, `[0; 4]`; - some: `::crubit_support::array::padded_array(&[7, 8], 0)` (added in https://github.com/google/crubit/commit/94d901b880684e13a3cb7a52c0440b6200f43c2c), which pads the explicit elements with the filler. `char` arrays initialized by string literals are bound element by element for now; unknown commit binds them using `c_char_array_from_string_literal` (also from https://github.com/google/crubit/commit/94d901b880684e13a3cb7a52c0440b6200f43c2c). Zero-length arrays, dimensions over INT32_MAX, non-integer elements, and arrays with more than 1024 explicitly initialized elements (to bound the size of the generated bindings) are reported as unsupported. PiperOrigin-RevId: 993871573

Commit:aa23a46
Author:Rostyslav Toch CA
Committer:Copybara-Service

Add end-to-end integration tests for `absl::optional_ref<T>` Crubit bindings (3/3) Add end-to-end integration tests in `rs_bindings_from_cc/test/assume_lifetimes` verifying `absl::optional_ref<const T>` and `absl::optional_ref<T>` across parameters, return values, lifetime elision, and non-trivial `#[recursively_pinned]` C++ structs (`Option<Pin<&mut T>>`). PiperOrigin-RevId: 1000010857

Commit:8d0589b
Author:Rostyslav Toch CA
Committer:Copybara-Service

Generate Rust bindings for `absl::optional_ref<T>` as `Option<&'a T>` / `Option<&'a mut T>` (2/3) Lower `absl::optional_ref<const T>` and `absl::optional_ref<T>` in `rs_bindings_from_cc` to `Option<&'a T>` and `Option<&'a mut T>` respectively when lifetimes are present or assumed (`pragma clang lifetime_elision`), and fall back to `*const T` / `*mut T` when lifetimes are omitted. Since `Option<&T>`, `Option<&mut T>`, and `absl::optional_ref<T>` share the same ABI representation (a single nullable pointer), they pass directly across FFI with `UniformReprTemplateType`. PiperOrigin-RevId: 1000010855

Commit:d875db4
Author:Rostyslav Toch CA
Committer:Copybara-Service

Add Crubit IR support for `absl::optional_ref<T>` (1/3) Recognize `absl::optional_ref<T>` in the C++ record importer and plumb `TemplateSpecializationKind::AbslOptionalRef` through the Crubit IR proto and Rust IR representation, along with `ir_from_cc_test` coverage. PiperOrigin-RevId: 999397134

Commit:506c0e2
Author:Googler
Committer:Copybara-Service

Infer Send and Sync for C++ records under the infer_send_sync feature. In Rust, a type is `Send`/`Sync` if all of its fields are. With the `infer_send_sync` Crubit feature, rs_bindings_from_cc now follows the same rule: records without an explicit annotation no longer get `impl !Send` / `impl !Sync`, so rustc infers the traits from the fields. Opaque byte blobs hide the real C++ type from rustc, and `[MaybeUninit<u8>; N]` would otherwise be inferred as `Send + Sync`. So under this feature, blobs which hold C++ data are followed by a `PhantomData<*mut ()>` marker, making them neither `Send` nor `Sync`: * Fields erased to opaque bytes (non-public fields, unsupported types, ...). * `__non_field_data` holding base class subobjects or a vptr (but not the single byte of an empty class). Alignment padding and bitfields are not marked, as they hold no data or only integers. Explicit annotations always win: * `CRUBIT_UNSAFE_IMPL("Send")` / `CRUBIT_THREAD_SAFE`: `unsafe impl Send`. * `CRUBIT_TRAIT_DERIVE("!Send")` / `CRUBIT_TRAIT_DERIVE("!Sync")`: newly allowed as an explicit opt-out, producing `impl !Send` / `impl !Sync`. This is accepted regardless of the feature (without it, it restates the default). Explicitly annotated `Send`/`Sync` (positive or negative) are also checked with `static_assertions`, alongside the existing `Copy`/`Clone`/`Drop` assertions. To represent the opt-out, the `TraitDerives` proto's `bool send` / `bool sync` are replaced by `TraitImplPolarity send_polarity` / `sync_polarity` (the old names and numbers are reserved). For template instantiations, the feature is read from the target which defines the template, since Send/Sync are a property of the C++ type. Without the feature, generated bindings are unchanged. PiperOrigin-RevId: 998269745

Commit:42cf8f4
Author:Googler
Committer:Copybara-Service

Support c-array constants PiperOrigin-RevId: 993871573

Commit:5eceb49
Author:Googler
Committer:Copybara-Service

Honor `ABSL_POINTERS_DEFAULT_NONNULL` in rs_bindings_from_cc. Registers the nullability `#pragma nullability file_default` handler and uses the recorded file defaults when a pointer type has no explicit nullability annotation. The governing file is the file containing the decl being imported, or, for types spelled via a typedef, the file containing the innermost typedef. This mirrors `getGoverningFile` in the nullability library. A `nonnull` file default is treated just like an explicit `_Nonnull`: it sets `CcType::is_nonnull`, and `PointerTypeKind::NON_NULL` for raw pointers. Codegen still only acts on it for smart pointers in targets with the `nonnull_smart_pointers` feature. Substituted template arguments (e.g. `std::vector<std::unique_ptr<T>>`) are not yet handled. PiperOrigin-RevId: 991887464

Commit:67af6e6
Author:Googler
Committer:Copybara-Service

Carry nullability on template arguments into the Rust bindings. `std::vector<absl_nonnull std::unique_ptr<T>>` now becomes `cc_std::std::vector<cc_std::std::NonNull<cc_std::std::unique_ptr<T>>>` (under the `nonnull_smart_pointers` feature), and the same holds for bridged types, e.g. `absl::StatusOr<absl_nonnull std::unique_ptr<T>>`. The specialization decl is shared by every use with the same canonical arguments, so it cannot carry per-use information like nullability. The importer already recorded the as-written template argument on the use site's `CcType`, but only if it carried an explicit lifetime. It now records it regardless: * The single-argument restriction stays: consumers of `template_args` still assume one argument. Defaulted arguments are not written, so e.g. `std::vector<T>` still has one. * Nothing is recorded if the argument fails to convert (except that an argument carrying an explicit lifetime still reports its error, as before). * The bridge arity check now falls back to the canonical argument per position, since one written argument can be shorter than the bridge's canonical argument list. `std::shared_ptr` now uses `choose_one_type` like the other smart pointers. * When looking through a system-header typedef, the typedef's file now governs the nullability default of the types inside it. As-written arguments keep typedef sugar, so `std::atomic` now looks through aliases when choosing the Rust atomic type. PiperOrigin-RevId: 991090487

Commit:869fcf7
Author:Googler
Committer:Copybara-Service

Honor ABSL_POINTERS_DEFAULT_NONNULL in rs_bindings_from_cc. Registers the nullability `#pragma nullability file_default` handler and uses the recorded file defaults when a pointer type has no explicit nullability annotation. The governing file is the file containing the decl being imported, or, for types spelled via a typedef, the file containing the innermost typedef. This mirrors `getGoverningFile` in the nullability library. A `nonnull` file default is treated just like an explicit `_Nonnull`: it sets `CcType::is_nonnull`, and `PointerTypeKind::NON_NULL` for raw pointers. Codegen still only acts on it for smart pointers in targets with the `nonnull_smart_pointers` feature. Substituted template arguments (e.g. `std::vector<std::unique_ptr<T>>`) are not yet handled. PiperOrigin-RevId: 988296364

Commit:1a1e200
Author:Luke Zarko
Committer:Copybara-Service

Record as-written template arguments that carry lifetimes Clang creates one `ClassTemplateSpecializationDecl` per *canonical* template argument list, so `W<int* $a>` and `W<int* $b>` denote the same record, and the importer produced byte-identical IR for the two. The sugar that carries the lifetime survives only on the use-site `TemplateSpecializationType`, and `Importer::ConvertTemplateSpecializationType` never consulted `type.template_arguments()`: both of its exits went straight to `ConvertTypeDecl`, which returns a bare `ItemId`. Record the as-written arguments on the `CcType` for that one use, in the `template_args` slot that `CcTypeVariant::Decl` already has and that `lifetime_defaults_transform` already populates from the Rust side. Like `is_const`, this describes one use of the type rather than the type itself. `lifetime_defaults_transform` used to overwrite `template_args` with the element type of the shared specialization decl, discarding the lifetime for exactly the types that consume `template_args` (`std::vector`, `std::unique_ptr`, `absl::Span`, `c9::Co`). It now starts from the as-written argument when the importer recorded one, and falls back to the decl's argument otherwise. PiperOrigin-RevId: 990615094

Commit:4412bfd
Author:Googler
Committer:Copybara-Service

Record `_Nonnull` on raw pointers in the rs_bindings_from_cc IR. A raw pointer annotated `_Nonnull` (e.g. via `absl_nonnull`) now gets `PointerTypeKind::NON_NULL` instead of `NULLABLE`. No change to generated bindings: both kinds still map to a Rust raw pointer. This only makes the information available to codegen. PiperOrigin-RevId: 990532093

Commit:92f4b1a
Author:Ethan Smith
Committer:Copybara-Service

Prepare `rs_bindings_from_cc` for round-tripping Rust stdlib types (`core`/`alloc`/`std`). When C++ code embeds or passes by value C++ bindings of Rust standard library types (such as `rs::std::string::String`, `rs::std::path::PathBuf`, or `rs::std::fs::File`), `rs_bindings_from_cc` needs several fixes before the Bazel rules mark `rs_core`/`rs_alloc`/`rs_std` headers as having bindings: 1. Conditionally emit `extern crate alloc;` in the generated `_rust_api.rs` when the target depends on `//third_party/crubit/support/rs_std:rs_alloc` (directly or transitively via `:rs_std`), since `rustc` does not place `alloc` into the extern prelude automatically. 2. Record `is_trivially_copyable` on `ExistingRustType` in the IR so that `RsTypeKind::implements_copy()` returns `false` for non-`Copy` Rust types (wrapping struct fields in `ManuallyDrop<T>` and avoiding invalid `T: Copy` static assertions). 3. Relocate non-trivially-copyable `ExistingRustType` by-value function parameters via `ManuallyDrop` on the Rust side and `crubit::Slot<T>::AssumeInitAndTakeValue()` in the C++ thunk so types without `Default` (e.g. `std::fs::File`, where `File(File&&) = delete` in C++) can be passed by value using their `UnsafeRelocateTag` constructor. 4. Set `policy.FullyQualifiedName = true` in `ExistingRustTypeImporter` so `using` aliases inside namespaces (such as `rs::std::string::String`) retain their enclosing namespace qualification in generated C++ thunks. PiperOrigin-RevId: 987707583

Commit:de96f99
Author:Luke Zarko
Committer:Copybara-Service

Record as-written template arguments that carry lifetimes Clang creates one `ClassTemplateSpecializationDecl` per *canonical* template argument list, so `W<int* $a>` and `W<int* $b>` denote the same record, and the importer produced byte-identical IR for the two. The sugar that carries the lifetime survives only on the use-site `TemplateSpecializationType`, and `Importer::ConvertTemplateSpecializationType` never consulted `type.template_arguments()`: both of its exits went straight to `ConvertTypeDecl`, which returns a bare `ItemId`. Record the as-written arguments on the `CcType` for that one use, in the `template_args` slot that `CcTypeVariant::Decl` already has and that `lifetime_defaults_transform` already populates from the Rust side. Like `is_const`, this describes one use of the type rather than the type itself. PiperOrigin-RevId: 987065061

Commit:49fce82
Author:Lukasz Anforowicz
Committer:Copybara-Service

Rename `is_trivial_abi` to `is_rust_movable` in the IR. The field says whether Rust may move a value with `memcpy`, without running the C++ destructor on the old location. The old name pointed at `[[clang::trivial_abi]]` and at the ABI. The attribute is related, but it is only one of the ways a record gets this property, and the property itself says nothing about how a value is passed to or returned from a function. This CL only renames the field and adjusts the related names and comments. There is no behavior change: * `Record::is_unpin` no longer claims that this property is called "trivially relocatable" in C++. No published C++ standard defines that term, and the competing proposals disagree on what it should mean. * The `ir.proto` rename TODO is now done, so it is removed. * The `IsRustMovable` matcher comment in `importer_test.cc` said "trivial for calls", which describes an ABI property rather than this one. PiperOrigin-RevId: 986990737

Commit:64d4e9a
Author:Lukasz Anforowicz
Committer:Copybara-Service

No public description PiperOrigin-RevId: 985651355

Commit:8c93a57
Author:Lukasz Anforowicz
Committer:Copybara-Service

Make `is_trivial_abi` independent of the target's C++ ABI. Crubit clients such as Chromium build the same Rust code for several target platforms, so the shape of the generated bindings should not depend on the target. `is_trivial_abi` controls the shape of some generated bindings - e.g. whether a C++ record is passed as `&mut T` rather than `Pin<&mut T>`. The "Unpin for C++ Types" design doc defines the underlying property as being "trivial for calls" in Clang: either actually trivial, or made trivial for calls with `[[clang::trivial_abi]]`. Before this CL, the importer did not ask that question - instead it asked `clang::CXXRecordDecl::canPassInRegisters()`, which is only a proxy for the desired property. In particular `canPassInRegisters` is exact on the Itanium C++ ABI, but not on the Microsoft C++ ABI (see [`canPassInRegisters` in `clang/lib/Sema/SemaDeclCXX.cpp`](https://github.com/llvm/llvm-project/blob/5dfe8605911e3f0f43fe2b5c08b4ffc23f2af37a/clang/lib/Sema/SemaDeclCXX.cpp#L6982)): * A small class with a trivial copy constructor can be passed in registers even when it has a non-trivial destructor, so `struct S { ~S() {} };` was `Unpin` only when targeting Windows. * The move constructor is ignored, so a class with a trivial copy constructor and a user-provided move constructor was `Unpin` only when targeting Windows. * A non-deleted copy constructor is required, so a move-only class with a trivial move constructor was `Unpin` only when targeting Linux. After this CL, the desired property is calculated more directly, in a new `IsRustMovable` helper function. The helper mirrors the Itanium C++ ABI branch of `canPassInRegisters`, so the result no longer depends on the target's C++ ABI, and it is unchanged on every currently supported target platform. One source of target dependence remains: Clang drops `[[clang::trivial_abi]]` when a base class or a field cannot be passed in registers on the target ABI. See b/564616479 and the `TrivialAbiWithMoveOnlyField` test case. PiperOrigin-RevId: 981314297

Commit:a9963f9
Author:Googler
Committer:Copybara-Service

Add layout-compatible std::optional<T> bindings. Today, user's rely on `std::optional<T>` bridging to `Option<T>` in Rust, and do not rely on it directly in non-bridge positions because Crubit makes those a blob of bytes. This change does two things: 1. Unconditionally turns those blobs of bytes into either `optional<T>` or `trivial_optional<T>`, depending on `Copy` requirements. This is a purely additive change and cannot realistically break anyone. 2. Add a flag to conditionally disable composable bridging `std::optional<T>` and instead use this new layout compatible `optional<T>`/`trivial_optional<T>` instead. This is a breaking change, and therefore is behind a flag to users can opt in when they're ready. PiperOrigin-RevId: 983911647

Commit:7a56534
Author:Googler
Committer:Copybara-Service

Add layout-compatible std::optional<T> bindings. Today, user's rely on `std::optional<T>` bridging to `Option<T>` in Rust, and do not rely on it directly in non-bridge positions because Crubit makes those a blob of bytes. This change does two things: 1. Unconditionally turns those blobs of bytes into either `optional<T>` or `trivial_optional<T>`, depending on `Copy` requirements. This is a purely additive change and cannot realistically break anyone. 2. Add a flag to conditionally disable composable bridging `std::optional<T>` and instead use this new layout compatible `optional<T>`/`trivial_optional<T>` instead. This is a breaking change, and therefore is behind a flag to users can opt in when they're ready. PiperOrigin-RevId: 981299096

Commit:47d5cba
Author:Krasimir Georgiev
Committer:Copybara-Service

Add label hint support and auto-inference for CRUBIT_INTERNAL_RUST_TYPE PiperOrigin-RevId: 983136933

Commit:61f3fe9
Author:Krasimir Georgiev
Committer:Copybara-Service

Add label hint support and auto-inference for CRUBIT_INTERNAL_RUST_TYPE PiperOrigin-RevId: 981709954

Commit:6f3eefc
Author:Krasimir Georgiev
Committer:Copybara-Service

Add label hint support and auto-inference for CRUBIT_INTERNAL_RUST_TYPE PiperOrigin-RevId: 981709954

Commit:ce4770b
Author:Googler
Committer:Copybara-Service

Add opt-in layout-compatible `std::optional<T>` bindings. `std::optional<T>` is bridged by value to a Rust `Option<T>`, so it cannot be used anywhere that requires a layout-compatible type: struct fields, pointees, or as a template argument to another vocabulary type. `std::optional<T>` is in fact layout-compatible (libc++ and libstdc++ both store the payload inline followed by an engaged flag), so bridging is not required, only convenient. Add a `layout_compat_optional` feature, mirroring `layout_compat_string`. A target which enables it gets a layout-compatible Rust type everywhere instead of the bridged `Option<T>`, and so can use `std::optional<T>` in all of the positions listed above. The default remains bridging, so existing callers are unaffected and can migrate incrementally. `std::optional<T>` is now imported both as a `BridgeType::StdOptional` and as a `TemplateSpecialization::StdOptional`; the generator selects between them based on the feature. The layout-compatible path reuses the existing `UniformReprTemplateType` machinery that backs `std::vector<T>` and `std::shared_ptr<T>`. The Rust type stores `T` inline, so element types which are not `Unpin` are rejected for now with a dedicated error. Storing `T` inline requires a `MaybeUninit` payload and therefore a manual `Drop` impl, and Rust forbids implementing both `Copy` and `Drop`. A single type would consequently never be `Copy`, not even for `std::optional<int>`, which is trivially copyable in C++. Ship two types instead, following the existing `unique_ptr` / `virtual_unique_ptr` precedent of two Rust types for one C++ type: * `cc_std::std::trivial_optional<T>`, for `Copy` `T`. This has no destructor and is itself `Copy`. * `cc_std::std::optional<T>`, for everything else. This has a `Drop` impl which destroys the engaged value, and is `Clone` but not `Copy`. Both are layout-compatible with `std::optional<T>` and expose the same API, and Crubit selects between them based on the element type. A record containing a `std::optional<T>` field therefore keeps deriving `Copy` exactly when the corresponding C++ type is trivially copyable. PiperOrigin-RevId: 981299096

Commit:c180c36
Author:Googler
Committer:Copybara-Service

rs_bindings_from_cc: Honor _Nonnull annotations on unique_ptr and shared_ptr A C++ API that declares `_Nonnull std::unique_ptr<T>` is promising its callers something that Rust can express in the type system, but Crubit was discarding it: the generated signature was the same `unique_ptr<T>` you get for an unannotated parameter, so Rust callers had to check for null anyway. Annotated smart pointers now generate `NonNull<unique_ptr<T>>` (or `NonNull<virtual_unique_ptr<T>>` / `NonNull<shared_ptr<T>>`), which derefs straight through to `T`. How it works: * `Importer::ConvertType` reads `Type::getNullability()` and records it on `CcType` as `is_nonnull`. Nullability describes one *use* of a type like a cv qualifier, rather than the declaration being referred to, so it belongs on `CcType` and not on the record that carries the `unique_ptr`-ness. It has to be read in `ConvertType` specifically: nullability is sugar, and `ConvertUnattributedType` looks through the `AttributedType` that carries it. * `rs_type_kind` then wraps the two smart-pointer `UniformReprTemplateType`s when the bit is set. `NonNull` is `#[repr(transparent)]`, so this needs no layout, ABI, or thunk changes. The bit is recorded for every type that can carry the annotation, but only smart pointers act on it. `_Nonnull` on raw pointers, `std::function`, and the other class types Clang accepts it on stays ignored, which is today's behavior. Rollout is behind a new `nonnull_smart_pointers` feature, off by default and excluded from the `all` feature set. `absl_nonnull std::unique_ptr<...>` is already widespread, so honoring it unconditionally would change the generated signature of many existing targets at once, and callers could start depending on the new signatures before anyone noticed. Opting in per target keeps the blast radius at zero. Followup work is required to make cc_bindings_from_rs map `cpp_std::NonNull<Ptr>` types back into `_Nonnull` in C++. PiperOrigin-RevId: 981243342

Commit:6531805
Author:Taylor Cramer
Committer:Copybara-Service

Add `CRUBIT_PUB_CRATE` annotation to restrict C++ function and method bindings to `pub(crate)` visibility in Rust. This allows C++ helper functions and internal methods to be called from custom Rust source files (`srcs`) in `rust_api_from_cpp` without exposing them in the public Rust API. PiperOrigin-RevId: 978185571

Commit:a8f5427
Author:Taylor Cramer
Committer:Copybara-Service

Support Rust Protobuf message fields, references, and pointers in cc_bindings_from_rs. - Add proto::Rust<T> (proto2::Rust<T>) in support/protobuf/rust.h as a non-nullable, movable C++ smart pointer layout-compatible with Rust-owned Protobuf message handles. - Support Protobuf message fields in structs via proto::Rust<CppProto>. - Support Protobuf message references (&Proto), raw pointers (*const Proto), and generic containers (Vec<T>, NewStatusOr<T>) in layout-compatible positions. PiperOrigin-RevId: 974760036

Commit:1951c9c
Author:Taylor Cramer
Committer:Copybara-Service

Reorganize unique_ptr API to encourage Box conversion PiperOrigin-RevId: 936971083

Commit:e8dad91
Author:Ethan Smith
Committer:Copybara-Service

Internal change. PiperOrigin-RevId: 975298756

Commit:01959c9
Author:Ethan Smith
Committer:Copybara-Service

Enable portable_abi_compatible for crubit. PiperOrigin-RevId: 971934605

Commit:6df4b8e
Author:Googler
Committer:Copybara-Service

Internal-only change. PiperOrigin-RevId: 974979014

Commit:9a954a4
Author:Luke Zarko
Committer:Copybara-Service

Fixes for template instantiation. This change, without loss of generality wrt *Mut variants: - Stops trying to generate std::ops::Index implementations for CRef returns (which is impossible) and CcIndex returns (which we may want to revisit) - Fixes a problem with !Unpin types and thunks for CcIndexMut - Does not generate CcIndex implementations when the return type would have an unbound lifetime. PiperOrigin-RevId: 970913058

Commit:76acd84
Author:Ethan Smith
Committer:Copybara-Service

Add user defined generics case to TemplateSpecializations. PiperOrigin-RevId: 974768423

Commit:5240462
Author:Taylor Cramer
Committer:Copybara-Service

Make proto::Rust<T> non-movable in C++ to preserve non-null invariant. - Delete move constructor and move assignment from proto::Rust<T> (proto2::Rust<T>) in support/protobuf/rust.h. - Remove NewStatusOr<Proto> from cc_bindings_from_rs protobuf test since non-movable types cannot be returned by value from C++ wrapper functions. PiperOrigin-RevId: 974770314

Commit:0bcc8ba
Author:Ethan Smith
Committer:Copybara-Service

Create single crate crubit_support that holds all our Rust support libs. In OSS it's easy to forget to include rust support libraries because they each have to be manually published to crates.io and threaded through cargo-cpp_api_from_rust. To ease this create one unified crate that we can upload and depend on. Now whenever we want to add a support lib we only have to re-upload the crate without any of the threading. This also fixes an incidental issue with uploading crates by moving the Cargo.toml to be adjacent with the Rust source code. PiperOrigin-RevId: 973886171

Commit:5de5924
Author:Ethan Smith
Committer:Copybara-Service

Emit self-referential constants as functions. Rust inherent constants that reference their Self type were emitted as C++ static constexpr's that also referenced their self type. This causes a compilation error because a C++ class type is not available when a static constexpr is evaluated, causing errors around incomplete types. We break this by emitting self-referential constants as constexpr functions. This allows for keeping them as constexpr (vs supressing the bindings or making them static consts). PiperOrigin-RevId: 974142978

Commit:4828566
Author:Taylor Cramer
Committer:Copybara-Service

Support Rust Protobuf message fields, references, and pointers in cc_bindings_from_rs. - Add proto::Rust<T> (proto2::Rust<T>) in support/protobuf/rust.h as a non-nullable, movable C++ smart pointer layout-compatible with Rust-owned Protobuf message handles. - Support Protobuf message fields in structs via proto::Rust<CppProto>. - Support Protobuf message references (&Proto), raw pointers (*const Proto), and generic containers (Vec<T>, NewStatusOr<T>) in layout-compatible positions. PiperOrigin-RevId: 972734189

Commit:07ae0b1
Author:Lukasz Anforowicz
Committer:Copybara-Service

Represent item ids as an **unsigned** integer. This avoids the following ClangTidy warnings: > implicit conversion changes signedness: 'ValueType' (aka 'unsigned long') to > '::int64_t' (aka 'long') Which otherwise would be reported in a handful of places like: https://github.com/google/crubit/blob/ff8c61cc3c6a4bc0a0bba754e6e94a5ed57d1806/rs_bindings_from_cc/importers/enum.cc#L180 PiperOrigin-RevId: 967998911

Commit:a450640
Author:Googler
Committer:Copybara-Service

Remove `has_c_calling_convention` field from `Func` in `rs_bindings_from_cc/ir.proto` and add helper function that checks `call_conv`. PiperOrigin-RevId: 966697157

Commit:e8fe564
Author:Googler
Committer:Copybara-Service

Support non-standard calling conventions for function signature checks - Move `ConvertCcCallConvToSupportedCallingConv` from `rs_bindings_from_cc/importer.cc` to `rs_bindings_from_cc/ast_util.h` and `rs_bindings_from_cc/ast_util.cc` - Add `CallingConv call_conv` field to `Func` in `rs_bindings_from_cc/ir.proto` - For supported non-standard calling conventions add flag to assertion in `rs_bindings_from_cc/generate_bindings/generate_function_thunk.rs` - Add case for `clang::vectorcall` and `win64` in `rs_bindings_from_cc/test/golden/nonstandard_calling_convention*` PiperOrigin-RevId: 966033485

Commit:bcd5508
Author:Googler
Committer:Copybara-Service

Support non-standard calling conventions for function signature checks - Move `ConvertCcCallConvToSupportedCallingConv` from `rs_bindings_from_cc/importer.cc` to `rs_bindings_from_cc/ast_util.h` and `rs_bindings_from_cc/ast_util.cc` - Add `CallingConv call_conv` field to `Func` in `rs_bindings_from_cc/ir.proto` - For supported non-standard calling conventions add flag to assertion in `rs_bindings_from_cc/generate_bindings/generate_function_thunk.rs` - Add case for `clang::vectorcall` and `win64` in `rs_bindings_from_cc/test/golden/nonstandard_calling_convention*` PiperOrigin-RevId: 965593089