HomePhabricator

[Cxx1z-constexpr-lambda-P0170R1] Support parsing of constexpr specifier (and…

Authored by faisalv on Mar 26 2016, 9:11 AM.

Description

[Cxx1z-constexpr-lambda-P0170R1] Support parsing of constexpr specifier (and its inference) on lambda expressions

Support the constexpr specifier on lambda expressions - and support its inference from the lambda call operator's body.

i.e.

auto L = [] () constexpr { return 5; };
static_assert(L() == 5); // OK
auto Implicit = [] (auto a) { return a; };
static_assert(Implicit(5) == 5);

We do not support evaluation of lambda's within constant expressions just yet.

Implementation Strategy:

  • teach ParseLambdaExpressionAfterIntroducer to expect a constexpr specifier and mark the invented function call operator's declarator's decl-specifier with it; Have it emit fixits for multiple decl-specifiers (mutable or constexpr) in this location.
  • for cases where constexpr is not explicitly specified, have buildLambdaExpr check whether the invented function call operator satisfies the requirements of a constexpr function, by calling CheckConstexprFunctionDecl/Body.

Much obliged to Richard Smith for his patience and his care, in ensuring the code is clang-worthy.

llvm-svn: 264513

Details

Committed
faisalvMar 26 2016, 9:11 AM
Parents
rGe4dbeb40c6a0: [X86][AVX] Enabled MULHS/MULHU v16i16 vectors on AVX1 targets
Branches
Unknown
Tags
Unknown