From: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
To: Shuai Wang <wangshuai901@gmail.com>
Cc: GCC Development <gcc@gcc.gnu.org>
Subject: Re: How to decide the what type is currently being used in tree_node?
Date: Fri, 19 Feb 2021 14:24:11 +0530 [thread overview]
Message-ID: <CAAgBjM=L4njx5xMYTP9ouMP5RCgVVgN6_fVUT4dQRWWcd3JCwQ@mail.gmail.com> (raw)
In-Reply-To: <CAEQMQomk6rGC=+XyAnLnY4hQ_AAA+nzAPFSfAFfVQbAeqzJqKQ@mail.gmail.com>
On Fri, 19 Feb 2021 at 10:31, Shuai Wang via Gcc <gcc@gcc.gnu.org> wrote:
>
> Hello,
>
> I noticed that tree_node is implemented as a union (
> https://code.woboq.org/gcc/gcc/tree-core.h.html#tree_node). However, I
> cannot find a way of checking whether the current tree_node is really a
> base or type.
>
> For instance, currently when I am using:
>
> is_gimple_constant(v)
>
> Given `v` as a tree type but NOT base type, the above statement would
> crash. I am thinking there should be a method like:
>
> is_tree_base(v) == false
>
> or something like this; however, I couldn't find one. Can anyone shed some
> lights on this? Thank you very much!
If you want to ascertain which class the tree node belongs to, you can
use either TREE_CODE, or one of the _P macros
defined in tree.h. If you use an accessor that needs tree node
belonging to a certain class, then you need to check for it before
hand.
For example before using DECL_NAME on a tree node, you need to
explicitly check if it's indeed a decl_node using DECL_P.
For is_gimple_constant(v), it will return true if v is a one of the
constant nodes (*_CST), and false otherwise, so I don't see how it
will crash if you
pass a non-constant node ?
Thanks,
Prathamesh
>
> best,
> Shuai
next prev parent reply other threads:[~2021-02-19 8:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-19 5:01 Shuai Wang
2021-02-19 8:54 ` Prathamesh Kulkarni [this message]
2021-02-19 14:54 ` Shuai Wang
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='CAAgBjM=L4njx5xMYTP9ouMP5RCgVVgN6_fVUT4dQRWWcd3JCwQ@mail.gmail.com' \
--to=prathamesh.kulkarni@linaro.org \
--cc=gcc@gcc.gnu.org \
--cc=wangshuai901@gmail.com \
/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: link
Be 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).