This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: What tree flags tell me a variable is local?
- From: Geoff Keating <geoffk at geoffk dot org>
- To: Daniel Berlin <dberlin at dberlin dot org>
- Cc: gcc at gcc dot gnu dot org
- Date: 14 Jun 2003 12:09:44 -0700
- Subject: Re: What tree flags tell me a variable is local?
- References: <4D1D062C-9E98-11D7-B489-000A95A34564@dberlin.org>
Daniel Berlin <dberlin@dberlin.org> writes:
> I know you can do it with decl_function_context, but I'm trying to
> avoid using it, because it's too expensive in PTA due to call overhead
> (Any time a query is made, we need to figure out whether they are
> querying about a global or not, so we end up calling it millions of
> times).
>
> Thus, i'm wondering if there is some combination of tree flags i can
> rely on to always be correct.
>
> Currently, I check DECL_CONTEXT, and iff it's a FUNCTION_DECL, we say
> it's local, otherwise, we call decl_function_context and see if it
> returns NULL.
>
>
> Is there a better way?
I presume that by 'local' you mean 'inside a function scope', not
'file-local' or 'automatic'?
No, there's no better way.
Why do you want to do this? I can't imagine what it might make a
difference for; surely
extern foo;
int bar(void) { ... }
is not different to
int bar(void) {
extern foo;
...
}
in any meaningful way.
--
- Geoffrey Keating <geoffk@geoffk.org>