diff options
author | M V V S Manoj Kumar <mvvsmanojkumar@gmail.com> | 2021-11-20 08:01:36 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-20 08:01:36 +0530 |
commit | 73a0903c156f86e1e59c30c542780fe2162438d4 (patch) | |
tree | d608a5ee3f316d63f259113ae7fed2da4149a6ce /gcc/rust/ast | |
parent | 9c4e3db7789dc32ae08a2302b13c2772f51d5bea (diff) | |
parent | fece068309e8a3cbeb81539fba14e1c970740a94 (diff) | |
download | gcc-73a0903c156f86e1e59c30c542780fe2162438d4.zip gcc-73a0903c156f86e1e59c30c542780fe2162438d4.tar.gz gcc-73a0903c156f86e1e59c30c542780fe2162438d4.tar.bz2 |
Merge branch 'Rust-GCC:master' into master
Diffstat (limited to 'gcc/rust/ast')
-rw-r--r-- | gcc/rust/ast/rust-ast.h | 19 | ||||
-rw-r--r-- | gcc/rust/ast/rust-expr.h | 15 |
2 files changed, 27 insertions, 7 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 72f2609..05779e7 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -542,6 +542,13 @@ protected: class AttrInput { public: + enum AttrInputType + { + LITERAL, + META_ITEM, + TOKEN_TREE, + }; + virtual ~AttrInput () {} // Unique pointer custom clone function @@ -564,6 +571,8 @@ public: // Returns whether attr input has been parsed to meta item syntax. virtual bool is_meta_item () const = 0; + virtual AttrInputType get_attr_input_type () const = 0; + protected: // pure virtual clone implementation virtual AttrInput *clone_attr_input_impl () const = 0; @@ -650,6 +659,11 @@ public: bool check_cfg_predicate (const Session &session) const override; + AttrInputType get_attr_input_type () const final override + { + return AttrInput::AttrInputType::META_ITEM; + } + // Clones this object. std::unique_ptr<AttrInputMetaItemContainer> clone_attr_input_meta_item_container () const @@ -767,6 +781,11 @@ public: } bool is_meta_item () const override { return false; } + + AttrInputType get_attr_input_type () const final override + { + return AttrInput::AttrInputType::TOKEN_TREE; + } }; /* Forward decl - definition moved to rust-expr.h as it requires LiteralExpr to diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index 05c78b7..3463f5a 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -102,13 +102,7 @@ protected: // Literal expression attribute body (non-macro attribute) class AttrInputLiteral : public AttrInput { - // Literal expression WITHOUT SUFFIX - // std::unique_ptr<LiteralExpr> literal_expr; - LiteralExpr - literal_expr; // as not using polymorphic behaviour, doesn't require pointer - // TODO: will require pointer if LiteralExpr is changed to have subclassing - - // TODO: should this store location data? + LiteralExpr literal_expr; public: AttrInputLiteral (LiteralExpr lit_expr) : literal_expr (std::move (lit_expr)) @@ -127,6 +121,13 @@ public: bool is_meta_item () const override { return false; } + LiteralExpr &get_literal () { return literal_expr; } + + AttrInputType get_attr_input_type () const final override + { + return AttrInput::AttrInputType::LITERAL; + } + protected: /* Use covariance to implement clone function as returning this object rather * than base */ |