[cfe-dev] What code generates default constructors?

Bruno Ricci via cfe-dev cfe-dev at lists.llvm.org
Tue Jan 22 05:17:17 PST 2019


I am not sure I understand the question, but in general one way I found to be
useful to know what piece of code creates which AST node is to grep for 
eg: StringLiteral::Create, or StringLiteral and new. In this case what you are
looking for is CXXConstructorDecl::Create, which gives a few matches.

In particular Sema::DeclareImplicitDefaultConstructor seems to be what you want.
The other matches in SemaDeclCXX are for the other implicitely declared constructors.

Bruno

On 22/01/2019 11:48, Gregory Malecha via cfe-dev wrote:
> Hello --
> 
> I'm trying to understand how ASTs for constructors are generated when they are referenced. In particular, I'm working on a libtooling tool that will dump the AST to another format on a per-file basis so I need to know the code for any constructors even if they are not called in the file.
> 
> Very concretely, if I write the following code:
> 
> class P {};
> int main() {
>    P x;
>    return 0;
> }
> 
> the result of -ast-dump will contain the implementation of the default constructor (not very interesting in this case). What code generates this?
> 
> Thank you.
> 
> -- 
> gregory malecha
> gmalecha.github.io <https://gmalecha.github.io>
> 
> _______________________________________________
> 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