[cfe-dev] Inheritance Information in Debug Information

David Blaikie via cfe-dev cfe-dev at lists.llvm.org
Fri Feb 24 08:15:19 PST 2017


Note that the TwoVirtual, NoSubOrSuper, and OneSuper types are all emitted
as declarations - so no inheritance information is provided in that case
(nor any member variables/functions, byte size, etc). This is a debug
information size optimization (GCC does a similar one) based on the
assumption that the whole program will be built with debug info, and in
that case some other file (the file with the 'key function' for each type)
so it doesn't need to be duplicated here.

If you want to disable that optimization, you can pass -fstandalone-debug
(this tells the compiler not to assume that any other part of the program
is built with debug info) - but it increases the size of the debug info
quite a bit.

(note that -femit-all-decls doesn't apply to debug info (ie: an unused type
will still not be emitted into the metadata/DWARF) GCC's -gfull would be
the right tool for this but it's not implemented in LLVM/Clang)

What are you trying to do with this information?

On Thu, Feb 23, 2017 at 3:52 PM Jon Eyolfson via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hello, I'm trying to understand why I'm not getting all the inheritance
> information for the following example:
>
>     class TwoVirtual {
>     public:
>       virtual void foo();
>       virtual void bar() const;
>     };
>
>     class TwoImpl : public TwoVirtual {
>       TwoImpl() {}
>     public:
>       virtual void foo() {}
>       virtual void bar() const {}
>     };
>
>     class NoSubOrSuper {
>       TwoImpl t;
>       void baz() {}
>     };
>
>     class OneSuper : public TwoImpl {
>       void baz() {}
>     };
>
> I'm generating llvm code with the following command:
>
>     clang++ -std=c++14 -g -O1 -Xclang -disable-llvm-optzns -emit-llvm
>             -femit-all-decls -S -c TestFile.cpp -o TestFile.ll
>
> I'm using -O1 because I need TBAA information present.
>
> What I get is only one DIDerivedType with the DW_TAG_inheritance tag.
> This connects TwoImpl to TwoVirtual. However there isnt an inheritance
> tag between OneSuper and TwoImpl. Is there a reason for this? I'm trying
> to determine in the llvm code that NoSubOrSuper and OneSuper are different
> (on has an inheritance relation and the other doesn't). Thanks!
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170224/2a9239eb/attachment.html>


More information about the cfe-dev mailing list