aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-ast.h
diff options
context:
space:
mode:
authorSimplyTheOther <simplytheother@gmail.com>2020-10-05 22:23:06 +0800
committerSimplyTheOther <simplytheother@gmail.com>2020-12-08 21:10:13 +0800
commit423462fb6785896c8031319d50ac38fbca3afb51 (patch)
tree2189e0aefa07f55ade13bd052e9d852f3afdccfa /gcc/rust/ast/rust-ast.h
parente7cf2f7789dccbb1d8aac6222b2b1c0f4d5f18f6 (diff)
downloadgcc-423462fb6785896c8031319d50ac38fbca3afb51.zip
gcc-423462fb6785896c8031319d50ac38fbca3afb51.tar.gz
gcc-423462fb6785896c8031319d50ac38fbca3afb51.tar.bz2
Added proper cfg_attr expansion
Diffstat (limited to 'gcc/rust/ast/rust-ast.h')
-rw-r--r--gcc/rust/ast/rust-ast.h19
1 files changed, 6 insertions, 13 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index ad3722f..cfb5f9b 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -83,6 +83,8 @@ public:
// Parse attribute input to meta item, if possible
virtual AttrInput *parse_to_meta_item () const { return nullptr; }
+ virtual std::vector<Attribute> separate_cfg_attrs () const { return {}; }
+
protected:
// pure virtual clone implementation
virtual AttrInput *clone_attr_input_impl () const = 0;
@@ -590,20 +592,9 @@ public:
/* Determines whether cfg predicate is true and item with attribute should not
* be stripped. */
- bool check_cfg_predicate (const Session &session)
- {
- /* assume that cfg predicate actually can exist, i.e. attribute has cfg or
- * cfg_attr path */
-
- if (!has_attr_input ())
- return false;
+ bool check_cfg_predicate (const Session &session);
- // TODO: maybe replace with storing a "has been parsed" variable?
- parse_attr_to_meta_item ();
- // can't be const because of this anyway
-
- return attr_input->check_cfg_predicate (session);
- }
+ std::vector<Attribute> separate_cfg_attrs ();
protected:
// not virtual as currently no subclasses of Attribute, but could be in future
@@ -683,6 +674,8 @@ public:
clone_attr_input_meta_item_container_impl ());
}
+ std::vector<Attribute> separate_cfg_attrs () const override;
+
protected:
// Use covariance to implement clone function as returning this type
AttrInputMetaItemContainer *clone_attr_input_impl () const override