Lines Matching refs:Lambda
10 // This file implements semantic analysis for C++ lambda expressions.
28 /// enclosing lambda (to the current lambda) that is 'capture-ready' for
29 /// the variable referenced in the current lambda (i.e. \p VarToCapture).
31 /// of the capture-ready lambda's LambdaScopeInfo.
33 /// Climbs down the stack of lambdas (deepest nested lambda - i.e. current
34 /// lambda - is on top) to determine the index of the nearest enclosing/outer
35 /// lambda that is ready to capture the \p VarToCapture being referenced in
36 /// the current lambda.
37 /// As we climb down the stack, we want the index of the first such lambda -
38 /// that is the lambda with the highest index that is 'capture-ready'.
40 /// A lambda 'L' is capture-ready for 'V' (var or this) if:
42 /// - and if the chain of lambdas between L and the lambda in which
43 /// V is potentially used (i.e. the lambda at the top of the scope info
47 /// Note that a lambda that is deemed 'capture-ready' still needs to be checked
53 /// LambdaScopeInfo inherits from). The current/deepest/innermost lambda
58 /// the index (into Sema's FunctionScopeInfo stack) of the innermost lambda
60 /// no lambda is capture-ready for \p VarToCapture.
72 "The function on the top of sema's function-info stack must be a lambda");
78 // Start with the current lambda at the top of the stack (highest index).
86 // IF we have climbed down to an intervening enclosing lambda that contains
90 // innermost nested lambda are dependent (otherwise we wouldn't have
91 // arrived here) - so we don't yet have a lambda that can capture the
97 // For an enclosing lambda to be capture ready for an entity, all
98 // intervening lambda's have to be able to capture that entity. If even
99 // one of the intervening lambda's is not capable of capturing the entity
100 // then no enclosing lambda can ever capture that entity.
104 // [](auto b) { #2 <-- an intervening lambda that can never capture 'x'
110 // If even a single dependent enclosing lambda lacks the capability
112 // non-dependent lambda that can capture this variable.
128 // If the enclosingDC is not dependent, then the immediately nested lambda
136 /// enclosing lambda (to the current lambda) that is 'capture-capable' for
137 /// the variable referenced in the current lambda (i.e. \p VarToCapture).
139 /// of the capture-capable lambda's LambdaScopeInfo.
142 /// the variable of interest, to identify the nearest enclosing lambda (to the
143 /// current lambda at the top of the stack) that can truly capture
145 /// a) 'capture-ready' - be the innermost lambda that is 'capture-ready':
147 /// each outer lambda step by step) checking if each enclosing
148 /// lambda can either implicitly or explicitly capture the variable.
149 /// Record the first such lambda that is enclosed in a non-dependent
150 /// context. If no such lambda currently exists return failure.
151 /// b) 'capture-capable' - make sure the 'capture-ready' lambda can truly
153 /// - check if all outer lambdas enclosing the 'capture-ready' lambda
156 /// 'this' by passing in the index of the Lambda identified in step 'a')
159 /// LambdaScopeInfo inherits from). The current/deepest/innermost lambda
166 /// the index (into Sema's FunctionScopeInfo stack) of the innermost lambda
168 /// no lambda is capture-capable for \p VarToCapture.
185 "The capture ready lambda for a potential capture can only be the "
186 "current lambda if it is a generic lambda");
196 // Check if the capture-ready lambda can truly capture the variable, by
197 // checking whether all enclosing lambdas of the capture-ready lambda allow
210 // Check if the capture-ready lambda can truly capture 'this' by checking
211 // whether all enclosing lambdas of the capture-ready lambda can capture
252 // Start constructing the lambda class.
363 // If a lambda appears in a dependent context or is a generic lambda (has
376 // C++11 [expr.prim.lambda]p5:
377 // The closure type for a lambda-expression has a public inline function
379 // the lambda-expression's parameter-declaration-clause and
446 LSI->Lambda = LambdaClass;
621 "lambda expressions use auto deduction in C++14 onwards");
624 // If a lambda-expression does not include a trailing-return-type,
756 // processed as one before we enter the declcontext of the lambda's
791 Context, LSI->Lambda, Var->getLocation(), Var->getLocation(),
796 LSI->Lambda->addDecl(Field);
807 // Determine if we're within a context where we know that the lambda will
813 // The lambda-expression's closure type might be dependent even if its
827 // C++11 [expr.prim.lambda]p4:
828 // If a lambda-expression does not include a lambda-declarator, it is as
829 // if the lambda-declarator were ().
834 // C++1y [expr.prim.lambda]:
835 // The lambda return type is 'auto', which is replaced by the
851 "lambda-declarator is a function");
854 // C++11 [expr.prim.lambda]p5:
856 // the lambda-expression's parameter-declaration-clause is not followed
862 assert(MethodTyInfo && "no type from lambda-declarator");
887 // Attributes on the lambda apply to the method.
893 // Build the lambda scope.
897 // C++11 [expr.prim.lambda]p9:
898 // A lambda-expression whose smallest enclosing scope is a block scope is a
899 // local lambda expression; any other lambda expression shall not have a
900 // capture-default or simple-capture in its lambda-introducer.
928 // C++11 [expr.prim.lambda]p8:
930 // lambda-capture.
939 // C++1z [expr.prim.lambda]p8:
940 // If a lambda-capture includes a capture-default that is =, each
941 // simple-capture of that lambda-capture shall be of the form "&
951 // C++11 [expr.prim.lambda]p12:
952 // If this is captured by a local lambda expression, its nearest
1003 // C++1y [expr.prim.lambda]p11:
1006 // lambda-expression's compound-statement
1013 // C++11 [expr.prim.lambda]p8:
1014 // If a lambda-capture includes a capture-default that is &, the
1015 // identifiers in the lambda-capture shall not be preceded by &.
1016 // If a lambda-capture includes a capture-default that is =, [...]
1030 // C++11 [expr.prim.lambda]p10:
1051 // C++11 [expr.prim.lambda]p8:
1053 // lambda-capture.
1067 // C++11 [expr.prim.lambda]p10:
1069 // duration declared in the reaching scope of the local lambda expression.
1086 // C++11 [expr.prim.lambda]p23:
1114 // Add lambda parameters into scope.
1117 // Enter a new evaluation context to insulate the lambda from any
1130 // Leave the context of the lambda.
1134 // Finalize the lambda.
1135 CXXRecordDecl *Class = LSI->Lambda;
1145 /// \brief Add a lambda's conversion to function pointer, as described in
1146 /// C++11 [expr.prim.lambda]p6.
1151 // This conversion is explicitly disabled if the lambda's function has
1171 "Lambda's call operator should not have a reference qualifier");
1328 /// \brief Add a lambda's conversion to block pointer.
1383 // C++11 [expr.prim.lambda]p21:
1384 // When the lambda-expression is evaluated, the entities that
1392 // C++ [expr.prim.lambda]p12:
1393 // An entity captured by a lambda-expression is odr-used (3.2) in
1394 // the scope containing the lambda-expression.
1484 llvm_unreachable("block capture in lambda");
1491 // Collect information from the lambda scope.
1508 Class = LSI->Lambda;
1567 // C++11 [expr.prim.lambda]p6:
1568 // The closure type for a lambda-expression with no lambda-capture
1577 // The closure type for a lambda-expression has a public non-virtual
1581 // FIXME: Fix generic lambda to block conversions.
1586 // Finalize the lambda class.
1595 LambdaExpr *Lambda = LambdaExpr::Create(Context, Class, IntroducerRange,
1602 // If the lambda expression's call operator is not explicitly marked constexpr
1616 // C++11 [expr.prim.lambda]p2:
1617 // A lambda-expression shall not appear in an unevaluated operand
1624 // evaluate [...] a lambda-expression.
1629 // allow a lambda-expression.
1634 ExprEvalContexts.back().Lambdas.push_back(Lambda);
1644 return MaybeBindToTemporary(Lambda);
1651 // Make sure that the lambda call operator is marked used.
1652 CXXRecordDecl *Lambda = Conv->getParent();
1655 Lambda->lookup(
1698 // the lambda object.