aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-macro.h
diff options
context:
space:
mode:
authorSimplyTheOther <simplytheother@gmail.com>2021-01-08 15:08:14 +0800
committerSimplyTheOther <simplytheother@gmail.com>2021-01-08 15:08:14 +0800
commitb5f86dca7e6b53ca3701ef01ae36070a760dff78 (patch)
tree9068741ba3ed05bafa7ad98989881198618e28b1 /gcc/rust/ast/rust-macro.h
parentfaf78e75e4ec3c989e452d47dc37a0be1706bf08 (diff)
downloadgcc-b5f86dca7e6b53ca3701ef01ae36070a760dff78.zip
gcc-b5f86dca7e6b53ca3701ef01ae36070a760dff78.tar.gz
gcc-b5f86dca7e6b53ca3701ef01ae36070a760dff78.tar.bz2
Added final to some overriden methods for optimisation, planned macro parsing
Diffstat (limited to 'gcc/rust/ast/rust-macro.h')
-rw-r--r--gcc/rust/ast/rust-macro.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h
index b0f4956..b5fb858 100644
--- a/gcc/rust/ast/rust-macro.h
+++ b/gcc/rust/ast/rust-macro.h
@@ -316,6 +316,12 @@ class MacroRulesDefinition : public MacroItem
Location locus;
+ /* NOTE: in rustc, macro definitions are considered (and parsed as) a type
+ * of macro, whereas here they are considered part of the language itself.
+ * I am not aware of the implications of this decision. The rustc spec does
+ * mention that using the same parser for macro definitions and invocations
+ * is "extremely self-referential and non-intuitive". */
+
public:
std::string as_string () const override;
@@ -388,21 +394,26 @@ public:
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
- MacroInvocation *clone_pattern_impl () const override
+ MacroInvocation *clone_pattern_impl () const final override
{
- return new MacroInvocation (*this);
+ return clone_macro_invocation_impl ();
}
/* Use covariance to implement clone function as returning this object rather
* than base */
- MacroInvocation *clone_expr_without_block_impl () const override
+ MacroInvocation *clone_expr_without_block_impl () const final override
{
- return new MacroInvocation (*this);
+ return clone_macro_invocation_impl ();
}
/* Use covariance to implement clone function as returning this object rather
* than base */
- MacroInvocation *clone_type_no_bounds_impl () const override
+ MacroInvocation *clone_type_no_bounds_impl () const final override
+ {
+ return clone_macro_invocation_impl ();
+ }
+
+ /*virtual*/ MacroInvocation *clone_macro_invocation_impl () const
{
return new MacroInvocation (*this);
}