]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
4 months agogccrs: expand: Keep track of semicoloned builtin macros
Arthur Cohen [Fri, 14 Jun 2024 14:45:34 +0000 (16:45 +0200)] 
gccrs: expand: Keep track of semicoloned builtin macros

This is quite a rough fix (like a lot of the macro expansion code...) but
it allows built-in macros to be treated as statements. I *think* asm!()
might be the only one where it really matters, but also doing something
like

{
    line!();
}

will now work, whereas before the macro invocation would not get expanded
properly and would be ignored.

gcc/rust/ChangeLog:

* ast/rust-ast-fragment.h: Pass `is_semicolon` information to builtin
macro transcribers.
* ast/rust-macro.h: Pass semicolon information to transcriber..
* expand/rust-macro-builtins-asm.cc (MacroBuiltin::asm_handler): Likewise.
(parse_asm): Likewise.
* expand/rust-macro-builtins-asm.h (parse_asm): Likewise.
* expand/rust-macro-builtins-format-args.cc (MacroBuiltin::format_args_handler): Likewise.
* expand/rust-macro-builtins-include.cc (MacroBuiltin::include_bytes_handler): Likewise.
(MacroBuiltin::include_str_handler): Likewise.
(MacroBuiltin::include_handler): Likewise.
* expand/rust-macro-builtins-location.cc (MacroBuiltin::file_handler): Likewise.
(MacroBuiltin::column_handler): Likewise.
(MacroBuiltin::line_handler): Likewise.
* expand/rust-macro-builtins-log-debug.cc (MacroBuiltin::assert_handler): Likewise.
* expand/rust-macro-builtins-utility.cc (MacroBuiltin::compile_error_handler): Likewise.
(MacroBuiltin::concat_handler): Likewise.
(MacroBuiltin::env_handler): Likewise.
(MacroBuiltin::cfg_handler): Likewise.
(MacroBuiltin::stringify_handler): Likewise.
* expand/rust-macro-builtins.cc (format_args_maker): Likewise.
(inline_asm_maker): Likewise.
(MacroBuiltin::sorry): Likewise.
(MacroBuiltin::proc_macro_builtin): Likewise.
* expand/rust-macro-builtins.h: Likewise.
* expand/rust-macro-expand.cc (MacroExpander::expand_decl_macro): Likewise.
(MacroExpander::expand_invoc): Likewise.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Remove rust_unreachable.
* ast/rust-ast.cc (InlineAsm::accept_vis): Likewise.
* hir/tree/rust-hir.cc (InlineAsm::accept_vis): Likewise.

4 months agogccrs: Fix optional trait parsing
dave [Wed, 15 Nov 2023 18:28:27 +0000 (12:28 -0600)] 
gccrs: Fix optional trait parsing

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Check for ?Trait in visitor

gcc/testsuite/ChangeLog:

* rust/compile/issue-2725.rs: New test.

Signed-off-by: Dave Evans <dave@dmetwo.org>
4 months agogccrs: Partial second layer of expected in parsing asm
jjasmine [Wed, 12 Jun 2024 06:25:50 +0000 (23:25 -0700)] 
gccrs: Partial second layer of expected in parsing asm

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parseDirSpec):
Partial second layer of expected in parsing asm
(parse_clobber_abi): Likewise
(parse_operand): Likewise
(parse_reg_operand): Likewise
(parse_asm_arg): Likewise
* expand/rust-macro-builtins-asm.h (parse_clobber_abi): Likewise
(parse_reg_operand): Likewise
(parse_operand): Likewise

4 months agogccrs: Expected first layer done
jjasmine [Wed, 12 Jun 2024 05:07:14 +0000 (22:07 -0700)] 
gccrs: Expected first layer done

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg):
Expected first layer done
(parse_reg_operand): Likewise.
(parse_asm_arg): Likewise.
(parse_format_strings): Likewise.
(parse_asm): Likewise.
(validate): Likewise.
* expand/rust-macro-builtins-asm.h (parse_asm_arg): Likewise.
(validate): Likewise.
(parse_format_strings): Likewise.

4 months agogccrs: Move parser and last_token_id to InlineAsmCtx
jjasmine [Wed, 12 Jun 2024 00:56:20 +0000 (17:56 -0700)] 
gccrs: Move parser and last_token_id to InlineAsmCtx

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_clobber_abi):
Move parser and last_token_id to InlineAsmCtx to prepapre
for tl::expected.
(parse_reg): Likewise.
(parse_operand): Likewise.
(parse_reg_operand): Likewise.
(check_and_set): Likewise.
(parse_options): Likewise.
(parse_format_string): Likewise.
(parse_asm_arg): Likewise.
(parse_asm): Likewise.
* expand/rust-macro-builtins-asm.h (class InlineAsmParseError): Likewise.
(parse_asm_arg): Likewise.
(check_and_set): Likewise.
(parse_operand): Likewise.
(parse_reg_operand): Likewise.
(parse_options): Likewise.
(parse_reg): Likewise.
(parse_clobber_abi): Likewise.
(parse_format_string): Likewise.

4 months agogccrs: Update parser to parse strings in the first stage
jjasmine [Tue, 11 Jun 2024 23:57:48 +0000 (16:57 -0700)] 
gccrs: Update parser to parse strings in the first stage

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
Update parser to parse strings in the first stage
(parse_label): not needed right now

4 months agogccrs: Scaffolding validation of asm!
jjasmine [Tue, 11 Jun 2024 01:08:42 +0000 (18:08 -0700)] 
gccrs: Scaffolding validation of asm!

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_asm):
Scaffolding validation of asm!
(validate): Likewise
* expand/rust-macro-builtins-asm.h (validate): Likewise

4 months agogccrs: Partial support for operand
jjasmine [Mon, 10 Jun 2024 23:54:34 +0000 (16:54 -0700)] 
gccrs: Partial support for operand

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct InlineAsmOperand):
Partial support for operand
* expand/rust-macro-builtins-asm.cc (parse_reg_operand): Likewise.
(parse_label): Likewise.
* expand/rust-macro-builtins-asm.h (parse_label): Likewise.

4 months agogccrs: Refactoring and supporting more parse_reg_operand
jjasmine [Mon, 10 Jun 2024 21:04:11 +0000 (14:04 -0700)] 
gccrs: Refactoring and supporting more parse_reg_operand

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct InlineAsmOperand):
Refactoring and supporting more parse_reg_operand
* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
Likewise.
(rust_debug): Likewise.

4 months agogccrs: Fix visitor-related warnings
jjasmine [Thu, 6 Jun 2024 01:12:49 +0000 (18:12 -0700)] 
gccrs: Fix visitor-related warnings

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit):
Fix visitor-related warnings
* ast/rust-ast-collector.h: Likewise.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise.
* ast/rust-ast-visitor.h: Likewise.
* checks/errors/borrowck/rust-bir-builder-struct.h: Likewise.
* checks/errors/borrowck/rust-function-collector.h: Likewise.
* checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise.
* checks/errors/rust-const-checker.h: Likewise.
* expand/rust-derive.h: Likewise.
* expand/rust-macro-builtins-asm.cc (parse_reg_operand): Likewise.
* hir/rust-hir-dump.cc (Dump::visit): Likewise.
* hir/rust-hir-dump.h: Likewise.
* hir/tree/rust-hir-visitor.h: Likewise.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise.
* resolve/rust-ast-resolve-base.h: Likewise.

4 months agogccrs: Add potentially_nonpromoted_keywords set str
jjasmine [Wed, 5 Jun 2024 15:24:50 +0000 (08:24 -0700)] 
gccrs: Add potentially_nonpromoted_keywords set str

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
Add potentially_nonpromoted_keywords set str
(check_identifier): likewise
* expand/rust-macro-builtins-asm.h (parse_format_string):
likewise

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_parse_operand.rs: fix warnings

4 months agogccrs: Successful parse of in and inout, albeit with str
jjasmine [Wed, 5 Jun 2024 06:14:19 +0000 (23:14 -0700)] 
gccrs: Successful parse of in and inout, albeit with str

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
Successful parse of in and inout, albeit with str
(check_identifier): Likewise.
(parse_asm_arg): Likewise.
* expand/rust-macro-builtins-asm.h (parse_format_string): Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_parse_operand.rs: New test.

4 months agogccrs: Scaffolding HIRFullVisitor for inline asm
jjasmine [Wed, 5 Jun 2024 03:17:23 +0000 (20:17 -0700)] 
gccrs: Scaffolding HIRFullVisitor for inline asm

gcc/rust/ChangeLog:

* ast/rust-ast-visitor.h:
Scaffolding HIRFullVisitor for inline asm
* ast/rust-ast.cc (InlineAsm::accept_vis): Likewise.
* hir/tree/rust-hir-visitor.h (RUST_HIR_VISITOR_H): Likewise.
* hir/tree/rust-hir.cc (InlineAsm::accept_vis): Likewise.

4 months agogccrs: Scaffolding ast visitor for InlineAsm
jjasmine [Wed, 5 Jun 2024 02:34:58 +0000 (19:34 -0700)] 
gccrs: Scaffolding ast visitor for InlineAsm

gcc/rust/ChangeLog:

* ast/rust-ast-visitor.h:
Scaffolding ast visitor for InlineAsm
* ast/rust-ast.cc (InlineAsm::accept_vis): Likewise.
* ast/rust-expr.h: Likewise.

4 months agogccrs: Fix warnings
jjasmine [Sat, 1 Jun 2024 02:34:49 +0000 (19:34 -0700)] 
gccrs: Fix warnings

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
Fix compile warnings.
(parse_options): Likewise.
(parse_asm): Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_illegal_options.rs:

4 months agogccrs: Partial unsafe support for inline asm
jjasmine [Fri, 31 May 2024 23:09:40 +0000 (16:09 -0700)] 
gccrs: Partial unsafe support for inline asm

gcc/rust/ChangeLog:

* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit):
Partial unsafe support for inline asm
* checks/errors/rust-unsafe-checker.h: Likewise.
* hir/tree/rust-hir-expr.h: Likewise.
* hir/tree/rust-hir.cc (InlineAsm::accept_vis): Likewise.

4 months agogccrs: Add support for AST to HIR inline asm translation
jjasmine [Fri, 31 May 2024 21:55:45 +0000 (14:55 -0700)] 
gccrs: Add support for AST to HIR inline asm translation

gcc/rust/ChangeLog:

* ast/rust-expr.h:
Add support for AST to HIR inline asm translation
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise.
* hir/rust-ast-lower-expr.h: Likewise.
* hir/tree/rust-hir-expr.h (class InlineAsm): Likewise.

4 months agogccrs: Slim down the test cases
jjasmine [Fri, 31 May 2024 09:06:18 +0000 (02:06 -0700)] 
gccrs: Slim down the test cases

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_faulty_clobber.rs: compress
the test
* rust/compile/inline_asm_nop.rs: compress
the test
* rust/compile/inline_asm_faulty_clobber_1.rs: Removed.
* rust/compile/inline_asm_faulty_clobber_2.rs: Removed.
* rust/compile/inline_asm_nop_2.rs: Removed.

4 months agogccrs: Refactoring for inline asm pr
jjasmine [Fri, 31 May 2024 09:01:18 +0000 (02:01 -0700)] 
gccrs: Refactoring for inline asm pr

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct AnonConst):
major refactoring of inline asm, mostly concerns
naming convention, trinary conditionals, warnings,
adding rust_unreachables in not-yet supported errors.
(struct InlineAsmRegOrRegClass): Likewise.
(struct InlineAsmOperand): Likewise.
* expand/rust-macro-builtins-asm.cc (parse_clobber_abi): Likewise.
(parse_reg): Likewise.
(parse_operand): Likewise.
(parse_reg_operand): Likewise.
(check_and_set): Likewise.
(parse_options): Likewise.
(parse_format_string): Likewise.
(parse_asm_arg): Likewise.
(parse_asm): Likewise.
* expand/rust-macro-builtins-asm.h (parse_asm_arg): Likewise.
(check_identifier): Likewise.
(check_and_set): Likewise.
(parse_operand): Likewise.
(parse_reg_operand): Likewise.
(parse_options): Likewise.
(parse_reg): Likewise.
(parse_clobber_abi): Likewise.
* expand/rust-macro-builtins.cc (enum class): Likewise.
(inline_asm_maker): Likewise.
* checks/errors/borrowck/ffi-polonius/Cargo.lock: Removed. Likewise.

gcc/testsuite/ChangeLog:
* rust/compile/inline_asm_faulty_clobber.rs: Likewise.
* rust/compile/inline_asm_faulty_clobber_1.rs: Likewise.
* rust/compile/inline_asm_faulty_clobber_2.rs: Likewise.
* rust/compile/inline_asm_illegal_options.rs: Likewise.

4 months agogccrs: Got AST::Fragment to be created from InlineAsm
jjasmine [Wed, 29 May 2024 04:56:19 +0000 (21:56 -0700)] 
gccrs: Got AST::Fragment to be created from InlineAsm

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct AnonConst):
Got AST::Fragment to be created from InlineAsm.
(struct InlineAsmOperand): Likewise.
(class InlineAsm): Likewise.
* expand/rust-macro-builtins-asm.cc (parse_reg_operand): Likewise.
(parse_asm): likewise

4 months agogccrs: Working towards parse_reg and parse_reg_operand
jjasmine [Tue, 28 May 2024 08:21:07 +0000 (01:21 -0700)] 
gccrs: Working towards parse_reg and parse_reg_operand

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg):
Working towards parse_reg and parse_reg_operand
(parse_reg_operand):
Working towards parse_reg and parse_reg_operand
(parse_asm_arg):
Add todo about errors
* expand/rust-macro-builtins-asm.h (parse_global_asm):
remove dead code.
(parse_nonglobal_asm):
remove dead code.

4 months agogccrs: Renamed parseAsmArg to conform to other function names
jjasmine [Tue, 28 May 2024 07:17:33 +0000 (00:17 -0700)] 
gccrs: Renamed parseAsmArg to conform to other function names

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parseAsmArg):
Renamed parseAsmArg to conform to other function names
(parse_asm_arg): Likewise.
(parse_asm): Likewise.
* expand/rust-macro-builtins-asm.h (parseAsmArg): Likewise.
(parse_asm_arg): Likewise.

4 months agogccrs: Big Refactor after meeting
jjasmine [Tue, 28 May 2024 03:51:38 +0000 (20:51 -0700)] 
gccrs: Big Refactor after meeting

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct InlineAsmRegOrRegClass):
Remove union
(struct InlineAsmOperand): Make instances of inside struct.
* expand/rust-macro-builtins-asm.cc (parse_clobber_abi):
Change signature with inlineAsmCtx.
(parse_reg): Likewise.
(parse_operand): Likewise.
(parse_reg_operand): Likewise.
(check_and_set): Likewise.
(parse_options): Likewise.
(parse_format_string): Likewise.
(parseAsmArg): Likewise.
(parse_asm): Likewise.
* expand/rust-macro-builtins-asm.h (class InlineAsmContext): Likewise.
(parseAsmArg): Likewise.
(check_and_set): Likewise.
(parse_reg_operand): Likewise.
(parse_options): Likewise.
(parse_reg): Likewise.
(parse_clobber_abi): Likewise.

4 months agogccrs: Remove global_asm and non_global_asm handler
jjasmine [Fri, 24 May 2024 23:01:13 +0000 (16:01 -0700)] 
gccrs: Remove global_asm and non_global_asm handler

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc
(MacroBuiltin::global_asm_handler):
Remove global_asm and non_global_asm handler
(MacroBuiltin::nonglobal_asm_handler): Likewise.
(MacroBuiltin::asm_handler): Likewise.
* expand/rust-macro-builtins.cc (enum class): Likewise.
(inline_asm_maker): Likewise.
* expand/rust-macro-builtins.h: Likewise.

4 months agogccrs: Safegaurd InlineAsm's clone_expr_...
jjasmine [Fri, 24 May 2024 22:35:16 +0000 (15:35 -0700)] 
gccrs: Safegaurd InlineAsm's clone_expr_...

Safegaurd InlineAsm's clone_expr_... with unreachable since
we would never use them.

gcc/rust/ChangeLog:

* ast/rust-expr.h:
Safegaurd InlineAsm's clone_expr_... with unreachable.

4 months agogccrs: Rename InlineAsmOptions to InlineAsmOption
jjasmine [Fri, 24 May 2024 22:31:48 +0000 (15:31 -0700)] 
gccrs: Rename InlineAsmOptions to InlineAsmOption

Rename InlineAsmOptions to InlineAsmOption for clarity

gcc/rust/ChangeLog:

* ast/rust-ast-full-decls.h (enum class):
Rename InlineAsmOptions to InlineAsmOption for clarity
* ast/rust-expr.h (enum class): Likewise.
* expand/rust-macro-builtins-asm.cc (check_and_set): Likewise.
(parse_options): Likewise.
* expand/rust-macro-builtins-asm.h (check_and_set): Likewise.
* hir/tree/rust-hir-expr.h: Likewise.

4 months agogccrs: Scaffolding parse_reg
jjasmine [Fri, 24 May 2024 22:18:45 +0000 (15:18 -0700)] 
gccrs: Scaffolding parse_reg

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct InlineAsmRegOrRegClass):
Scaffolding parse_reg
* expand/rust-macro-builtins-asm.cc (parse_reg): Likewise.
(parse_operand): Likewise.
(parseAsmArg): Likewise.

4 months agogccrs: Resolve static decl warning
jjasmine [Wed, 22 May 2024 18:25:07 +0000 (11:25 -0700)] 
gccrs: Resolve static decl warning

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.h (parseAsmArg):
Resolve static decl warning
(parse_nonglobal_asm):
Resolve static decl warning

4 months agogccrs: Add checks for duplicate options in inline asm
jjasmine [Wed, 22 May 2024 09:00:09 +0000 (02:00 -0700)] 
gccrs: Add checks for duplicate options in inline asm

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (check_and_set):
Add checks for duplicate options in inline asm
(parse_options): likewise.

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_illegal_options.rs: New test.

4 months agogccrs: Wraps inline_asm tests in unsafe {}
jjasmine [Wed, 22 May 2024 08:23:40 +0000 (01:23 -0700)] 
gccrs: Wraps inline_asm tests in unsafe {}

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_faulty_clobber.rs:
Wraps inline_asm tests in unsafe {}
* rust/compile/inline_asm_faulty_clobber_1.rs: likewise.
* rust/compile/inline_asm_faulty_clobber_2.rs: likewise.
* rust/compile/inline_asm_ident_first.rs: likewise.
* rust/compile/inline_asm_nop.rs: likewise.
* rust/compile/inline_asm_nop_2.rs: likewise.

4 months agogccrs: Parsing of options(...) done.
jjasmine [Wed, 22 May 2024 08:18:48 +0000 (01:18 -0700)] 
gccrs: Parsing of options(...) done.

This is without any mutually exclusive options checked, or
any relationship with reg_operands. Very primitive.

gcc/rust/ChangeLog:

* ast/rust-expr.h: parsing of options(...)
* expand/rust-macro-builtins-asm.cc (check_and_set):
likewise.
(parse_options): likewise.
(parseAsmArg): likewise.
* expand/rust-macro-builtins-asm.h (check_and_set):
likewise.

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_legal_options.rs: New test.

4 months agogccrs: Implemented parse_clobber_abi to pass new tests
jjasmine [Wed, 22 May 2024 02:46:18 +0000 (19:46 -0700)] 
gccrs: Implemented parse_clobber_abi to pass new tests

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_clobber_abi):
implemented parse_clobber_abi
(parse_format_string): likewise.
(parseAsmArg): likewise.
(parse_asm): likewise.
* expand/rust-macro-builtins-asm.h (parseAsmArg): likewise.

4 months agogccrs: Added faulty tests for inline asm cloberring
jjasmine [Wed, 22 May 2024 02:45:35 +0000 (19:45 -0700)] 
gccrs: Added faulty tests for inline asm cloberring

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_faulty_clobber.rs: New test.
* rust/compile/inline_asm_faulty_clobber_1.rs: New test.
* rust/compile/inline_asm_faulty_clobber_2.rs: New test.

4 months agogccrs: Add tests parsing with trailing commas inline asm
jjasmine [Wed, 22 May 2024 01:06:30 +0000 (18:06 -0700)] 
gccrs: Add tests parsing with trailing commas inline asm

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_nop_2.rs: New test.

4 months agogccrs: Top level parsing test for asm!
jjasmine [Wed, 22 May 2024 00:54:57 +0000 (17:54 -0700)] 
gccrs: Top level parsing test for asm!

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_ident_first.rs: New test.

4 months agogccrs: Add a simple no-op test for asm!
jjasmine [Wed, 22 May 2024 00:48:30 +0000 (17:48 -0700)] 
gccrs: Add a simple no-op test for asm!

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_nop.rs: Simple test for asm!

4 months agogccrs: Replace scaffolded InlineAsm with real InlineAsm.
jjasmine [Tue, 21 May 2024 23:50:36 +0000 (16:50 -0700)] 
gccrs: Replace scaffolded InlineAsm with real InlineAsm.

Replace scaffolded InlineAsm with real InlineAsm node in rust-expr.h

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parseDirSpec): replace
scaffolded InlineAsm with real InlineAsm.
(parse_clobber_abi): likewise.
(check_and_set): likewise.
(parse_options): likewise.
(parseAsmArg): likewise.
(parse_asm): likewise.
* expand/rust-macro-builtins-asm.h (struct AsmParseError): likewise.
(enum InlineAsmDirSpec): likewise.
(enum InlineAsmRegOrRegClass): likewise.
(struct AsmArg): likewise.
(parseAsmArg): likewise.
(check_and_set): likewise.
(parse_operand): likewise.
(parse_options): likewise.
(parse_reg): likewise.
(parse_clobber_abi): likewise.

4 months agogccrs: Make InlineAsm non-abstract for usage in parsing.
jjasmine [Tue, 21 May 2024 22:02:00 +0000 (15:02 -0700)] 
gccrs: Make InlineAsm non-abstract for usage in parsing.

gcc/rust/ChangeLog:

* ast/rust-expr.h: Make InlineAsm non-abstract for usage in parsing.

4 months agogccrs: Introduced is_global_asm to InlineAsm AST
jjasmine [Tue, 21 May 2024 21:53:52 +0000 (14:53 -0700)] 
gccrs: Introduced is_global_asm to InlineAsm AST

gcc/rust/ChangeLog:

* ast/rust-expr.h: Introduced is_global_asm to InlineAsm AST

4 months agogccrs: First draft of parse_option finished
jjasmine [Tue, 21 May 2024 07:31:57 +0000 (00:31 -0700)] 
gccrs: First draft of parse_option finished

Finish up on parse_option, formatted parse_clobber_abi
gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_clobber_abi): format
(check_and_set): helper function, is try_set_option equivalent
(parse_options): new function
* expand/rust-macro-builtins-asm.h (enum InlineAsmOptions):
removed
(check_and_set): decl of helper function

4 months agogccrs: Fix clobber_api brackets
jjasmine [Tue, 21 May 2024 06:04:01 +0000 (23:04 -0700)] 
gccrs: Fix clobber_api brackets

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_clobber_abi): title.

4 months agogccrs: Working on parse_options for a bit more
jjasmine [Tue, 21 May 2024 06:02:59 +0000 (23:02 -0700)] 
gccrs: Working on parse_options for a bit more

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_options): title.

4 months agogccrs: Introduce first implementation of parse_clobber_abi
jjasmine [Tue, 21 May 2024 00:01:43 +0000 (17:01 -0700)] 
gccrs: Introduce first implementation of parse_clobber_abi

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_clobber_abi): title.
(parseAsmArg): title.
* expand/rust-macro-builtins-asm.h (parse_clobber_abi): title.

4 months agogccrs: Working on parseAsmArg
jjasmine [Sun, 19 May 2024 04:24:10 +0000 (21:24 -0700)] 
gccrs: Working on parseAsmArg

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (enum InlineAsmRegOrRegClass): title.
(parseAsmArg): title.
(check_identifier): title.
(parse_operand): title.
(parse_options): title.
(parse_reg): title.
(parseDirSpec): title.
(parse_asm): title.

4 months agogccrs: Almost done with top level parsing
jjasmine [Wed, 8 May 2024 18:06:00 +0000 (11:06 -0700)] 
gccrs: Almost done with top level parsing

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (struct AsmParseError): title.
(enum InlineAsmDirSpec): title.
(enum InlineAsmOptions): title.
(struct AsmArg): title.
(parseAsmArg): title.
(parse_global_asm): title.
(parse_nonglobal_asm): title.
(parse_asm): title.
(parseDirSpec): title.
(parse_format_string): title.
(MacroBuiltin::global_asm_handler): title.
(MacroBuiltin::nonglobal_asm_handler): title.
* expand/rust-macro-builtins.cc: title.
* expand/rust-macro-builtins.h: title.

4 months agogccrs: Add regression tests for exclusive range pattern
Pierre-Emmanuel Patry [Tue, 21 May 2024 16:29:08 +0000 (18:29 +0200)] 
gccrs: Add regression tests for exclusive range pattern

Add a few test to check the exclusive range pattern feature. This feature
is experimental and shall not be enabled in stable rust.

gcc/testsuite/ChangeLog:

* rust/compile/exclusive_range_pattern.rs: New test.
* rust/compile/exclusive_range_pattern_feature_gate.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Add exclusive_range_pattern feature gate
Pierre-Emmanuel Patry [Tue, 21 May 2024 16:09:14 +0000 (18:09 +0200)] 
gccrs: Add exclusive_range_pattern feature gate

This syntax is experimental and shall be explicitely enabled in the crate
attributes as it cannot be used in stable rust.

gcc/rust/ChangeLog:

* checks/errors/rust-feature-gate.cc (FeatureGate::visit): Gate the
excluded pattern.
* checks/errors/rust-feature-gate.h: Update the function prototype
and delete two empty implementations in order to use default visitor
behavior.
* checks/errors/rust-feature.cc (Feature::create): Add the new
exclusive range pattern feature gate.
* checks/errors/rust-feature.h: Add new feature enum variant for
exclusive range patterns.
* parse/rust-parse-impl.h (Parser::parse_pattern_no_alt): Forward the
token location to the AST.
(Parser::parse_ident_leading_pattern): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Parse exclusive range pattern
Pierre-Emmanuel Patry [Tue, 21 May 2024 15:45:34 +0000 (17:45 +0200)] 
gccrs: Parse exclusive range pattern

Exclusive range pattern were not handled by the parser as this an
experimental feature.

gcc/rust/ChangeLog:

* ast/rust-pattern.cc (tokenid_to_rangekind): Add a new function to
get a range kind from the current token type.
(RangePattern::as_string): Change the string representation for range
pattern in order to handle excluded ranges.
* ast/rust-pattern.h (enum class): Add new enum class to differentiate
range kinds.
(tokenid_to_rangekind): New prototype for a function that converts a
token id to it's corresponding range kind.
(class RangePattern): Change the class to accept a range kind instead
of an ellipsis boolean.
* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Abort
when an excluded pattern has been found as we do not handle their
lowering yet.
* parse/rust-parse-impl.h (Parser::parse_literal_or_range_pattern):
Parse excluded range patterns.
(Parser::parse_pattern_no_alt): Likewise.
(Parser::parse_ident_leading_pattern): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Add some test for raw_ref_op to prevent regressions
Pierre-Emmanuel Patry [Tue, 21 May 2024 09:36:55 +0000 (11:36 +0200)] 
gccrs: Add some test for raw_ref_op to prevent regressions

Add a test for the feature gate, as well as some test to ensure the raw
keyword stays weak. Also add some tests to check whether the raw_ref_op
syntax is parsed correctly.

gcc/testsuite/ChangeLog:

* rust/compile/not_raw_ref_op.rs: New test.
* rust/compile/raw_ref_op.rs: New test.
* rust/compile/raw_ref_op_feature_gate.rs: New test.
* rust/compile/raw_ref_op_invalid.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Add raw_ref_op feature gate
Pierre-Emmanuel Patry [Tue, 21 May 2024 08:58:55 +0000 (10:58 +0200)] 
gccrs: Add raw_ref_op feature gate

Raw ref operators are still experimental and shall not slip within
stable rust, they should therefore be feature gated.

gcc/rust/ChangeLog:

* checks/errors/rust-feature-gate.cc (FeatureGate::visit): Gate raw
borrow.
* checks/errors/rust-feature-gate.h: Update function prototype.
* checks/errors/rust-feature.cc: Add raw_ref_op gate.
* checks/errors/rust-feature.h: Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Prevent raw reference from being lowered silently
Pierre-Emmanuel Patry [Tue, 21 May 2024 08:38:16 +0000 (10:38 +0200)] 
gccrs: Prevent raw reference from being lowered silently

We do not handle those kind of references yet, we shall not let them
pass as a regular reference.

gcc/rust/ChangeLog:

* ast/rust-expr.h: Add a getter for mutability.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Panic when a
raw reference is met.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Parse raw ref operator
Pierre-Emmanuel Patry [Tue, 21 May 2024 08:23:55 +0000 (10:23 +0200)] 
gccrs: Parse raw ref operator

The raw ref operator is an unstable feature required to obtain a pointer
to unaligned adresses (mainly unaligned struct fields) without UB.

gcc/rust/ChangeLog:

* ast/rust-ast-builder.cc (Builder::ref): Adapt constructor to the new
API.
* ast/rust-ast-collector.cc (TokenCollector::visit): Emit a raw weak
keyword when required.
* ast/rust-ast.cc (BorrowExpr::as_string): Change as_string
representation to handle raw ref operator.
* ast/rust-expr.h (class BorrowExpr): Add raw discriminant.
* expand/rust-macro-builtins-include.cc: Adapt constructor to the new
API.
* parse/rust-parse-impl.h: Handle the raw weak keyword.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Add a new regression test over struct expr field
Pierre-Emmanuel Patry [Mon, 20 May 2024 15:57:52 +0000 (17:57 +0200)] 
gccrs: Add a new regression test over struct expr field

We want to prevent regressions on struct expr field attribute parsing.

gcc/testsuite/ChangeLog:

* rust/compile/struct_expr_field_attributes.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Add outer attributes to struct expr fields
Pierre-Emmanuel Patry [Mon, 20 May 2024 13:28:19 +0000 (15:28 +0200)] 
gccrs: Add outer attributes to struct expr fields

Struct fields can have outer attributes on their field for various
purpose, this behavior should be reflected upon struct expr fields.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Output field
attributes.
* ast/rust-expr.h (class StructExprField): Add outer attributes member.
* parse/rust-parse-impl.h (Parser::parse_struct_expr_field): Parse
outer attributes and store them in the appropriate AST node.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Add two new tests related to may_dangle attribute
Pierre-Emmanuel Patry [Mon, 20 May 2024 11:29:51 +0000 (13:29 +0200)] 
gccrs: Add two new tests related to may_dangle attribute

First test checks the may_dangle outer atttribute on generic params can
be parsed. The second one tests whether may_dangle attributes are
correctly feature gated.

gcc/testsuite/ChangeLog:

* rust/compile/dropck_eyepatch_feature_gate.rs: New test.
* rust/compile/may_dangle.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Add dropck_eyepatch feature gate for may_dangle
Pierre-Emmanuel Patry [Mon, 20 May 2024 11:26:43 +0000 (13:26 +0200)] 
gccrs: Add dropck_eyepatch feature gate for may_dangle

Add a new feature gate for may_dangle generic param outer attributes.

gcc/rust/ChangeLog:

* checks/errors/rust-feature-gate.cc: Visit and gate may_dangle
attributes.
* checks/errors/rust-feature-gate.h: Update visit function prototype
and add a new member function to check on a set of attributes whether
one is may_dangle.
* checks/errors/rust-feature.cc (Feature::create): Add new
dropck_eyepatch feature.
* checks/errors/rust-feature.h: Likewise.
* util/rust-attribute-values.h: Add new may_dangle attribute value.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Allow multiple outer attributes on generic params
Pierre-Emmanuel Patry [Mon, 20 May 2024 10:00:11 +0000 (12:00 +0200)] 
gccrs: Allow multiple outer attributes on generic params

Previously generic params only allowed one outer attribute in front of
them.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Visit outer
attributes.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Change outer
attribute visit, we need to visit all of them.
* ast/rust-ast.cc (LifetimeParam::as_string): Change as_string
implementation to allow multiple outer attributes.
(TypeParam::as_string): Likewise.
* ast/rust-ast.h (class LifetimeParam): Allow multiple outer
attributes.
* ast/rust-item.h (class TypeParam): Likewise.
* ast/rust-path.h: Likewise.
* parse/rust-parse-impl.h (Parser::parse_generic_param): Change call
to outer attribute parsing to collect several attributes.
(Parser::parse_lifetime_param): Likewise.
(Parser::parse_type_param): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Fix generic parameter parsing
Pierre-Emmanuel Patry [Mon, 20 May 2024 09:02:53 +0000 (11:02 +0200)] 
gccrs: Fix generic parameter parsing

Generic parameter parsing failed when an outer attribute was used on it.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_generic_param): Change token
reference to be the last token after all outer attributes have been
parsed.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Add new test for box syntax
Pierre-Emmanuel Patry [Sun, 19 May 2024 00:11:36 +0000 (02:11 +0200)] 
gccrs: Add new test for box syntax

Add a new test to prevent regressions on the box syntax as well as its
feature gate.

gcc/testsuite/ChangeLog:

* rust/compile/box_syntax.rs: New test.
* rust/compile/box_syntax_feature_gate.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Add feature gate for box syntax
Pierre-Emmanuel Patry [Sun, 19 May 2024 00:44:42 +0000 (02:44 +0200)] 
gccrs: Add feature gate for box syntax

The box syntax is experimental even though it is used in the standard
library. It should be feature gated to prevent anyone from using it in
stable rust.

gcc/rust/ChangeLog:

* checks/errors/rust-feature-gate.cc (FeatureGate::visit): Allow
visitor recursion in functions. Also add the gate for the box syntax.
* checks/errors/rust-feature-gate.h: Remove several recursion fences
in the feature gate visitor.
* checks/errors/rust-feature.cc (Feature::create): Add a new feature.
(Feature::as_name): Likewise.
* checks/errors/rust-feature.h: Add box_syntax gate.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Parse box expressions
Pierre-Emmanuel Patry [Sat, 18 May 2024 21:53:42 +0000 (23:53 +0200)] 
gccrs: Parse box expressions

Add support for old box expression syntax.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Add visit member
function for BoxExpr nodes.
* ast/rust-ast-collector.h: Add visit function prototype.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Add visit member
function to default ast visitor.
* ast/rust-ast-visitor.h: Add visit function's prototype.
* ast/rust-ast.cc (BoxExpr::as_string): Add as_string function
implementation for BoxExpr.
(BoxExpr::accept_vis): Add accept_vis implementation to BoxExpr.
* ast/rust-expr.h (class BoxExpr): Add BoxExpr class to represent boxed
expressions.
* expand/rust-derive.h: Add BoxExpr visit function prototype.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Add BoxExpr
visitor implementation.
* hir/rust-ast-lower-base.h: Add visit function's prototype.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Add BoxExpr
visitor implementation.
* hir/rust-ast-lower-expr.h: Add visit function's prototype.
* parse/rust-parse-impl.h (Parser::parse_box_expr): Add parse_box_expr
function's implementation.
* parse/rust-parse.h: Add parse_box_expr function's prototype.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Add resolver
visit implementation.
* resolve/rust-ast-resolve-base.h: Add resolver's visit function
prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Improve handling of ConstantItem during name resolution 2.0
Owen Avery [Thu, 29 Feb 2024 01:19:04 +0000 (20:19 -0500)] 
gccrs: Improve handling of ConstantItem during name resolution 2.0

gcc/rust/ChangeLog:

* resolve/rust-default-resolver.cc
(DefaultResolver::visit):
Scope with Rib::Kind::ConstantItem instead
of Rib::Kind::Item.
* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::visit): Remove redundancy in override of
ConstantItem visitor.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Allow rustc_const_stable and rustc_const_unstable
Owen Avery [Thu, 29 Feb 2024 02:00:08 +0000 (21:00 -0500)] 
gccrs: Allow rustc_const_stable and rustc_const_unstable

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc
(MacroBuiltin::builtin_transcribers):
Add entries for "rustc_const_stable" and "rustc_const_unstable".
* util/rust-attributes.cc
(__definitions): Add entries for RUSTC_CONST_STABLE and
RUSTC_CONST_UNSTABLE.
* util/rust-attribute-values.h
(Attributes::RUSTC_CONST_STABLE): New.
(Attributes::RUSTC_CONST_UNSTABLE): New.

gcc/testsuite/ChangeLog:

* rust/compile/rustc_const_stable.rs:
Enable feature rustc_attrs, expect no errors.
* rust/compile/rustc_const_unstable.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Corrected access specifiers
Kushal Pal [Mon, 27 May 2024 03:16:03 +0000 (03:16 +0000)] 
gccrs: Corrected access specifiers

gcc/rust/ChangeLog:

* ast/rust-expr.h (class OperatorExpr):
Location should be private.
* hir/tree/rust-hir-expr.h (class OperatorExpr): Likewise.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
4 months agogccrs: Make gccrs recognize negative_impls
jjasmine [Wed, 15 May 2024 19:44:15 +0000 (12:44 -0700)] 
gccrs: Make gccrs recognize negative_impls

gcc/rust/ChangeLog:

* checks/errors/rust-feature-gate.cc (FeatureGate::visit): make
gccrs recognize negative_impls
* checks/errors/rust-feature-gate.h: likewise.
* checks/errors/rust-feature.cc (Feature::create): likewise.
* checks/errors/rust-feature.h: likewise.

gcc/testsuite/ChangeLog:

* rust/compile/negative_impls.rs: New test.
* rust/compile/negative_impls_2.rs: New test.

4 months agogccrs: Add system include to `gcc/rust/rust-system.h`
SIGMazer [Tue, 23 Apr 2024 15:33:17 +0000 (17:33 +0200)] 
gccrs: Add system include to `gcc/rust/rust-system.h`

gcc/rust/ChangeLog:

* rust-system.h: Add system include <stack>

Signed-off-by: SIGMazer <mazinasd7@gmail.com>
4 months agogccrs: Add call and method call default visitors
Owen Avery [Thu, 29 Feb 2024 01:18:14 +0000 (20:18 -0500)] 
gccrs: Add call and method call default visitors

gcc/rust/ChangeLog:

* resolve/rust-default-resolver.cc
(DefaultResolver::visit):
New for AST::CallExpr and AST::MethodCallExpr.
* resolve/rust-default-resolver.h
(DefaultResolver::visit): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Remove useless cstddef header from rust-fmt
jjasmine [Sun, 19 May 2024 02:58:51 +0000 (19:58 -0700)] 
gccrs: Remove useless cstddef header from rust-fmt

gcc/rust/ChangeLog:

* ast/rust-fmt.h:  Remove useless cstddef header from rust-fmt

4 months agogccrs: mingw: Fix build with patch from Liu Hao
Arthur Cohen [Mon, 16 Sep 2024 12:06:13 +0000 (14:06 +0200)] 
gccrs: mingw: Fix build with patch from Liu Hao

This commit adds Liu Hao's patch from
https://github.com/lhmouse/MINGW-packages/blob/5859d27b2b6101204a08ad9702cb2937f8797be9/mingw-w64-gcc/0100-rust-fix.patch

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-borrow-checker.cc (mkdir_wrapped): Remove.
(BorrowChecker::go): Use `mkdir` instead.
* expand/rust-proc-macro.cc (register_callback): Use Windows APIs to
open dynamic proc macro library.
(load_macros_array): Likewise.
* parse/rust-parse.cc (defined): Replace separators in paths using
std::replace.

4 months agogccrs: Change lookup_ast_item's return type
Pierre-Emmanuel Patry [Sat, 4 May 2024 02:10:08 +0000 (04:10 +0200)] 
gccrs: Change lookup_ast_item's return type

Wrap the function's return type within an optional.

gcc/rust/ChangeLog:

* metadata/rust-export-metadata.cc (ExportContext::emit_trait):
Adapt call site to the new return type.
(ExportContext::emit_function): Likewise.
(ExportContext::emit_macro): Likewise.
* util/rust-hir-map.cc (Mappings::lookup_ast_item): Change the
function's return type.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_visibility's return type
Pierre-Emmanuel Patry [Sat, 4 May 2024 01:44:35 +0000 (03:44 +0200)] 
gccrs: Change lookup_visibility's return type

Wrap the return type within an optional.

gcc/rust/ChangeLog:

* checks/errors/privacy/rust-privacy-reporter.cc: Change call site
to accomodate new return type.
* checks/errors/privacy/rust-pub-restricted-visitor.cc: Likewise.
* util/rust-hir-map.cc (Mappings::lookup_visibility): Change the
function's return type.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_macro_invocation's return type
Pierre-Emmanuel Patry [Sat, 4 May 2024 01:21:27 +0000 (03:21 +0200)] 
gccrs: Change lookup_macro_invocation's return type

Wrap the function's return type within an optional and remove the out
reference argument.

gcc/rust/ChangeLog:

* expand/rust-macro-expand.cc (MacroExpander::expand_invoc): Adapt
the function call to match its new prototype.
* resolve/rust-early-name-resolver-2.0.cc (Early::insert_once):
Likewise.
(Early::visit): Likewise.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit):
Likewise.
* util/rust-hir-map.cc (Mappings::lookup_macro_invocation): Change the
function's return type.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_macro_def return type
Pierre-Emmanuel Patry [Sat, 4 May 2024 00:42:10 +0000 (02:42 +0200)] 
gccrs: Change lookup_macro_def return type

Wrap the function's return type within an optional.

gcc/rust/ChangeLog:

* resolve/rust-early-name-resolver-2.0.cc (Early::insert_once): Change
call site to accomodate the new return type.
(Early::visit): Likewise.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit):
Likewise.
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):
Likewise.
* util/rust-hir-map.cc (Mappings::lookup_macro_def): Change the
function's return type.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_canonical_path's return path
Pierre-Emmanuel Patry [Fri, 3 May 2024 21:17:43 +0000 (23:17 +0200)] 
gccrs: Change lookup_canonical_path's return path

Change the function's return type to wrap it within an optional.

gcc/rust/ChangeLog:

* backend/rust-compile-base.cc: Change call site to accomodate new
return type.
* backend/rust-compile-base.h: Change parameter to use a reference.
* backend/rust-compile-extern.h: Likewise.
* backend/rust-compile-implitem.cc (CompileTraitItem::visit):
Change call site for new return type.
* backend/rust-compile-item.cc (CompileItem::visit): Likewise.
* resolve/rust-ast-resolve-type.cc (ResolveTypeToCanonicalPath::visit):
Likewise.
* typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit):
Likewise.
* typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit):
Likewise.
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit):
Likewise.
* typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn):
Likewise.
* util/rust-hir-map.h: Update the function's prototype and change the
function's return type.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_hir_pattern return type
Pierre-Emmanuel Patry [Fri, 3 May 2024 18:55:01 +0000 (20:55 +0200)] 
gccrs: Change lookup_hir_pattern return type

Wrap the function's return type within an optional in order to
differentiate between a null pointer and a missing value.

gcc/rust/ChangeLog:

* util/rust-hir-map.cc (Mappings::insert_hir_pattern): Change call site
in order to accomodate new return type.
(Mappings::lookup_hir_pattern): Change the function's return type.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_hir_struct_field return type
Pierre-Emmanuel Patry [Fri, 3 May 2024 18:48:10 +0000 (20:48 +0200)] 
gccrs: Change lookup_hir_struct_field return type

Wrap the function's return type within an optional to differentiate
between a null pointer and a missing value.

gcc/rust/ChangeLog:

* util/rust-hir-map.cc (Mappings::insert_hir_struct_field): Change
call site to accomodate new return type.
(Mappings::lookup_hir_struct_field): Change the function's return
type.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_hir_self_param return type
Pierre-Emmanuel Patry [Fri, 3 May 2024 18:42:06 +0000 (20:42 +0200)] 
gccrs: Change lookup_hir_self_param return type

Wrap the function's return type within an optional in order to
differentiate null pointers from missing value.

gcc/rust/ChangeLog:

* util/rust-hir-map.cc (Mappings::insert_hir_self_param): Adapt call
site to new return type.
(Mappings::lookup_hir_self_param): Change the function's return type.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_hir_param return type with optional
Pierre-Emmanuel Patry [Fri, 3 May 2024 18:34:58 +0000 (20:34 +0200)] 
gccrs: Change lookup_hir_param return type with optional

Wrap the function's return type within an optional to differentiate
between a null ppointer and a missing value.

gcc/rust/ChangeLog:

* util/rust-hir-map.cc (Mappings::insert_hir_param): Change call site
to accomodate new return type.
(Mappings::lookup_hir_param): Change the function's return type.
* util/rust-hir-map.h: Updat ethe function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_hir_smt's return type with optional
Pierre-Emmanuel Patry [Fri, 3 May 2024 18:17:16 +0000 (20:17 +0200)] 
gccrs: Change lookup_hir_smt's return type with optional

Wrap the function's return type within an optional in order to
differentiate missing values from null pointers.

gcc/rust/ChangeLog:

* util/rust-hir-map.cc (Mappings::insert_hir_stmt): Change call site
to accomodate new return type.
(Mappings::lookup_hir_stmt): Change the function's return type.
(Mappings::resolve_nodeid_to_stmt): Adapt call site to new return type.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_hir_type return type with an optional
Pierre-Emmanuel Patry [Fri, 3 May 2024 18:08:14 +0000 (20:08 +0200)] 
gccrs: Change lookup_hir_type return type with an optional

Wrap the function's return type with an optional in order to tell
appart a null pointer from a missing value.

gcc/rust/ChangeLog:

* util/rust-hir-map.cc (Mappings::insert_hir_type): Change call site
to accomodate the new return type.
(Mappings::lookup_hir_type): Change the function's return type.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_hir_generic_param return type
Pierre-Emmanuel Patry [Fri, 3 May 2024 17:59:43 +0000 (19:59 +0200)] 
gccrs: Change lookup_hir_generic_param return type

Wrap the function's return type with an optional.

gcc/rust/ChangeLog:

* util/rust-hir-map.cc (Mappings::insert_hir_generic_param): Change
call site to accomodate the new return type.
(Mappings::lookup_hir_generic_param): Wrap the function's return type
with an optional.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_hir_path_expr_seg return type
Pierre-Emmanuel Patry [Fri, 3 May 2024 17:49:44 +0000 (19:49 +0200)] 
gccrs: Change lookup_hir_path_expr_seg return type

Make the function's return type optional in order to differentiate
between null pointers and missing value.

gcc/rust/ChangeLog:

* util/rust-hir-map.cc (Mappings::insert_hir_path_expr_seg): Change
call site to accomodate the new return type.
(Mappings::lookup_hir_path_expr_seg): Wrap the function's return type
with an optional.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_hir_expr return type to optional
Pierre-Emmanuel Patry [Fri, 3 May 2024 17:40:18 +0000 (19:40 +0200)] 
gccrs: Change lookup_hir_expr return type to optional

Wrap the function's return type with an optional in order to
differentiate missing values from null pointers.

gcc/rust/ChangeLog:

* backend/rust-mangle-v0.cc (v0_path): Adapt call site to new returned
type.
* util/rust-hir-map.cc (Mappings::lookup_hir_expr): Change the
function's return type.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_hir_implitem return type
Pierre-Emmanuel Patry [Fri, 3 May 2024 14:30:06 +0000 (16:30 +0200)] 
gccrs: Change lookup_hir_implitem return type

Wrap the return type within an optional. Now return the parent id within
a pair instead of taking an out reference.

gcc/rust/ChangeLog:

* backend/rust-compile-item.cc (CompileItem::visit): Change call site
to accept new return type.
* backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile):
Likewise.
* backend/rust-mangle-v0.cc (v0_path): Likewise.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit):
Likewise.
* checks/lints/rust-lint-marklive.cc (MarkLive::go): Likewise.
(MarkLive::visit): Likewise.
* typecheck/rust-type-util.cc (query_type): Likewise.
* util/rust-hir-map.cc (Mappings::insert_hir_implitem): Likewise.
(Mappings::lookup_hir_implitem): Change return type.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change return type to optional in get_lang_item
Pierre-Emmanuel Patry [Fri, 3 May 2024 12:54:06 +0000 (14:54 +0200)] 
gccrs: Change return type to optional in get_lang_item

Wrap the function's return type with an optional.

gcc/rust/ChangeLog:

* typecheck/rust-autoderef.cc: Adapt calling code to new return type.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
Likewise.
(TypeCheckExpr::resolve_operator_overload): Likewise.
* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::assemble_builtin_candidate):
Likewise.
* typecheck/rust-tyty.cc (ClosureType::setup_fn_once_output): Likewise.
* util/rust-hir-map.cc (Mappings::get_lang_item): Change return type.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_module function return type
Pierre-Emmanuel Patry [Fri, 3 May 2024 11:25:20 +0000 (13:25 +0200)] 
gccrs: Change lookup_module function return type

Wrap the return type into an optional.

gcc/rust/ChangeLog:

* checks/errors/privacy/rust-visibility-resolver.cc: Update function
call to match the new return type.
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path):
Likewise.
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path):
Likewise.
* util/rust-hir-map.cc (Mappings::insert_module): Likewise.
(Mappings::lookup_module): Change the function's return type.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_hir_extern_item return type
Pierre-Emmanuel Patry [Thu, 2 May 2024 11:44:10 +0000 (13:44 +0200)] 
gccrs: Change lookup_hir_extern_item return type

Wrap the return type with an optional and make the return type a pair
with the parent hid.

gcc/rust/ChangeLog:

* backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile):
Adapt code around new return type.
* checks/errors/rust-const-checker.cc (ConstChecker::check_function_call):
Likewise.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::check_use_of_static):
Likewise.
(UnsafeChecker::check_function_call): Likewise.
* typecheck/rust-type-util.cc (query_type): Likewise.
* util/rust-hir-map.cc (Mappings::insert_hir_extern_item): Likewise.
(Mappings::lookup_hir_extern_item): Change return type.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change return type of lookup trait defid functions.
Pierre-Emmanuel Patry [Thu, 2 May 2024 10:33:20 +0000 (12:33 +0200)] 
gccrs: Change return type of lookup trait defid functions.

Wrap the return type with an optional.

gcc/rust/ChangeLog:

* backend/rust-compile-base.cc (HIRCompileBase::resolve_method_address):
Update code around lookup return type.
* typecheck/rust-tyty-bounds.cc (TypeCheckBase::get_predicate_from_bound):
Likewise.
* typecheck/rust-tyty.cc (ClosureType::setup_fn_once_output):
Likewise.
* util/rust-hir-map.cc (Mappings::insert_defid_mapping): Likewise.
(Mappings::lookup_trait_item_defid): Update return type with an
optional.
(Mappings::get_lang_item): Likewise.
* util/rust-hir-map.h: Update the functions prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_local_defid return type to optional
Pierre-Emmanuel Patry [Thu, 2 May 2024 09:43:02 +0000 (11:43 +0200)] 
gccrs: Change lookup_local_defid return type to optional

Make the API more convenient by changing the function's return type. We
can now differentiate between a stored null pointer and a missing value.

gcc/rust/ChangeLog:

* util/rust-hir-map.cc (Mappings::insert_defid_mapping): Adapt call
to new return type.
(Mappings::insert_local_defid_mapping): Likewise.
(Mappings::lookup_local_defid): Change return type to wrap it with an
optional.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change return type of lookup_defid
Pierre-Emmanuel Patry [Fri, 26 Apr 2024 10:02:53 +0000 (12:02 +0200)] 
gccrs: Change return type of lookup_defid

Change the return type to an optional.

gcc/rust/ChangeLog:

* backend/rust-compile-base.cc (HIRCompileBase::resolve_method_address):
Change calling code to accomodate new return type.
* checks/errors/privacy/rust-privacy-reporter.cc:
Likewise.
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::get_marker_predicate):
Likewise.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
Likewise.
* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::assemble_builtin_candidate):
Likewise.
* typecheck/rust-tyty.cc (ClosureType::setup_fn_once_output): Likewise.
* util/rust-hir-map.cc (Mappings::lookup_defid): Change function's
return type.
* util/rust-hir-map.h: Update function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change crate name retrieval function return types
Pierre-Emmanuel Patry [Thu, 25 Apr 2024 14:34:44 +0000 (16:34 +0200)] 
gccrs: Change crate name retrieval function return types

Change their return type to a const reference in order to avoid copies
when possible. Also wrap this new return type into an optional.

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go):
Adapt the code to the new return types.
* resolve/rust-ast-resolve.cc (NameResolution::go): Likewise.
* util/rust-hir-map.cc (Mappings::get_crate_name): Change return type
to const string reference optional.
(Mappings::get_current_crate_name): Likewise.
* util/rust-hir-map.h: Update function prototypes.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change crate_num_to_nodeid return type
Pierre-Emmanuel Patry [Thu, 25 Apr 2024 14:15:42 +0000 (16:15 +0200)] 
gccrs: Change crate_num_to_nodeid return type

Change the function's return type to an optional.

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-toplevel.h: Adapt the code to the new
return type.
* rust-session-manager.cc (Session::load_extern_crate): Likewise.
* util/rust-hir-map.cc (Mappings::crate_num_to_nodeid): Change the
return type.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change return type of lookup_crate_name
Pierre-Emmanuel Patry [Thu, 25 Apr 2024 14:00:23 +0000 (16:00 +0200)] 
gccrs: Change return type of lookup_crate_name

Change the function's return type to use an optional.

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-toplevel.h: Adapt the code to the new
return type.
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):
Likewise.
* rust-session-manager.cc (Session::load_extern_crate): Likewise.
* util/rust-hir-map.cc (Mappings::lookup_crate_name): Change the return
type to an optional.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change return type of lookup_impl_block_type
Pierre-Emmanuel Patry [Thu, 25 Apr 2024 13:39:33 +0000 (15:39 +0200)] 
gccrs: Change return type of lookup_impl_block_type

Change the return type to an optional.

gcc/rust/ChangeLog:

* typecheck/rust-type-util.cc (query_type): Adapt code to accomodate
the new return type.
* util/rust-hir-map.cc (Mappings::lookup_impl_block_type): Change
the function's return type and remove the out pointer argument.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change return type for lookup_hir_impl_block
Pierre-Emmanuel Patry [Thu, 25 Apr 2024 13:28:32 +0000 (15:28 +0200)] 
gccrs: Change return type for lookup_hir_impl_block

Change the return type to an optiona. This allows to differentiate
between missing hir impl block and null pointers.

gcc/rust/ChangeLog:

* typecheck/rust-type-util.cc (query_type): Change call to the function
in order to accomodate the new return type.
* util/rust-hir-map.cc (Mappings::lookup_hir_impl_block): Change the
function's return type to an optional.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change return type of lookup_hir_extern_block
Pierre-Emmanuel Patry [Thu, 25 Apr 2024 13:14:36 +0000 (15:14 +0200)] 
gccrs: Change return type of lookup_hir_extern_block

Change the return type to an optional in order to easily differentiate
between a null pointer and an missing value.

gcc/rust/ChangeLog:

* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::check_function_call):
Adapt function call to new return type.
* typecheck/rust-type-util.cc (query_type): Likewise.
* util/rust-hir-map.cc (Mappings::insert_hir_extern_block): Likewise.
(Mappings::lookup_hir_extern_block): Change return type to an optional.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change return type of lookup_hir_trait_item
Pierre-Emmanuel Patry [Thu, 25 Apr 2024 12:54:23 +0000 (14:54 +0200)] 
gccrs: Change return type of lookup_hir_trait_item

Change the return type to an optional instead of returning a null
pointer. This allows easier tracking of rogue null pointers in the
map. This commit also fixes a bug in trait associated function mangling,
the function was using an already invalidated pointer.

gcc/rust/ChangeLog:

* backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile):
Adapt return type to new optional.
* backend/rust-mangle-v0.cc (v0_function_path): Change prototype to use
the generic arguments vector instead of the whole HIR function.
(v0_path): Fix a bug with a null pointer being used to create the
trait function mangling.
* util/rust-hir-map.cc (Mappings::insert_hir_trait_item): Adapt code
to new return type.
(Mappings::lookup_hir_trait_item): Change the return type of the
function to an optional.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change return type for lookup_hir_item to optional
Pierre-Emmanuel Patry [Thu, 25 Apr 2024 08:48:47 +0000 (10:48 +0200)] 
gccrs: Change return type for lookup_hir_item to optional

gcc/rust/ChangeLog:

* backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile):
Adapt function call to new return type.
* backend/rust-mangle-v0.cc (v0_path): Likewise.
* checks/errors/rust-const-checker.cc (ConstChecker::check_function_call):
Likewise.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::check_use_of_static):
Likewise.
(UnsafeChecker::check_function_call): Likewise.
(UnsafeChecker::check_function_attr): Likewise.
* checks/lints/rust-lint-marklive.cc (MarkLive::go): Likewise.
(MarkLive::visit): Likewise.
* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait):
Likewise.
* typecheck/rust-type-util.cc (query_type): Likewise.
* util/rust-hir-map.cc (Mappings::insert_hir_item): Likewise.
(Mappings::lookup_hir_item): Change function return type to use
optional.
* util/rust-hir-map.h: Update function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change return type of resolve_nodeid_to_stmt
Pierre-Emmanuel Patry [Wed, 24 Apr 2024 21:21:57 +0000 (23:21 +0200)] 
gccrs: Change return type of resolve_nodeid_to_stmt

Change the return type to an optional.

gcc/rust/ChangeLog:

* util/rust-hir-map.cc (Mappings::resolve_nodeid_to_stmt): Change the
return type and remove pointer out argument.
* util/rust-hir-map.h: Update function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change lookup_hir_to_node return type to optional
Pierre-Emmanuel Patry [Wed, 24 Apr 2024 20:32:54 +0000 (22:32 +0200)] 
gccrs: Change lookup_hir_to_node return type to optional

Optional are more convenient to use and avoid uninitialized data.

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::generate_closure_function):
Adapt code for new optional return type.
* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::check_base_type_privacy):
Likewise.
* util/rust-hir-map.cc (Mappings::lookup_hir_to_node): Change return
type to an optional.
* util/rust-hir-map.h: Adapt function prototype with the new return
type.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>