]> granicus.if.org Git - clang/commit
[cxx1z-constexpr-lambda] Implement captures - thus completing implementation of const...
authorFaisal Vali <faisalv@yahoo.com>
Thu, 16 Feb 2017 04:12:21 +0000 (04:12 +0000)
committerFaisal Vali <faisalv@yahoo.com>
Thu, 16 Feb 2017 04:12:21 +0000 (04:12 +0000)
commit65db7256b937148d79df25dbdc1d328beb16dcc5
tree7659f393ed37be398a56dae32583ec195d287338
parentb5e3458bd2a56765b32efb4652bb535eedcf19a6
[cxx1z-constexpr-lambda] Implement captures - thus completing implementation of constexpr lambdas.

Enable evaluation of captures within constexpr lambdas by using a strategy similar to that used in CodeGen:
  - when starting evaluation of a lambda's call operator, create a map from VarDecl's to a closure's FieldDecls
  - every time a VarDecl (or '*this) that represents a capture is encountered while evaluating the expression via the expression evaluator (specifically the LValueEvaluator) in ExprConstant.cpp - it is replaced by the corresponding FieldDecl LValue (an Lvalue-to-Rvalue conversion on this LValue representation then determines the right rvalue when needed).

Thanks to Richard Smith and Hubert Tong for their review and feedback!

https://reviews.llvm.org/D29748

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@295279 91177308-0d34-0410-b5e6-96231b3b80d8
lib/AST/ExprConstant.cpp
test/SemaCXX/cxx1z-constexpr-lambdas.cpp