public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] Add get_locus function for abstract class MetaItemInner. Date: Thu, 12 Jan 2023 07:45:15 +0000 (GMT) [thread overview] Message-ID: <20230112074515.3525F385B508@sourceware.org> (raw) https://gcc.gnu.org/g:84009909526bec9f6a07b94b4df187f57b692b9c commit 84009909526bec9f6a07b94b4df187f57b692b9c Author: mxlol233 <mxlol233@outlook.com> Date: Wed Jan 11 23:24:07 2023 +0800 Add get_locus function for abstract class MetaItemInner. This commit adds virtual function get_locus to base class MetaItemInner, which is helpful when we need to print diagnostics on some sub-classes of MetaItemInner. Signed-off-by: Xiao Ma <mxlol233@outlook.com> Diff: --- gcc/rust/ast/rust-ast.h | 2 ++ gcc/rust/ast/rust-expr.h | 8 ++++++++ gcc/rust/ast/rust-macro.h | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 1539e78f01b..6ec2841cd08 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -630,6 +630,8 @@ public: virtual ~MetaItemInner (); + virtual Location get_locus () const = 0; + virtual std::string as_string () const = 0; virtual void accept_vis (ASTVisitor &vis) = 0; diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index c58fae5e564..34bc6993ab6 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -150,6 +150,8 @@ public: std::string as_string () const override { return lit_expr.as_string (); } + Location get_locus () const override { return lit_expr.get_locus (); } + void accept_vis (ASTVisitor &vis) override; bool check_cfg_predicate (const Session &session) const override; @@ -178,6 +180,12 @@ public: return path.as_string () + " = " + lit.as_string (); } + // There are two Locations in MetaItemPathLit (path and lit_expr), + // we have no idea use which of them, just simply return UNKNOWN_LOCATION + // now. + // Maybe we will figure out when we really need the location in the future. + Location get_locus () const override { return Location (UNKNOWN_LOCATION); } + void accept_vis (ASTVisitor &vis) override; bool check_cfg_predicate (const Session &session) const override; diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h index 52c7efb5d1b..33a250ed84a 100644 --- a/gcc/rust/ast/rust-macro.h +++ b/gcc/rust/ast/rust-macro.h @@ -725,6 +725,8 @@ public: return path; } + Location get_locus () const override { return path.get_locus (); } + bool check_cfg_predicate (const Session &session) const override; Attribute to_attribute () const override; @@ -778,6 +780,8 @@ public: void accept_vis (ASTVisitor &vis) override; + Location get_locus () const override { return path.get_locus (); } + bool check_cfg_predicate (const Session &session) const override; Attribute to_attribute () const override; @@ -805,6 +809,8 @@ public: void accept_vis (ASTVisitor &vis) override; + Location get_locus () const override { return ident_locus; } + bool check_cfg_predicate (const Session &session) const override; Attribute to_attribute () const override; @@ -847,6 +853,8 @@ public: return std::unique_ptr<MetaNameValueStr> (clone_meta_item_inner_impl ()); } + Location get_locus () const override { return ident_locus; } + bool check_cfg_predicate (const Session &session) const override; Attribute to_attribute () const override; @@ -885,6 +893,8 @@ public: void accept_vis (ASTVisitor &vis) override; + Location get_locus () const override { return ident_locus; } + bool check_cfg_predicate (const Session &session) const override; Attribute to_attribute () const override; @@ -919,6 +929,8 @@ public: void accept_vis (ASTVisitor &vis) override; + Location get_locus () const override { return ident_locus; } + bool check_cfg_predicate (const Session &session) const override; Attribute to_attribute () const override;
reply other threads:[~2023-01-12 7:45 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230112074515.3525F385B508@sourceware.org \ --to=tschwinge@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).