diff options
author | Faisal Vali <faisalv@yahoo.com> | 2017-01-09 03:02:53 +0000 |
---|---|---|
committer | Faisal Vali <faisalv@yahoo.com> | 2017-01-09 03:02:53 +0000 |
commit | c72a08c1f6f42d1999ca481aba75cd9a2ae2fc53 (patch) | |
tree | eed393d95cf11792d9acc99782734a8a1a3fe181 /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | 6393afce978a30737e170150b7c34de4986cd2a8 (diff) | |
download | bcm5719-llvm-c72a08c1f6f42d1999ca481aba75cd9a2ae2fc53.tar.gz bcm5719-llvm-c72a08c1f6f42d1999ca481aba75cd9a2ae2fc53.zip |
[cxx1z-constexpr-lambda] Implement constant evaluation of non-capturing lambda expressions.
Add a visitor for lambda expressions to RecordExprEvaluator in ExprConstant.cpp that creates an empty APValue of Struct type to represent the closure object. Additionally, add a LambdaExpr visitor to the TemporaryExprEvaluator that forwards constant evaluation of immediately-called-lambda-expressions to the one in RecordExprEvaluator through VisitConstructExpr.
This patch supports:
constexpr auto ID = [] (auto a) { return a; };
static_assert(ID(3.14) == 3.14);
static_assert([](auto a) { return a + 1; }(10) == 11);
Lambda captures are still not supported for constexpr lambdas.
llvm-svn: 291416
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
0 files changed, 0 insertions, 0 deletions