[cfe-users] Implicit or explicit public inheritance in the AST

2020-06-08 Thread Csaba Raduly via cfe-users
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  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:8 implicit struct B
|-CXXRecordDecl 0x8000bdef8  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:8 implicit struct D1
`-CXXRecordDecl 0x80015c918  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: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
Sent from my 12-core Windows machine, using Gmail.
-- 
You can get very substantial performance improvements
by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler
So if you're looking for a completely portable, 100% standards-conformant
way
to get the wrong information: this is what you want. - Scott Meyers
(C++TDaWYK)
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] Implicit or explicit public inheritance in the AST

2020-06-08 Thread David Blaikie via cfe-users
Looks like comparing getAccessSpecifierAsWritten with
getAccessSpecifier might help:
https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html#a6abcd6d5d707f4cab88bab1fc916bfad

On Mon, Jun 8, 2020 at 1:09 PM Csaba Raduly via cfe-users
 wrote:
>
> 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  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:8 implicit struct B
> |-CXXRecordDecl 0x8000bdef8  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:8 implicit struct D1
> `-CXXRecordDecl 0x80015c918  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: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
> Sent from my 12-core Windows machine, using Gmail.
> --
> You can get very substantial performance improvements
> by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler
> So if you're looking for a completely portable, 100% standards-conformant way
> to get the wrong information: this is what you want. - Scott Meyers 
> (C++TDaWYK)
> ___
> cfe-users mailing list
> cfe-users@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users