[cfe-dev] Inherited members/functions in CXXRecordDecl

David Blaikie via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 16 09:09:48 PST 2016


On Wed, Nov 16, 2016 at 6:24 AM David Come via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> I'm a a bit puzzled. Because clang  has to know about these attributes
> later on (for looking up the symbol if used, or when computing the class
> size).
>
> it means somewhere it's done, I don't know where =/
>
I'm not sure I follow - it does know about them, by walking through the
base classes and looking at their members.

If you want to see where that walk is - try calling a function that doesn't
exist, break at the code where the warning is emitted, then follow the
logic that lead to that point as it walks the parent looking for names.

Also - if you're looking for record layout (how it knows which bytes to use
for which members) you could look in codegen for that to see how it lays
out the struct, walking all the members of the bases.

>
>

> Thanks.
>
> David
>
>
> On 15/11/2016 15:30, David Blaikie wrote:
>
> I would expect you'd have to look at the base class, yes - the AST is, at
> least somewhat, a syntax tree, representing the code as written.
>
> On Tue, Nov 15, 2016 at 2:41 AM David Come via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
>
> Hello,
>
>
> I'm using clang and libtooling 3.9 to parse some C++ code.
>
> With the following snippet :
>
> struct A0  {
>    char* p;
>    void Z();
> };
> struct A : A0{
>    const int i;
>    volatile double g;
> protected:
>    void f(){};
> };
>
> When iterating over fields and methods on A's CXXRecordDecl in my visitor,
>
> I only get fields i and g ; and method f. I completely miss p and Z.
>
>
> Is this normal ? How can I get them when looking at A's CXXRecordDecl ?
> Do I have to iterate over A base classes and add A0's public/protected
> members ?
>
>
> Thanks.
>
> David Come
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
> _______________________________________________
> 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/20161116/c066dd49/attachment.html>


More information about the cfe-dev mailing list