Missing info in AST for CXXConstructExpr
Abramo Bagnara
abramo.bagnara at bugseng.com
Thu Jan 29 02:24:37 PST 2015
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
2) an extra InitListExpr in r227424
>
> On Wed, Jan 28, 2015 at 2:27 AM, Abramo Bagnara
> <abramo.bagnara at bugseng.com <mailto:abramo.bagnara at bugseng.com>> wrote:
>
> Il 27/01/2015 02:50, Richard Smith ha scritto:
>
> >
> > There should be a CXXFunctionalCastExpr (with cast kind CK_NoOp) between
> > the MaterializeTemporaryExpr and its contained CXXStdInitializerListExpr:
> >
> > `-CallExpr 0x7962cd0 <line:11:3, col:9> 'void'
> > |-ImplicitCastExpr 0x7962cb8 <col:3> 'void
> > (*)(class std::initializer_list<int>)' <FunctionToPointerDecay>
> > | `-DeclRefExpr 0x7962c60 <col:3> 'void
> > (class std::initializer_list<int>)' lvalue [...]
> > `-CXXConstructExpr 0x7962d18 <col:6, col:8> [...]
> > `-MaterializeTemporaryExpr 0x7962d00 <col:6, col:8>
> > 'class std::initializer_list<int>' xvalue
> > * `-CXXFunctionalCastExpr 0x... <NoOp>
> > * `-CXXStdInitializerListExpr 0x7962910 <col:6,
> > col:8> 'T':'class std::initializer_list<int>'
> > `-MaterializeTemporaryExpr 0x79628f8 <col:6, col:8>
> > 'const int [1]' xvalue
> > `-InitListExpr 0x79628b0 <col:6, col:8> 'const int [1]'
> > `-IntegerLiteral 0x7962848 <col:7> 'int' 0
> >
> > This case appears to be missing from Sema::BuildCXXTypeConstructExpr; it
> > looks like it assumes that initialization will give us either a
> > CXXConstructExpr or an InitListExpr.
>
> Filed as http://llvm.org/bugs/show_bug.cgi?id=22367 with reference to
> your proposed solution.
>
>
> --
> Abramo Bagnara
>
> BUGSENG srl - http://bugseng.com
> mailto:abramo.bagnara at bugseng.com <mailto:abramo.bagnara at bugseng.com>
>
>
--
Abramo Bagnara
BUGSENG srl - http://bugseng.com
mailto:abramo.bagnara at bugseng.com
More information about the cfe-commits
mailing list