Inherited members/functions in CXXRecordDecl

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

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.

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 =/

Thanks.

David

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.