[PATCH][RFC] Transition C++ FE to use TRANSLATION_UNIT_DECL context for globals
Richard Guenther
rguenther@suse.de
Fri Sep 24 19:57:00 GMT 2010
On Fri, 24 Sep 2010, Jakub Jelinek wrote:
> On Fri, Sep 24, 2010 at 05:12:15PM +0200, Richard Guenther wrote:
> > On Fri, 24 Sep 2010, Jason Merrill wrote:
> >
> > > On 09/24/2010 10:40 AM, Richard Guenther wrote:
> > > >
> > > > This is a start at using TRANSLATION_UNIT_DECL for DECL_CONTEXT of
> > > > file-scope entities. The idea is to make the translation-unit decl
> > > > the context of global_namespace and adjust FROB_CONTEXT accordingly.
> > > > And then deal with the fallout (which the following patch only
> > > > partially does).
> > > >
> > > > Is that approach ok in general? If so I'll continue fixing whatever
> > > > the testsuite and bootstrap catches.
> > >
> > > Rather than start setting *_CONTEXT of file-scope entities to the
> > > TRANSLATION_UNIT_DECL, it seems like we might as well just set it to
> > > global_namespace so we can do away with CP_*_CONTEXT and simplify logic. And
> > > then maybe mark global_namespace as DECL_IGNORED_P or just have the debug
> > > backends know that a namespace immediately inside the TRANSLATION_UNIT_DECL
> > > doesn't need to be represented.
> >
> > That would need adjustment to the middle-end DECL_FILE_SCOPE_P which
> > would need to recognize this case specially as well. But yes, it seems
> > easier for the C++ frontend (but likely causes a similar amount of
> > fallout).
>
> Would that global_namespace be changed for TRANSLATION_UNIT_DECL during LTO
> streaming out though? If we start emitting different DW_TAG_compile_unit
> DIEs for different source code TUs for LTO, I think the debuggers would be
> interested to know whether
> int foo = 6;
> was defined in foo.cc or bar.cc.
No, but it would still have a TRANSLATION_UNIT_DECL as DECL_CONTEXT.
Which means that we still need CP_DECL_CONTEXT, now being sth like
#define CP_DECL_CONTEXT(NODE) \
(TREE_CODE (DECL_CONTEXT (NODE)) == TRANSLATION_UNIT_DECL \
? global_namespace : DECL_CONTEXT (NODE))
Richard.
More information about the Gcc-patches
mailing list