Age | Commit message (Collapse) | Author | Files | Lines |
|
InlineAsm node does not support memory clobbers.
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc (TokenCollector::visit): Make visitor
unreachable.
* ast/rust-ast-collector.h: Add visit for LlvmInlineAsmNode.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Add visit
function for the default ast visitor.
* ast/rust-ast-visitor.h: Add function prototype.
* ast/rust-ast.cc (LlvmInlineAsm::accept_vis): Add accept_vis to
LlvmInlineAsm node.
* ast/rust-ast.h: Add LlvmInlineAsm node kind.
* ast/rust-expr.h (class LlvmInlineAsm): Add LlvmInlineAsm node.
* expand/rust-derive.h: Add visit function for LlvmInlineAsm node.
* expand/rust-macro-builtins-asm.cc (MacroBuiltin::llvm_asm_handler):
Add handler for llvm inline assembly nodes.
(parse_llvm_asm): Add function to parse llvm assembly nodes.
* expand/rust-macro-builtins-asm.h (parse_llvm_asm): Add function
prototypes.
* expand/rust-macro-builtins.cc (inline_llvm_asm_maker): Add macro
transcriber.
* expand/rust-macro-builtins.h: Add transcriber function prototype.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Add visit
function for LlvmInlineAsm node.
* hir/rust-ast-lower-base.h: Add visit function prototype.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Add visit
function for LlvmInlineAsm node.
* resolve/rust-ast-resolve-base.h: Add visit function prototype.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* util/rust-attribute-values.h: Add RUSTFMT value.
* util/rust-attributes.cc: Define the attribute.
* util/rust-attributes.h (enum CompilerPass): Add EXTERNAL variant.
* expand/rust-macro-builtins.cc: Fix formatting.
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (MacroBuiltin::builtin_transcribers):
Add entry for track_caller.
* util/rust-attribute-values.h: add `TRACK_CALLER` attribute.
* util/rust-attributes.cc: add `track_caller` attribute definition.
gcc/testsuite/ChangeLog:
* rust/compile/track_caller.rs: New test.
Signed-off-by: Bhavesh Mandalapu <mandalapubhavesh@gmail.com>
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins-asm.cc (strip_double_quotes): Special case empty
strings ("\"\"").
(parse_reg_operand): Remove use of the `struct` keyword.
(parse_reg_operand_in): Likewise.
(parse_reg_operand_out): Likewise.
* expand/rust-macro-builtins.cc: Add llvm_asm! built-in macro as an alias to asm!.
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins-utility.cc: Add macro expansion for
option_env with eager expansion
* expand/rust-macro-builtins.cc: Add option_env to builtin list
* expand/rust-macro-builtins.h: Add option_env handler to header
file
* resolve/rust-late-name-resolver-2.0.cc: Prevent NR2.0 from
recursing into lang-item segments
gcc/testsuite/ChangeLog:
* rust/compile/macros/builtin/option_env1.rs: Add success case for option_env
* rust/compile/macros/builtin/option_env2.rs: Add failure case for option_env
* rust/execute/torture/builtin_macro_option_env.rs: Add
execution case for option_env
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-fragment.h (enum class): Add InvocKind and AsmKind enums.
* ast/rust-macro.h: Switch semicolon boolean to InvocKind enum.
* expand/rust-expand-visitor.cc (ExpandVisitor::visit): Likewise.
* 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.
(enum class): 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_eager_invocations): Likewise.
(MacroExpander::expand_invoc): Likewise.
* expand/rust-macro-expand.h (struct MacroExpander): Likewise.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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>
|
|
Fixes issue #2855
gcc/rust/ChangeLog:
* Make-lang.in: add new .o builds for new .cc files
* expand/rust-cfg-strip.h (RUST_CFG_STRIP_H): Add include guards
for rust-cfg-strip
* expand/rust-macro-builtins.cc (make_macro_path_str): moved to new respective files
(make_token): moved to new respective files
(make_string): moved to new respective files
(macro_end_token): moved to new respective files
(try_extract_string_literal_from_fragment): moved to new respective files
(try_expand_many_expr): moved to new respective files
(parse_single_string_literal): moved to new respective files
(source_relative_path): moved to new respective files
(load_file_bytes): moved to new respective files
(MacroBuiltin::assert_handler): moved to new respective files
(MacroBuiltin::file_handler): moved to new respective files
(MacroBuiltin::column_handler): moved to new respective files
(MacroBuiltin::include_bytes_handler): moved to new respective files
(MacroBuiltin::include_str_handler): moved to new respective files
(MacroBuiltin::compile_error_handler): moved to new respective files
(MacroBuiltin::concat_handler): moved to new respective files
(MacroBuiltin::env_handler): moved to new respective files
(MacroBuiltin::cfg_handler): moved to new respective files
(MacroBuiltin::include_handler): moved to new respective files
(MacroBuiltin::line_handler): moved to new respective files
(MacroBuiltin::stringify_handler): moved to new respective files
(struct FormatArgsInput): moved to new respective files
(struct FormatArgsParseError): moved to new respective files
(format_args_parse_arguments): moved to new respective files
(MacroBuiltin::format_args_handler): moved to new respective files
* expand/rust-macro-builtins.h (builtin_macro_from_string):
merge tl::optional from master
* expand/rust-macro-builtins-asm.cc: New file.
* expand/rust-macro-builtins-format-args.cc: New file.
* expand/rust-macro-builtins-helpers.cc: New file.
* expand/rust-macro-builtins-helpers.h: New file.
* expand/rust-macro-builtins-include.cc: New file.
* expand/rust-macro-builtins-location.cc: New file.
* expand/rust-macro-builtins-log-debug.cc: New file.
* expand/rust-macro-builtins-test-bench.cc: New file.
* expand/rust-macro-builtins-trait.cc: New file.
* expand/rust-macro-builtins-utility.cc: New file.
|
|
This fixes an issue we had where the generated code ended with more static
pieces than its rustc counterpart.
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (struct FormatArgsInput): Store the format_str
as a string instead of an AST::Expr.
(format_args_parse_arguments): Transform format_expr into a format string
properly - add note for handling eager macro invocations later on.
(MacroBuiltin::format_args_handler): Parse the correct input, append
newline to format_str if necessary.
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-builder.h: Rename AST::AstBuilder -> AST::Builder
* ast/rust-ast-builder.cc: Likewise.
* expand/rust-derive.cc: Use new AST::Builder name.
* expand/rust-derive.h: Likewise.
* ast/rust-builtin-ast-nodes.h: Add required getters.
* expand/rust-expand-format-args.cc (format_arg): New.
(get_trait_name): New.
(expand_format_args): Properly expand basic format_args!() invocations.
* expand/rust-expand-format-args.h (expand_format_args): Fix signature.
* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler):
Call into expand_format_args().
|
|
gcc/rust/Changelog:
* expand/rust-expand-visitor.cc
(ExpandVisitor::expand_inner_items): Adjust to use has_value ()
(ExpandVisitor::expand_inner_stmts): Likewise
* expand/rust-macro-builtins.cc (builtin_macro_from_string): Likewise
(make_macro_path_str): Likewise
* util/rust-hir-map.cc (Mappings::insert_macro_def): Likewise
* util/rust-lang-item.cc (LangItem::Parse): Adjust to return tl::optional
(LangItem::toString) Likewise
* util/rust-token-converter.cc (handle_suffix): Adjust to use value.or ()
(from_literal) Likewise
* util/bi-map.h (BiMap::lookup): Adjust to use tl::optional for
lookups
Signed-off-by: Sourabh Jaiswal <sourabhrj31@gmail.com>
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Add
documentation regarding future tasks.
|
|
gcc/rust/ChangeLog:
* Make-lang.in: Do not build Rust library in release mode.
* ast/rust-ast.cc: Make FormatArgs inherit from AST::Expr
* ast/rust-builtin-ast-nodes.h: Improve FormatArg* nodes and helpers.
* ast/rust-fmt.cc (Pieces::collect): Fix interface to match FFI function.
* ast/rust-fmt.h (collect_pieces): Likewise.
(struct Pieces): Add append_newline parameter.
* expand/rust-macro-builtins.cc: Add proper parsing of format_args
input.
* hir/rust-ast-lower-base.cc: Include diagnostics header.
libgrust/ChangeLog:
* libformat_parser/src/lib.rs: Switch interface to use more parser
parameters.
* libformat_parser/src/bin.rs: Use new interface.
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (format_args_maker): New function.
(try_expand_many_expr): Add comment about reworking function.
(MacroBuiltin::format_args_handler): Add newline parameter.
* expand/rust-macro-builtins.h: Likewise.
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc: Change BuiltinMacro in
builtin_macro_from_string to tl::optional<>
* expand/rust-macro-builtins.h (enum class): Change BuiltinMacro
in builtin_macro_from_string to tl::optional<>
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit):
Resolved wrong type dependency of builtin_macro_from_string
Signed-off-by: jjasmine <tanghocle456@gmail.com>
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler):
Transform entire invocation token stream into string for the parser.
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler):
Construct string to parser properly.
|
|
Compile libformat_parser and link to it.
gcc/rust/ChangeLog:
* Make-lang.in: Compile libformat_parser.
* ast/rust-fmt.cc: New FFI definitions.
* ast/rust-fmt.h: Likewise.
* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Call
into libformat_parser.
* expand/rust-macro-builtins.h: Define format_args!() handler proper.
libgrust/ChangeLog:
* libformat_parser/Cargo.lock: New file.
* libformat_parser/Cargo.toml: New file.
* libformat_parser/generic_format_parser/Cargo.toml: New file.
* libformat_parser/generic_format_parser/src/lib.rs: New file.
* libformat_parser/src/bin.rs: New file.
* libformat_parser/src/lib.rs: New file.
|
|
Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com>
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (MacroBuiltin::include_str_handler): Comment removed
(MacroBuiltin::env_handler): Comment removed
(MacroBuiltin::cfg_handler): Comment removed
(MacroBuiltin::line_handler): Comment removed
Signed-off-by: Mohammed Rizan Farooqui <rizanfarooqui@gmail.com>
|
|
Attribute values were used as raw string, this is error prone and
makes renaming harder. Using a constexpr instead will leverage the power
of the compiler and emit an error when an incorrect builtin attribute
value is used.
gcc/rust/ChangeLog:
* ast/rust-ast.cc (Attribute::check_cfg_predicate): Change raw
string to constexpr call.
(Attribute::separate_cfg_attrs): Likewise.
* backend/rust-compile-base.cc (should_mangle_item): Likewise.
(HIRCompileBase::setup_fndecl): Likewise.
(HIRCompileBase::handle_cold_attribute_on_fndecl): Likewise.
* checks/errors/privacy/rust-privacy-reporter.cc (find_proc_macro_attribute):
Likewise.
* checks/errors/rust-unsafe-checker.cc (check_target_attr):
Likewise.
* expand/rust-cfg-strip.cc (fails_cfg): Likewise.
(fails_cfg_with_expand): Likewise.
(expand_cfg_attrs): Likewise.
* expand/rust-macro-builtins.cc: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_outer_attributes): Likewise.
(ASTLoweringBase::lower_macro_definition): Likewise.
* hir/rust-hir-dump.cc (Dump::visit): Likewise.
* parse/rust-parse-impl.h (Parser::parse_doc_comment): Likewise.
* parse/rust-parse.cc (extract_module_path): Likewise.
* resolve/rust-early-name-resolver.cc (is_macro_use_module):
Likewise.
(EarlyNameResolver::visit): Likewise.
* resolve/rust-toplevel-name-resolver-2.0.cc (is_macro_export):
Likwise.
* rust-session-manager.cc (Session::injection): Likewise.
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::parse_repr_options): Likewise.
* util/rust-attributes.cc (is_proc_macro_type): Likewise.
(AttributeChecker::check_attribute): Likewise.
(AttributeChecker::visit): Likewise.
* util/rust-hir-map.cc (Mappings::insert_macro_def): Likewise.
* util/rust-attribute-values.h: New file.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc
(MacroBuiltin::include_str_handler): Use vector::data.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
When the load_file_bytes() fails to open the file, it emits an error but
returns an empty vector (as if the file is empty).
Instead, return a tl::optional nullopt in case of error and an empty
vector in case of an empty file.
fixes #2421
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc
(load_file_bytes): Return a tl::optional.
(MacroBuiltin::include_byte_handler): Adjust and check file was
correctly opened.
(MacroBuiltin::include_str_handler): Likewise.
gcc/testsuite/ChangeLog:
* rust/compile/empty_file: New file.
* rust/compile/issue-2421_str.rs: New test.
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
|
|
refs #2421.
gcc/rust/ChangeLog:
* ast/rust-ast-fragment.cc (Fragment::create_empty): New.
* ast/rust-ast-fragment.h (MacroTranscriberFunc): New.
* ast/rust-macro.h (MacroRulesDefinition): Use MacroTranscriberFunc.
* expand/rust-macro-builtins.cc
(MacroBuiltin::builtin_transcribers): likewise.
(MacroBuiltin::assert_handler): Return optional.
(MacroBuiltin::file_handler): Likewise.
(MacroBuiltin::column_handler): Likewise.
(MacroBuiltin::include_bytes_handler): Likewise.
(MacroBuiltin::include_str_handler): Likewise.
(MacroBuiltin::compile_error_handler): Likewise.
(MacroBuiltin::concat_handler): Likewise.
(MacroBuiltin::env_handler): Likewise.
(MacroBuiltin::cfg_handler): Likewise.
(MacroBuiltin::include_handler): Likewise.
(MacroBuiltin::line_handler): Likewise.
(MacroBuiltin::stringify_handler): Likewise.
(MacroBuiltin::sorry): Likewise.
* expand/rust-macro-builtins.h (builtin_transcribers): Use
MacroTranscriberFunc.
(assert_handler): Return optional.
(file_handler): Likewise.
(column_handler): Likewise.
(include_bytes_handler): Likewise.
(include_str_handler): Likewise.
(compile_error_handler): Likewise.
(concat_handler): Likewise.
(env_handler): Likewise.
(cfg_handler): Likewise.
(include_handler): Likewise.
(line_handler): Likewise.
(stringify_handler): Likewise.
(sorry): Likewise.
* expand/rust-macro-expand.cc (MacroExpander::expand_invoc):
Adjust to transcribers returning optional.
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-clone.cc: Replace Location with location_t.
* expand/rust-derive-clone.h: Likewise.
* expand/rust-derive-copy.cc: Likewise.
* expand/rust-derive-copy.h: Likewise.
* expand/rust-derive.cc: Likewise.
* expand/rust-derive.h: Likewise.
* expand/rust-macro-builtins.cc: Likewise.
* expand/rust-macro-builtins.h: Likewise.
* expand/rust-macro-expand.cc: Likewise.
* parse/rust-parse-impl.h: Likewise.
* parse/rust-parse.cc: Likewise.
* parse/rust-parse.h: Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc: Replace Location with location_t.
* ast/rust-ast.cc: Likewise.
* ast/rust-ast.h: Likewise.
* ast/rust-expr.h: Likewise.
* ast/rust-item.h: Likewise.
* ast/rust-macro.h: Likewise.
* ast/rust-path.cc: Likewise.
* ast/rust-path.h: Likewise.
* ast/rust-pattern.h: Likewise.
* ast/rust-stmt.h: Likewise.
* ast/rust-type.h: Likewise.
* backend/rust-compile-base.cc: Likewise.
* backend/rust-compile-base.h: Likewise.
* backend/rust-compile-block.cc: Likewise.
* backend/rust-compile-expr.cc: Likewise.
* backend/rust-compile-expr.h: Likewise.
* backend/rust-compile-fnparam.cc: Likewise.
* backend/rust-compile-fnparam.h: Likewise.
* backend/rust-compile-intrinsic.cc: Likewise.
* backend/rust-compile-pattern.cc: Likewise.
* backend/rust-compile-resolve-path.h: Likewise.
* backend/rust-compile.cc: Likewise.
* checks/errors/rust-const-checker.cc: Likewise.
* checks/errors/rust-const-checker.h: Likewise.
* checks/errors/rust-unsafe-checker.cc: Likewise.
* checks/errors/rust-unsafe-checker.h: Likewise.
* expand/rust-macro-builtins.cc: Likewise.
* expand/rust-macro-expand.h: Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* hir/rust-ast-lower-implitem.h: Likewise.
* hir/rust-ast-lower-item.cc: Likewise.
* hir/tree/rust-hir-expr.h: Likewise.
* hir/tree/rust-hir-item.h: Likewise.
* hir/tree/rust-hir-path.h: Likewise.
* hir/tree/rust-hir-pattern.h: Likewise.
* hir/tree/rust-hir-stmt.h: Likewise.
* hir/tree/rust-hir-type.h: Likewise.
* hir/tree/rust-hir.cc: Likewise.
* hir/tree/rust-hir.h: Likewise.
* lex/rust-token.h: Likewise.
* metadata/rust-extern-crate.cc: Likewise.
* metadata/rust-extern-crate.h: Likewise.
* parse/rust-parse-impl.h: Likewise.
* parse/rust-parse.h: Likewise.
* resolve/rust-ast-resolve-expr.cc: Likewise.
* resolve/rust-ast-resolve-implitem.h: Likewise.
* resolve/rust-ast-resolve-pattern.h: Likewise.
* resolve/rust-ast-resolve-stmt.h: Likewise.
* resolve/rust-ast-resolve-toplevel.h: Likewise.
* resolve/rust-ast-resolve-type.h: Likewise.
* resolve/rust-name-resolver.cc: Likewise.
* resolve/rust-name-resolver.h: Likewise.
* rust-diagnostics.cc: Likewise.
* rust-diagnostics.h: Likewise.
* rust-gcc.cc: Likewise.
* rust-session-manager.cc: Likewise.
* rust-session-manager.h: Likewise.
* typecheck/rust-casts.cc: Likewise.
* typecheck/rust-casts.h: Likewise.
* typecheck/rust-coercion.cc: Likewise.
* typecheck/rust-coercion.h: Likewise.
* typecheck/rust-hir-path-probe.cc: Likewise.
* typecheck/rust-hir-path-probe.h: Likewise.
* typecheck/rust-hir-trait-reference.cc: Likewise.
* typecheck/rust-hir-trait-reference.h: Likewise.
* typecheck/rust-hir-trait-resolve.cc: Likewise.
* typecheck/rust-hir-type-check-base.cc: Likewise.
* typecheck/rust-hir-type-check-base.h: Likewise.
* typecheck/rust-hir-type-check-item.cc: Likewise.
* typecheck/rust-hir-type-check-item.h: Likewise.
* typecheck/rust-hir-type-check-path.cc: Likewise.
* typecheck/rust-hir-type-check-pattern.cc: Likewise.
* typecheck/rust-hir-type-check-pattern.h: Likewise.
* typecheck/rust-hir-type-check-type.cc: Likewise.
* typecheck/rust-hir-type-check-type.h: Likewise.
* typecheck/rust-hir-type-check.cc: Likewise.
* typecheck/rust-hir-type-check.h: Likewise.
* typecheck/rust-substitution-mapper.cc: Likewise.
* typecheck/rust-substitution-mapper.h: Likewise.
* typecheck/rust-type-util.cc: Likewise.
* typecheck/rust-typecheck-context.cc: Likewise.
* typecheck/rust-tyty-bounds.cc: Likewise.
* typecheck/rust-tyty-call.h: Likewise.
* typecheck/rust-tyty-subst.cc: Likewise.
* typecheck/rust-tyty-subst.h: Likewise.
* typecheck/rust-tyty-util.cc: Likewise.
* typecheck/rust-tyty-util.h: Likewise.
* typecheck/rust-tyty.cc: Likewise.
* typecheck/rust-tyty.h: Likewise.
* typecheck/rust-unify.cc: Likewise.
* typecheck/rust-unify.h: Likewise.
* util/rust-hir-map.cc: Likewise.
* util/rust-hir-map.h: Likewise.
* util/rust-identifier.h: Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* Make-lang.in: Remove rust-optional-test.cc's object file
* ast/rust-macro.h: Remove use of Rust::Optional
* backend/rust-compile-base.cc
(HIRCompileBase::resolve_method_address): Likewise.
* checks/errors/privacy/rust-privacy-reporter.cc
(PrivacyReporter::check_for_privacy_violation): Likewise.
(PrivacyReporter::visit): Likewise.
* checks/errors/privacy/rust-privacy-reporter.h: Likewise.
* checks/errors/rust-feature-gate.cc (FeatureGate::check): Likewise.
* checks/errors/rust-feature.cc (Feature::create): Likewise.
(Feature::as_name): Likewise.
* checks/errors/rust-feature.h: Likewise.
* expand/rust-macro-builtins.cc: Likewise.
* lex/rust-lex.cc (Lexer::Lexer): Likewise.
(Lexer::skip_token): Likewise.
(Lexer::dump_and_skip): Likewise.
* lex/rust-lex.h: Likewise.
* resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): Likewise.
* resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Likewise.
* rust-lang.cc (run_rust_tests): Likewise.
* rust-session-manager.cc (Session::compile_crate): Likewise.
(TargetOptions::dump_target_options): Likewise.
* rust-session-manager.h (struct TargetOptions): Likewise.
* util/rust-hir-map.cc (Mappings::lookup_module_children): Likewise.
(Mappings::lookup_module_chidren_items): Likewise.
(Mappings::lookup_module_child): Likewise.
(Mappings::lookup_parent_module): Likewise.
* util/rust-hir-map.h (RUST_HIR_MAP_H): Likewise.
* util/rust-optional-test.cc: Removed.
* util/rust-optional.h: Removed.
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc
(source_relative_path): Use LOCATION_FILE.
(MacroBuiltin::file_handler): Likewise.
(MacroBuiltin::column_handler): Use LOCATION_COLUMN.
(MacroBuiltin::line_handler): Use LOCATION_LINE.
* rust-linemap.cc
(Gcc_linemap::location_file): Remove.
(Gcc_linemap::location_line): Remove.
(Gcc_linemap::location_column): Remove.
* rust-linemap.h
(Linemap::location_file): Remove.
(Linemap::location_line): Remove.
(Linemap::location_column): Remove.
(Linemap::location_to_file): Remove.
(Linemap::location_to_line): Remove.
(Linemap::location_to_column): Remove.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc: Fix comments.
(MacroBuiltin::proc_macro_builtin): Add error message.
* expand/rust-macro-builtins.h: Fix comments.
gcc/testsuite/ChangeLog:
* rust/compile/derive_macro8.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
Fixes #2257.
Derive builtins do not need a real transcriber, but still need one. It
will however never be called since builtin derive macros get expanded
differently, and benefit from knowing on what kind of items they are
applied (struct, enums, unions) rather than receiving a list of tokens
like regular builtin macros.
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (MacroBuiltin::dummy): New function.
* expand/rust-macro-builtins.h: Declare it.
gcc/testsuite/ChangeLog:
* rust/compile/derive_macro7.rs: New test.
|
|
gcc/rust/ChangeLog:
* Make-lang.in: Add new object files to Makefile.
* expand/rust-expand-visitor.cc (is_derive): Move function.
(is_builtin): Likewise.
(get_traits_to_derive): New function.
(derive_item): Likewise.
(ExpandVisitor::visit): Visit item/statements containers.
(ExpandVisitor::visit_outer_attrs): Take a reference on the attribute
instead of a copy.
(ExpandVisitor::is_derive): Deleted function.
(ExpandVisitor::is_builtin): Likewise.
* expand/rust-expand-visitor.h (RUST_EXPAND_VISITOR_H): Add missing #ifdef
guards.
(is_derive): Declare function.
(is_builtin): Likewise.
* expand/rust-macro-builtins.cc (builtin_macro_from_string): Use new
MacroBuiltin::builtins map.
(make_macro_path_str): Likewise.
* expand/rust-macro-builtins.h (enum class): Add builtin derive macros.
* expand/rust-derive-clone.cc: New file.
* expand/rust-derive-clone.h: New file.
* expand/rust-derive.cc: New file.
* expand/rust-derive.h: New file.
* util/rust-hir-map.cc (Mappings::insert_macro_def): Fix logic for
setting builtin macro transcribers.
gcc/testsuite/ChangeLog:
* rust/compile/macro43.rs: Fix test with new derive macros.
* rust/compile/derive_macro1.rs: New test.
* rust/compile/derive_macro3.rs: New test.
* rust/execute/torture/derive_macro1.rs: New test.
* rust/execute/torture/derive_macro3.rs: New test.
|
|
This commit regroups information related to builtin macros in one place instead
of spreading it over multiple files. It also adds a simple bi-directional
hashmap in order to perform lookups from a key as well as a value.
gcc/rust/ChangeLog:
* ast/rust-macro.cc (builtin_macro_from_string): Move function.
* ast/rust-macro.h (enum class): Move enum.
(builtin_macro_from_string): Move function.
* expand/rust-macro-builtins.cc (builtin_macro_from_string): New function.
(make_macro_path_str): Use new bi-map.
(parse_single_string_literal): Use new `BuiltinMacro` enum.
(MacroBuiltin::include_bytes_handler): Likewise.
(MacroBuiltin::include_str_handler): Likewise.
(MacroBuiltin::compile_error_handler): Likewise.
(MacroBuiltin::concat_handler): Likewise.
(MacroBuiltin::env_handler): Likewise.
(MacroBuiltin::include_handler): Likewise.
(MacroBuiltin::sorry): New function.
* expand/rust-macro-builtins.h (enum class): Move enum here.
(builtin_macro_from_string): New function declaration.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Use
new function.
* util/rust-hir-map.cc (Mappings::insert_macro_def): Remove old
builtin macro map.
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc: Include bidirectional map.
* util/bi-map.h: New file.
|
|
We're going to introduce AST::Kind::IDENTIFIER next, and with the
default C-style enum member scoping, this would cause name clashes.
Instead, convert AST::Kind into an enum class, so that its members
are properly namespaced.
gcc/rust/ChangeLog:
* ast/rust-ast.h (Kind): Convert into a C++ enum class
* expand/rust-macro-builtins.cc: Adapt to the change
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
|
|
Since the expansion and stripping phase are now separated, it does not
make sense to keep AttrVisitor named AttrVisitor. Furthermore, the visitor
is already very complex, with a heavy mental load (erasing iterators,
rearranging them, performing cfg-expansion, etc) so further attribute
handling should probably happen in rust-attribute-checker.h
gcc/rust/ChangeLog:
* Make-lang.in: Rename rust-asttribute-visitor.o -> rust-cfg-strip.o
* expand/rust-attribute-visitor.cc: Moved to...
* expand/rust-cfg-strip.cc: ...here.
* expand/rust-attribute-visitor.h: Moved to...
* expand/rust-cfg-strip.h: ...here.
* expand/rust-macro-expand.cc: Fix include of rust-attribute-visitor.h
* expand/rust-macro-builtins.cc: Likewise.
* rust-session-manager.cc (Session::expansion): Call CfgStrip instead of
AttrVisitor.
|
|
Add the stringify macro expansion as well as some tests.
gcc/rust/ChangeLog:
* ast/rust-macro.cc (builtin_macro_from_string): Add identifier
identification.
* ast/rust-macro.h (enum class): Add Stringify builtin macro
type.
* expand/rust-macro-builtins.cc (make_macro_path_str): Add path
for builtin stringify macro.
(MacroBuiltin::stringify_handler): Add handler for builtin
stringify macro.
* expand/rust-macro-builtins.h: Add stringify handler's
prototype.
* util/rust-hir-map.cc (Mappings::insert_macro_def): Add
stringify handler to builtin hir map.
gcc/testsuite/ChangeLog:
* rust/compile/stringify.rs: Add a basic test with some text.
* rust/execute/torture/builtin_macro_stringify.rs: Verify the
text is left as is without any other macro expansion.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
include_bytes. Resolves issue #1872
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (load_file_bytes): Add location parameter.
(MacroBuiltin::include_bytes_handler): Pass location to load_file_bytes.
(MacroBuiltin::include_str_handler): Pass location to load_file_bytes.
gcc/testsuite/ChangeLog:
* rust/compile/builtin_macro_include_bytes_location_info.rs: New test.
* rust/compile/builtin_macro_include_str_location_info.rs: New test.
Signed-off-by: Nikos Alexandris <nikos-alexandris@protonmail.com>
|
|
builtins: Implement eager expansion for include_str!()
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc
(MacroBuiltin::include_str_handler): eager expansion
(make_macro_path_str): macto to string
(parse_single_string_literal): check for eager invocation
(MacroBuiltin::assert_handler): eager expansion
(MacroBuiltin::include_bytes_handler): eager expansion
(MacroBuiltin::include_str_handler): eager expansion
(MacroBuiltin::compile_error_handler): eager expansion
(MacroBuiltin::include_handler): eager expansion
gcc/testsuite/ChangeLog:
* rust/compile/builtin_macro_eager3.rs: New test.
Signed-off-by: omkar-mohanty <franzohouser@gmail.com>
|
|
The class now allows for more variants including a `Hint` one which
then gets emitted by calling `rust_inform`. This allows us to display
hints/tips/notes in backtracking contexts such as the parser.
gcc/rust/ChangeLog:
* rust-diagnostics.h (struct Error): Add new Kind enum and various new
static constructors to allow for hints as well.
* rust-diagnostics.cc (Error::Error): Use new `kind` field properly.
* checks/errors/privacy/rust-visibility-resolver.cc
(VisibilityResolver::resolve_module_path): Use new Error API.
* expand/rust-macro-builtins.cc (MacroBuiltin::include_handler): Likewise.
* expand/rust-macro-expand.cc (parse_many): Likewise.
(transcribe_type): Likewise.
* parse/rust-parse-impl.h (Parser::parse_crate): Likewise.
* rust-session-manager.cc (Session::handle_crate_name): Likewise.
* ast/rust-ast.cc (Module::load_items): Likewise.
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (MacroBuiltin::include_handler): Do not
return nullptr token in expansion of `include!()`
gcc/testsuite/ChangeLog:
* rust/compile/empty.in: New test.
* rust/compile/include_empty.rs: New test.
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc
(MacroBuiltin::include_str_handler): Add check for valid UTF-8.
gcc/testsuite/ChangeLog:
* rust/compile/builtin_macro_include_str.rs:
Include test of invalid UTF-8.
* rust/compile/invalid_utf8: File with invalid UTF-8.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
1847: Merge upstream, last commit before 2023-01-31 GCC/Rust upstreaming r=tschwinge a=tschwinge
Co-authored-by: Andrea Corallo <andrea.corallo@arm.com>
Co-authored-by: Richard Biener <rguenther@suse.de>
Co-authored-by: Srinath Parvathaneni <srinath.parvathaneni@arm.com>
Co-authored-by: Iain Sandoe <iain@sandoe.co.uk>
Co-authored-by: François Dumont <fdumont@gcc.gnu.org>
Co-authored-by: Jason Merrill <jason@redhat.com>
Co-authored-by: Harald Anlauf <anlauf@gmx.de>
Co-authored-by: Marek Polacek <polacek@redhat.com>
Co-authored-by: GCC Administrator <gccadmin@gcc.gnu.org>
Co-authored-by: Lulu Cheng <chenglulu@loongson.cn>
Co-authored-by: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Co-authored-by: Jakub Jelinek <jakub@redhat.com>
Co-authored-by: Eric Biggers <ebiggers@google.com>
Co-authored-by: Xianmiao Qu <cooper.qu@linux.alibaba.com>
Co-authored-by: Andre Vieira <andre.simoesdiasvieira@arm.com>
|
|
Conflicts:
gcc/rust/rust-gcc-diagnostics.cc
gcc/rust/typecheck/rust-hir-trait-ref.h
gcc/rust/typecheck/rust-hir-type-check-toplevel.cc
gcc/rust/typecheck/rust-hir-type-check-toplevel.h
gcc/rust/typecheck/rust-tyctx.cc
gcc/rust/typecheck/rust-tyty-rules.h
Upstream GCC commit r13-5197-g83ffe9cde7fe0b4deb0d1b54175fd9b19c38179c
"Update copyright years" did updated those files that don't exist in
GCC/Rust master branch anymore.
|
|
This commit changes our macro expansion system from an eager and recursive
macro expansion to a fixed-point like system. Instead of, when seeing
a macro invocation, expanding it and all of the macros within it, we
now perform multiple passes of expansion on the entire crate.
This, however, leads to a problem. Rust macros are expanded lazily, but
Rust builtin macros should be expanded eagerly. Due to this, we must
work around the lazy expansion in builtin macros and perform eager
expansion for each pass of the fixed-point, before finally expanding
the builtin when there are no longer any inner macro invocations.
To perform proper macro scoping, the ENR now keeps track of the current
scope (`current_scope` member) and resolves macros accordingly.
This is done through the use of the `scoped` method, which creates a new
scope, runs a specified lambda and then exits the scope. This prevents
pushing/popping errors that we've seen happen already in similar
contexts.
We might think about generalizing it to other classes, providing a
`Scoped<EntryFn, ExitFn>` class or similar
gcc/rust/ChangeLog:
* ast/rust-macro.cc: New file.
* Make-lang.in: Add `rust-macro.o` object
* ast/rust-ast-fragment.cc (Fragment::Fragment): Change API around
the construction of AST fragments.
(Fragment::operator=): Correct `Fragment::operator=` to take into
account the fragment tokens.
(Fragment::create_error): Use new constructor.
(Fragment::complete): Remove in favor of new constructor.
(Fragment::unexpanded): Remove as that Fragment type is no longer used
or possible.
(Fragment::get_tokens): Add helper to access a fragment's tokens.
* ast/rust-ast-fragment.h (enum class): Remove `FragmentKind::Unused`
* ast/rust-ast.cc (MacroInvocation::as_string): Display
builtin macro invocations properly.
* ast/rust-ast.h: Fix `DelimTokenTree` class copy constructors and
handling of its token vector.
* ast/rust-macro.h (class MacroMatcher): Format.
(class MetaItemSeq): Likewise.
(builtin_macro_from_string): Get a `BuiltinMacroKind` from a given
string, i.e the name of the macro (`assert!`, `cfg!` and so on).
* expand/rust-attribute-visitor.cc (AttrVisitor::visit): Do not expand
macros recursively anymore.
(AttrVisitor::maybe_expand_expr): Likewise.
(AttrVisitor::maybe_expand_type): Likewise.
* expand/rust-attribute-visitor.h: Likewise, and remove
`expand_macro_fragment_recursively` function.
* expand/rust-macro-builtins.cc (make_token): Add shorthand for
returning `std::unique_ptr<AST::Token>`s.
(make_macro_invocation): Add shorthand for returning fragments
containing builtin macro invocations.
(try_expand_macro_expression): Do not expand macros recursively.
(try_expand_single_string_literal): Likewise.
(try_expand_many_expr): Likewise.
(parse_single_string_literal): Error out more appropriately.
(MacroBuiltin::file_handler): Return the proper tokens associated with
macro invocation, and builtin macros in the case of necessary eager
expansion.
(MacroBuiltin::column_handler): Likewise.
(MacroBuiltin::include_bytes_handler): Likewise.
(MacroBuiltin::include_str_handler): Likewise.
(MacroBuiltin::concat_handler): Likewise.
(MacroBuiltin::env_handler): Likewise.
(MacroBuiltin::cfg_handler): Likewise.
(MacroBuiltin::include_handler): Likewise.
(MacroBuiltin::line_handler): Likewise.
* expand/rust-macro-expand.cc (MacroExpander::expand_eager_invocations):
Add function to expand eager invocations *once* in the fixed point
pipeline.
(MacroExpander::expand_invoc): Call into `expand_eager_invocations` for
builtin macro invocations.
(MacroExpander::expand_crate): Use new `AttrVisitor` API.
(parse_many): Return tokens in `AST::Fragment`.
(transcribe_expression): Likewise.
(transcribe_type): Likewise.
* expand/rust-macro-expand.h (struct MacroExpander): Add `has_changed`
flag for fixed point checking.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::EarlyNameResolver):
Keep track of the current macro scope.
(EarlyNameResolver::go): Use `scoped` API.
(EarlyNameResolver::visit): Likewise.
* resolve/rust-early-name-resolver.h: Add `scoped` API.
* rust-session-manager.cc (Session::expansion): Perform macro expansion
in a fixed-point fashion.
gcc/testsuite/ChangeLog:
* rust/compile/macro17.rs: Fix testsuite for new recursion errors.
* rust/compile/macro44.rs: Fix invalid testcase assertions.
* rust/compile/builtin_macro_recurse.rs: Fix invalid test.
* rust/compile/builtin_macro_recurse2.rs: New test.
* rust/compile/macro46.rs: New test.
|
|
This commit turns AST::MacroInvocation into a sum type.
The class can now represent a regular macro invocation (lazily expanded)
or a builtin one (eagerly expanded)
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (make_macro_invocation): Add short hand
function for returning fragments containing macro invocations.
(MacroBuiltin::compile_error_handler): Add explanation for eager
invocation
|
|
|