Owen Avery c8461400fd gccrs: Improve libformat_parser FFI
This should remove a use-after-free as well as simplify the FFI
interface.

gcc/rust/ChangeLog:

	* ast/rust-fmt.cc (Pieces::collect): Handle changes to ffi
	interface.
	(Pieces::~Pieces): Remove function definition.
	(Pieces::Pieces): Likewise.
	(Pieces::operator=): Likewise.
	* ast/rust-fmt.h: Include "optional.h".
	(rust_ffi_alloc): New extern "C" function declaration.
	(rust_ffi_dealloc): Likewise.
	(class FFIVec): New class.
	(class FFIOpt): Likewise.
	(RustHamster::RustHamster): New constructor accepting const
	std::string reference.
	(struct FormatSpec): Use FFIOpt.
	(struct PieceSlice): Remove struct.
	(struct RustString): Likewise.
	(struct FormatArgsHandle): Likewise.
	(collect_pieces): Change function signature.
	(clone_pieces): Likewise.
	(destroy_pieces): Remove extern "C" function declaration.
	(Pieces::~Pieces): Remove function declaration.
	(Pieces::operator=): Likewise.
	(Pieces::get_pieces): Handle changes to class fields.
	(Pieces::Pieces): Remove copy and move constructor declarations,
	adjust signature of remaining constructor declaration.
	(Pieces::pieces_vector): Remove member variable.
	(Pieces::handle): Likewise.
	(Pieces::data): Add member variable.
	* expand/rust-macro-builtins-asm.cc (expand_inline_asm_strings):
	Use references to avoid copying.

libgrust/ChangeLog:

	* libformat_parser/src/lib.rs (struct FFIVec): New.
	(trait StringLeakExt): Remove.
	(struct FFIOpt): New.
	(trait IntoFFI): Adjust implementation for Option.
	(struct RustHamster): Add lifetime and adjust conversion to and
	from &str.
	(enum Piece): Adjust definition to handle changes to
	RustHamster.
	(struct Argument): Likewise.
	(struct FormatSpec): Use FFIOpt and RustHamster.
	(enum Position): Use RustHamster.
	(enum Count): Likewise.
	(struct PieceSlice): Replace with...
	(typedef PieceVec): ...this.
	(struct RustString): Remove.
	(struct FormatArgsHandle): Likewise.
	(fn collect_pieces): Adjust signature, greatly simplifying
	implementation.
	(fn clone_pieces): Likewise.
	(fn destroy_pieces): Remove.
	(trait LayoutExt): New.
	(fn rust_ffi_alloc): New.
	(fn rust_ffi_dealloc): New.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-10-30 20:58:41 +01:00
2025-06-03 00:18:06 +00:00
2025-10-05 16:50:51 +00:00
2025-10-17 00:18:48 +00:00
2025-08-29 00:19:55 +00:00
2025-10-30 20:58:41 +01:00
2025-06-23 00:16:33 +00:00
2025-10-17 00:18:48 +00:00
2025-10-10 00:21:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-10 00:21:51 +00:00
2025-10-14 00:20:06 +00:00
2025-10-05 16:50:51 +00:00
2025-10-26 00:17:33 +00:00
2025-10-29 00:19:49 +00:00
2025-10-05 16:50:51 +00:00
2025-10-25 00:18:16 +00:00
2025-10-29 00:19:49 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-09-02 00:19:26 +00:00
2025-10-05 16:50:51 +00:00
2025-10-29 00:19:49 +00:00
2025-10-11 11:08:01 +02:00
2025-10-11 11:08:01 +02:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 1.5 GiB
Languages
C++ 30.7%
C 30%
Ada 14.5%
D 6.1%
Go 5.7%
Other 12.5%