Move the computation of the lambda mangling information (mangling
number + context) to the point where we initially start defining the
lambda, so that the linkage won't change when that information is made
available. Fixes the assertion in <rdar://problem/11182962>.
Plus, actually mangle the context of lambdas properly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154029 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index c759e7a..f16b667 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -7815,7 +7815,8 @@
TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
// Create the local class that will describe the lambda.
CXXRecordDecl *Class
- = getSema().createLambdaClosureType(E->getIntroducerRange());
+ = getSema().createLambdaClosureType(E->getIntroducerRange(),
+ /*KnownDependent=*/false);
getDerived().transformedLocalDecl(E->getLambdaClass(), Class);
// Transform the type of the lambda parameters and start the definition of
@@ -7836,11 +7837,15 @@
Invalid = true;
// Build the call operator.
+ // Note: Once a lambda mangling number and context declaration have been
+ // assigned, they never change.
+ unsigned ManglingNumber = E->getLambdaClass()->getLambdaManglingNumber();
+ Decl *ContextDecl = E->getLambdaClass()->getLambdaContextDecl();
CXXMethodDecl *CallOperator
= getSema().startLambdaDefinition(Class, E->getIntroducerRange(),
MethodTy,
E->getCallOperator()->getLocEnd(),
- Params);
+ Params, ManglingNumber, ContextDecl);
getDerived().transformAttrs(E->getCallOperator(), CallOperator);
// FIXME: Instantiation-specific.
@@ -7953,14 +7958,8 @@
return ExprError();
}
- // Note: Once a lambda mangling number and context declaration have been
- // assigned, they never change.
- unsigned ManglingNumber = E->getLambdaClass()->getLambdaManglingNumber();
- Decl *ContextDecl = E->getLambdaClass()->getLambdaContextDecl();
return getSema().ActOnLambdaExpr(E->getLocStart(), Body.take(),
- /*CurScope=*/0, ManglingNumber,
- ContextDecl,
- /*IsInstantiation=*/true);
+ /*CurScope=*/0, /*IsInstantiation=*/true);
}
template<typename Derived>