On Thu, Aug 28, 2014 at 10:14 PM, Jason Merrill <ja...@redhat.com> wrote: > On 08/28/2014 03:13 PM, Richard Biener wrote: >>>> >>>> knowledge of scopes and such, only available in the FE. Is there a >>>> generic way of determining if a DECL is in global scope? >> >> >> Via DECL_CONTEXT and the global scope macro predicate. Eventually not >> enough to detect class scope statics. > > > !decl_function_context should do the trick.
Yeah, that might work. But I suppose we want proper ordering even for a namespace hierarchy, that is, output dwarf for the namespace which will output its siblings. That is, dwarf2out.c currently kind-of supports both, first create DIEs for the context which will usually create DIEs for its siblings or first create siblings which will either end up in the limbo-list or get a context DIE via force_decl/type_die (see get_context_die). IMHO the best would be to create DIEs top-down controlled by frontends and also populate context DIEs from the frontends and not by walking some sibling list from dwarf2out.c. Frontends already "announce" some types/decls to dwarf2out.c by means of calling rest_of_decl_compilation or rest_of_type_compilation (only for TYPE_DECLs). So it's mostly a matter of adding similar calls for scopes and global decls. The calls should be debug_hook calls of course, not these weird rest_of_*_compilation stuff. Richard. > Jason >