[cfe-dev] Detecting implicit constructor calls

John McCall rjmccall at apple.com
Mon Nov 22 12:49:02 PST 2010


On Nov 22, 2010, at 7:50 AM, Nico Weber wrote:
> andersca suggested on irc that I check if the SourceLocation of the
> construtor call is valid to check if its an implicit call or not. I
> finally got around to trying this: it doesn't work, implicit
> constructors get valid SourceLocations, too.
> 
> Are there other ways to get at this information with the current AST
> structure? If not, are there any comments on my patch? It makes the
> AST for function parameters consistent with the AST in other places.

Explicit calls like 'A(4)' should always be CXXTemporaryObjectExprs,
not just CXXConstructExprs.  Direct initializers like 'A x(4)' have
hasCXXDirectInitializer() set on the variable.

That said, I have no problem with adding the ImplicitCastExpr in this
case, although I haven't actually looked at your patch.

John.



More information about the cfe-dev mailing list