Skip to content
  • Faisal Vali's avatar
    [cxx1z-constexpr-lambda] Implement constant evaluation of non-capturing lambda expressions. · 25f75c48
    Faisal Vali authored
    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.
    
    
    
    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291416 91177308-0d34-0410-b5e6-96231b3b80d8
    25f75c48