[cfe-dev] Initializer lists and the AST

Richard Smith richard at metafoo.co.uk
Fri Feb 1 14:22:41 PST 2013


On Fri, Feb 1, 2013 at 11:42 AM, Vane, Edwin <edwin.vane at intel.com> wrote:
> For anybody else who cares about the answer, the trick in this case is that CXXConstructExpr has a member function isListInitialized(). The flag doesn't show up in the dump but the function returns what you'd expect.

Alternatively, you can use VarDecl::getInitStyle. It's VarDecl::CInit
for copy-initialization (including copy-list-initialization) and
VarDecl:::ListInit for direct-list-initialization.

> -----Original Message-----
> From: cfe-dev-bounces at cs.uiuc.edu [mailto:cfe-dev-bounces at cs.uiuc.edu] On Behalf Of Vane, Edwin
> Sent: Friday, February 01, 2013 11:42 AM
> To: Clang Dev List (cfe-dev at cs.uiuc.edu)
> Subject: [cfe-dev] Initializer lists and the AST
>
> I have two statements I'm looking at for replacing the type specifier with 'auto':
>
>   std::vector<int>::iterator begin2{blah.begin()};
>   std::vector<int>::iterator begin3 = {blah.begin()};
>
> The end result is that the first line should use auto and the second should not (auto will turn into std::initializer_list). However, when I dump the parts of the AST corresponding to the initializers, I get exactly the same thing. How can I differentiate these two cases? Should I be looking in the VarDecl for some clue?
>
> --
> Edwin Vane
>   Software Developer
>   Intel of Canada, Inc.
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list