|
@@ -148,6 +148,11 @@ public:
|
|
|
/// statement node appears at most once in its containing declaration.
|
|
|
bool AlwaysRebuild() { return SemaRef.ArgumentPackSubstitutionIndex != -1; }
|
|
|
|
|
|
+ /// Whether the transformation is forming an expression or statement that
|
|
|
+ /// replaces the original. In this case, we'll reuse mangling numbers from
|
|
|
+ /// existing lambdas.
|
|
|
+ bool ReplacingOriginal() { return false; }
|
|
|
+
|
|
|
/// Returns the location of the entity being transformed, if that
|
|
|
/// information was not available elsewhere in the AST.
|
|
|
///
|
|
@@ -654,6 +659,9 @@ public:
|
|
|
Optional<unsigned> NumExpansions,
|
|
|
bool ExpectParameterPack);
|
|
|
|
|
|
+ /// Transform the body of a lambda-expression.
|
|
|
+ StmtResult TransformLambdaBody(Stmt *Body);
|
|
|
+
|
|
|
QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL);
|
|
|
|
|
|
StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr);
|
|
@@ -11197,8 +11205,6 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
|
|
|
|
|
|
auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
|
|
|
Optional<unsigned> NumExpansions) {
|
|
|
- EnterExpressionEvaluationContext EEEC(
|
|
|
- getSema(), Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
|
|
|
ExprResult NewExprInitResult = getDerived().TransformInitializer(
|
|
|
OldVD->getInit(), OldVD->getInitStyle() == VarDecl::CallInit);
|
|
|
|
|
@@ -11289,19 +11295,25 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
|
|
|
LSI->GLTemplateParameterList = TPL;
|
|
|
|
|
|
// Create the local class that will describe the lambda.
|
|
|
+ CXXRecordDecl *OldClass = E->getLambdaClass();
|
|
|
CXXRecordDecl *Class
|
|
|
= getSema().createLambdaClosureType(E->getIntroducerRange(),
|
|
|
NewCallOpTSI,
|
|
|
/*KnownDependent=*/false,
|
|
|
E->getCaptureDefault());
|
|
|
- getDerived().transformedLocalDecl(E->getLambdaClass(), {Class});
|
|
|
+ getDerived().transformedLocalDecl(OldClass, {Class});
|
|
|
+
|
|
|
+ Optional<std::pair<unsigned, Decl*>> Mangling;
|
|
|
+ if (getDerived().ReplacingOriginal())
|
|
|
+ Mangling = std::make_pair(OldClass->getLambdaManglingNumber(),
|
|
|
+ OldClass->getLambdaContextDecl());
|
|
|
|
|
|
// Build the call operator.
|
|
|
CXXMethodDecl *NewCallOperator = getSema().startLambdaDefinition(
|
|
|
Class, E->getIntroducerRange(), NewCallOpTSI,
|
|
|
E->getCallOperator()->getEndLoc(),
|
|
|
NewCallOpTSI->getTypeLoc().castAs<FunctionProtoTypeLoc>().getParams(),
|
|
|
- E->getCallOperator()->isConstexpr());
|
|
|
+ E->getCallOperator()->isConstexpr(), Mangling);
|
|
|
|
|
|
LSI->CallOperator = NewCallOperator;
|
|
|
|
|
@@ -11465,7 +11477,7 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
|
|
|
|
|
|
// Instantiate the body of the lambda expression.
|
|
|
StmtResult Body =
|
|
|
- Invalid ? StmtError() : getDerived().TransformStmt(E->getBody());
|
|
|
+ Invalid ? StmtError() : getDerived().TransformLambdaBody(E->getBody());
|
|
|
|
|
|
// ActOnLambda* will pop the function scope for us.
|
|
|
FuncScopeCleanup.disable();
|
|
@@ -11489,6 +11501,12 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
|
|
|
&LSICopy);
|
|
|
}
|
|
|
|
|
|
+template<typename Derived>
|
|
|
+StmtResult
|
|
|
+TreeTransform<Derived>::TransformLambdaBody(Stmt *S) {
|
|
|
+ return TransformStmt(S);
|
|
|
+}
|
|
|
+
|
|
|
template<typename Derived>
|
|
|
ExprResult
|
|
|
TreeTransform<Derived>::TransformCXXUnresolvedConstructExpr(
|