In the following code:
classA{
public:
A();
A(A const&a);
A(inti);
};
voidf(A a);
voidg() {
A a;
f(a); // 1
f(2); // 2
}
The generated AST contains nodes about object construction that are implicit (the copy constructor for 1, the conversion then the copy constructor for 2).
>\-CallExpr <line:12:5, col:8> 'void'
> >\-ImplicitCastExpr <col:5> 'void \(\*\)\(A\)' <FunctionToPointerDecay>
> > \`\-DeclRefExpr <col:5> 'void \(A\)' lvalue Function 0x55c42589b208 'f' 'void \(A\)'
> \`\-CXXConstructExpr <col:7> 'A' 'void \(const A &\)'
> \`\-ImplicitCastExpr <col:7> 'const A' lvalue <NoOp>
> \`\-DeclRefExpr <col:7> 'A' lvalue Var 0x55c42589b3c8 'a' 'A'
\`\-ExprWithCleanups <line:13:5, col:8> 'void'
\`\-CallExpr <col:5, col:8> 'void'
>\-ImplicitCastExpr <col:5> 'void \(\*\)\(A\)' <FunctionToPointerDecay>
> \`\-DeclRefExpr <col:5> 'void \(A\)' lvalue Function 0x55c42589b208 'f' 'void \(A\)'
\`\-CXXConstructExpr <col:7> 'A' 'void \(const A &\)' elidable
\`\-MaterializeTemporaryExpr <col:7> 'const A' lvalue
\`\-ImplicitCastExpr <col:7> 'const A' <NoOp>
\`\-ImplicitCastExpr <col:7> 'A' <ConstructorConversion>
\`\-CXXConstructExpr <col:7> 'A' 'void \(int\)'
\`\-IntegerLiteral <col:7> 'int' 2
Do you know if there is a way to detect that these constructions are implicit (as opposed to constructions written as the type name followed by initialization?)
Thank you!