[cfe-dev] Inheritance Information in Debug Information

Jon Eyolfson via cfe-dev cfe-dev at lists.llvm.org
Fri Feb 24 08:59:53 PST 2017


Great, thanks a lot for the reply! That seems to do the trick for now. It's a
shame about -gfull though, is there just really no use for it?

I'm using this information to create a class heirarchy for an LLVM static
analysis. I need to use LLVM for the static analysis part but it seems like all
of the class heirarchy information from clang is stripped away by then. So I'm
using debugging information to re-create the class heirarchy.

Thanks!

On Fri, Feb 24, 2017 at 04:15:19PM +0000, David Blaikie wrote:
> 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
> >



More information about the cfe-dev mailing list