This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++: Tag transparent binding contour


On Fri, 2003-09-19 at 15:00, Gabriel Dos Reis wrote:
> Devang Patel <dpatel@apple.com> writes:
> 
> | Patch for debugging info, which is related to this transparent
> | tag discussion
> | 
> | http://gcc.gnu.org/ml/gcc-patches/2003-07/msg02422.html
> | 
> | If we get rid off transparent binding levels and handle cleanup
> | using other techniques, then we don't need it.
> 
> Aha, it seems liek that is make the case for Mark's approach.  Maybe
> we could do this in two stages: (1) replace the tag-transparent and
> keep == 2 hack with a sk_cleanup binding coutour/scope; (2) figure out
> a better structure to handle that stuff.

Yes.  

The problem Devang is trying to fix is the kind of thing that happens
when you have the wrong data structures in play -- there's no C++ scope
that begins with a label, and so now binding_level is overloaded in a
confusing way.  There's already a bunch of code in decl.c that looks
through these "imaginary" scopes.

I don't object to sk_cleanup, but we really should try to find a better
way to do that.

In response to Jason's comment that:

> I suppose it could, but then you'd need to introduce some other data
> structure to track when this is needed.

I would guess that we could do something like this:

(1) For each binding level, keep a counter indicating how many open
SCOPE_STMTS are in the binding level.  Also, have a bit indicating
whether or not we have seen a label in this binding level, but have not
yet seen a variable requiring cleanup after the label.

(2) When you see a label, set the bit.

(3) If the bit is set, and you see a variable requiring a cleanup,
insert a SCOPE_STMT, clear the bit, and increment the counter.

(4) When poplevel is called for the scope, create as many SCOPE_STMTs as
there are counters.

For brownie points, do not always create a SCOPE_STMT in do_pushlevel. 
Just set the bit above.  Then, if nothing with a cleanup is ever seen,
you will never create the SCOPE_STMTs.  This will make the compiler go
faster and use less memory.
 
-- 
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]