[LLVMdev] Debug info for namespaces and "using"
Robinson, Paul
Paul.Robinson at am.sony.com
Wed Mar 20 10:59:43 PDT 2013
I've noticed the work going on to support namespace and "using" directives.
Awesome that this is happening, I've had a couple users wonder about it.
(The main issue actually seems to be with anonymous namespaces; gdb will
auto-import those declarations, but our debugger doesn't.)
I thought I should also bring up another aspect of how Clang/LLVM handles
namespaces, in case you hadn't noticed. If you have something like this:
namespace MYSPACE {
typedef int MYINT;
};
// ... other stuff
namespace MYSPACE {
typedef long MYLONG;
};
then Clang will emit two separate DW_TAG_namespace DIEs, one with a
child MYINT and one with a child MYLONG. However, these namespace DIEs
are not connected by DW_AT_extension, so a "using namespace MYSPACE;"
that emits a single DW_TAG_imported_module isn't going to catch both
namespace DIEs.
I looked at gcc, and an EDG-based compiler; they collect all the
declarations for a given namespace and put them out under a single
DW_TAG_namespace DIE, regardless of how many fragments there are in
the source. That way, one DW_TAG_imported_module will catch everything
(even declarations that come after the "using namespace" lexically,
which matches how [namespace.udir]p5 works).
So, if Clang is going to use DW_AT_extension to connect separate DIEs,
the DW_TAG_imported_module will have to specify the last one in the
chain; or, Clang will need to collect these declarations so they can
all be emitted under a single namespace DIE.
Make sense?
--paulr
More information about the llvm-dev
mailing list