diff options
author | SimplyTheOther <simplytheother@gmail.com> | 2020-10-29 22:11:41 +0800 |
---|---|---|
committer | SimplyTheOther <simplytheother@gmail.com> | 2020-12-08 21:10:18 +0800 |
commit | 69048af1878e95e26b57febb701f884f513c7b93 (patch) | |
tree | 553c3d302a1e9ebf668b7d1629e33b09a525fbbe /gcc/rust/ast/rust-ast.h | |
parent | 98d429466bf783ff1a7ac59bf800061d3e67061a (diff) | |
download | gcc-69048af1878e95e26b57febb701f884f513c7b93.zip gcc-69048af1878e95e26b57febb701f884f513c7b93.tar.gz gcc-69048af1878e95e26b57febb701f884f513c7b93.tar.bz2 |
Added cfg stripping for ExternalItems
Fixed non-renaming of has_variadic_outer_attrs()
Fixed old as_string function for ExternalItem
Fixed parse_named_function_param arguments
Diffstat (limited to 'gcc/rust/ast/rust-ast.h')
-rw-r--r-- | gcc/rust/ast/rust-ast.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 31c547a..4c4b043 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -1289,12 +1289,36 @@ public: virtual void accept_vis (ASTVisitor &vis) = 0; }; +// Abstract base class for an item used inside an extern block +class ExternalItem +{ +public: + virtual ~ExternalItem () {} + + // Unique pointer custom clone function + std::unique_ptr<ExternalItem> clone_external_item () const + { + return std::unique_ptr<ExternalItem> (clone_external_item_impl ()); + } + + virtual std::string as_string () const = 0; + + virtual void accept_vis (ASTVisitor &vis) = 0; + + virtual void mark_for_strip () = 0; + virtual bool is_marked_for_strip () const = 0; + +protected: + // Clone function implementation as pure virtual method + virtual ExternalItem *clone_external_item_impl () const = 0; +}; + /* A macro invocation item (or statement) AST node (i.e. semi-coloned macro * invocation) */ class MacroInvocationSemi : public MacroItem, public TraitItem, public InherentImplItem, - public TraitImplItem + public TraitImplItem, public ExternalItem { std::vector<Attribute> outer_attrs; SimplePath path; @@ -1394,6 +1418,13 @@ protected: { return clone_macro_invocation_semi_impl (); } + + /* Use covariance to implement clone function as returning this object rather + * than base */ + MacroInvocationSemi *clone_external_item_impl () const override + { + return clone_macro_invocation_semi_impl (); + } }; // A crate AST object - holds all the data for a single compilation unit |