Hi all,
If I run clang++ -std=c++17 -Xclang -ast-dump
on the following code:
struct B {};
struct D1 : B {};
struct D2 : public B {};
the output is
-CXXRecordDecl 0x8000bdd48 <kg.cpp:1:1, col:11> col:8 referenced struct B definition
-DefinitionData pass_in_registers empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init
-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr
-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
-MoveConstructor exists simple trivial needs_implicit
-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param
-MoveAssignment exists simple trivial needs_implicit
-Destructor simple irrelevant trivial needs_implicit
-CXXRecordDecl 0x8000bde58 <col:1, col:8> col:8 implicit struct B
-CXXRecordDecl 0x8000bdef8 <line:3:1, col:16> col:8 struct D1 definition
-DefinitionData pass_in_registers empty aggregate standard_layout trivially_copyable trivial literal has_constexpr_non_copy_move_ctor can_const_default_init
-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr
-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
-MoveConstructor exists simple trivial needs_implicit
-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param
-MoveAssignment exists simple trivial needs_implicit
-Destructor simple irrelevant trivial needs_implicit -public 'B'
-CXXRecordDecl 0x80015c878 <col:1, col:8> col:8 implicit struct D1
-CXXRecordDecl 0x80015c918 <line:5:1, col:23> col:8 struct D2 definition -DefinitionData pass_in_registers empty aggregate standard_layout trivially_copyable trivial literal has_constexpr_non_copy_move_ctor can_const_default_init -DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr -CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param -MoveConstructor exists simple trivial needs_implicit -CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param -MoveAssignment exists simple trivial needs_implicit
-Destructor simple irrelevant trivial needs_implicit
-public ‘B’
`-CXXRecordDecl 0x80015ca68 <col:1, col:8> col:8 implicit struct D2
I can see no difference between the CXXRecordDecl for D1 and D2. Is there a way to tell, when visiting the AST, whether the inheritance of the derived class was specified implicitly or explicitly? (Hopefully yes, just not visible in the output of ast-dump).
Csaba