From: Christopher Li <sparse@chrisli.org>
To: Sergey Lapin <slapinid@gmail.com>
Cc: linux-sparse@vger.kernel.org
Subject: Re: building of call tree
Date: Fri, 2 Apr 2010 10:55:19 -0700 [thread overview]
Message-ID: <y2v70318cbf1004021055i2aa4ec82h1d6b2f43a2af01d0@mail.gmail.com> (raw)
In-Reply-To: <k2u48239d391004020916w712535dala168de2a6d2b2bf7@mail.gmail.com>
On Fri, Apr 2, 2010 at 9:16 AM, Sergey Lapin <slapinid@gmail.com> wrote:
> but I fail with scoping. I need to detect which function that
> particular reference belongs to,
> and how to detect if that reference is really a function.
What do you mean by "reference"? If you mean the struct symbol *
in the AST. It can point to the function prototype or declaration. It is easy to
find out the symbol is a function or not.
Some thing along the lines of :
if (sym->type == SYM_NODE)
sym = sym->ctype.base_type
if (sym && sym->type = SYM_FN) {
/* sym is a function */
}
> sym->type isn't what I need, sym->ctype.base_type is used to print base type,
> but I'd like to print type as is, and detect if that is a function a proper way.
You need understand that, each local variable or function start with a SYM_NODE.
SYM_NODE bind a type to a instance of the type. e.g. a variable.
A function is just a SYM_NODE with base type as SYM_FN.
You can also try debug_symbol(), see how it print out the function prototype.
I am about to post a AST inspection patch series. That tool should
help you understand
the AST as well. Stay tuned.
Chris
prev parent reply other threads:[~2010-04-02 17:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-02 16:16 building of call tree Sergey Lapin
2010-04-02 17:55 ` Christopher Li [this message]
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=y2v70318cbf1004021055i2aa4ec82h1d6b2f43a2af01d0@mail.gmail.com \
--to=sparse@chrisli.org \
--cc=linux-sparse@vger.kernel.org \
--cc=slapinid@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 NNTP newsgroup(s).