[cfe-dev] Detecting implicit constructor calls

Nico Weber thakis at chromium.org
Mon Nov 22 07:50:48 PST 2010


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.

Nico

On Fri, Nov 5, 2010 at 4:36 PM, Nico Weber <thakis at chromium.org> wrote:
> Now that the conference is over: Ping :-)
>
> On Tue, Nov 2, 2010 at 1:45 AM, Nico Weber <thakis at chromium.org> wrote:
>> Hi,
>>
>> I'm trying to write a rewriter that turns implicit constructor (`A a =
>> 4; f(4);`) calls into explicit constructor calls (`A a(4); f(A(4));`).
>> To find out if a constructor call is implicit, I check if the
>> CXXConstructExpr is wrapped in a ImplicitCastExpr. This works well,
>> except if the implicit conversion happens in a function parameter. In
>> that case, clang doesn't create an ImplicitCastExpr.
>>
>> Is this intentional? If not, the attached patch fixes this. It doesn't
>> regress any tests, and it makes clang's ASTs more consistent.
>>
>> If this is in fact intentional, what's a good way to check if a
>> constructor call is implicit?
>>
>> Thanks,
>> Nico
>>
>



More information about the cfe-dev mailing list