Missing info in AST for CXXConstructExpr

Larisse Voufo lvoufo at google.com
Wed Feb 4 14:10:24 PST 2015


On Thu, Jan 29, 2015 at 4:06 PM, Richard Smith <richard at metafoo.co.uk>
wrote:

> On Thu, Jan 29, 2015 at 2:24 AM, Abramo Bagnara <
> abramo.bagnara at bugseng.com> wrote:
>
>> Il 28/01/2015 23:07, Richard Smith ha scritto:
>> > Fixed in r227377.
>>
>> I'm not sure it is related to your commit, but trying to validate your
>> changes I've discovered a regression between r224592 and r227424.
>>
>> For the source:
>>
>> #include <initializer_list>
>>
>> typedef std::initializer_list<bool> T;
>> struct A {
>>   A(T) {}
>> };
>>
>> void f() {
>>   T x;
>>   A y = {x};
>> }
>>
>> in r224592 we used to get with -ast-print for last function:
>>
>> void f() {
>>     T x;
>>     A y = { x };
>> }
>>
>> in r227424 we get:
>>
>>
>> void f() {
>>     T x;
>>     A y = { { { x } } };
>> }
>>
>> The difference comes from different AST, r224592:
>>
>>     `-DeclStmt 0x72db9a8 <line:10:3, col:12>
>>       `-VarDecl 0x72db1d0 <col:3, col:11> col:5 y 'struct A' cinit
>>         `-CXXConstructExpr 0x72db970 <col:9, col:11> 'struct A' 'void (T)'
>>           `-CXXConstructExpr 0x72db818 <col:10> 'T':'class
>> std::initializer_list<_Bool>' 'void (const class
>> std::initializer_list<_Bool> &) noexcept'
>>             `-ImplicitCastExpr 0x72db640 <col:10> 'const class
>> std::initializer_list<_Bool>' lvalue <NoOp>
>>               `-DeclRefExpr 0x72db228 <col:10> 'T':'class
>> std::initializer_list<_Bool>' lvalue Var 0x72dacb0 'x' 'T':'class
>> std::initializer_list<_Bool>'
>>
>>
>> while r227424:
>>
>>     `-DeclStmt 0x8c99f08 <line:10:3, col:12>
>>       `-VarDecl 0x8c996e0 <col:3, col:11> col:5 y 'struct A' cinit
>>         `-CXXConstructExpr 0x8c99ed0 <col:9, col:11> 'struct A' 'void (T)'
>>           `-CXXConstructExpr 0x8c99d78 <col:9, col:11> 'T':'class
>> std::initializer_list<_Bool>' 'void (const class
>> std::initializer_list<_Bool> &) noexcept'
>>             `-InitListExpr 0x8c99b68 <col:9, col:11> 'const class
>> std::initializer_list<_Bool>' lvalue
>>               `-ImplicitCastExpr 0x8c99b50 <col:10> 'const class
>> std::initializer_list<_Bool>' lvalue <NoOp>
>>                 `-DeclRefExpr 0x8c99738 <col:10> 'T':'class
>> std::initializer_list<_Bool>' lvalue Var 0x8c991c0 'x' 'T':'class
>> std::initializer_list<_Bool>'
>>
>>
>> What I can see is:
>> 1) a NoOp ImplicitCastExpr apparently needless in both
>>
>
> It's not needless, it's adding a 'const' qualifier to the lvalue.
>
>
>> 2) an extra InitListExpr in r227424
>
>
> This is weird and looks wrong, but it's unlikely to be related to r227377.
> Possibly caused by the changes for DR1467?
>

DR1467 is not completely backward compatible. For example, it breaks PR12117
and there is an issue filed on this with the standard.
I'm looking into temporary workarounds.
This sample case does look weird, and I can take a look at it as soon as my
schedule allows it, perhaps tonight or later in the week.
In the meantime, I have filed a bug on this, PR22465
<http://llvm.org/bugs/show_bug.cgi?id=22465>. Sounds good?

-- Larisse.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150204/b6be602a/attachment.html>


More information about the cfe-commits mailing list