aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaLambda.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-02-20 19:44:39 +0000
committerDouglas Gregor <dgregor@apple.com>2012-02-20 19:44:39 +0000
commit9e8c92a9c9b949bbb0408fbbd9a58e34894b6efc (patch)
tree9579005bf62f65f14d6478c74c2c36096d691398 /lib/Sema/SemaLambda.cpp
parent86211df4d28f6fb3c48ab09f02a011e8570d8b1c (diff)
Basic support for name mangling of C++11 lambda expressions. Because
name mangling in the Itanium C++ ABI for lambda expressions is so dependent on context, we encode the number used to encode each lambda as part of the lambda closure type, and maintain this value within Sema. Note that there are a several pieces still missing: - We still get the linkage of lambda expressions wrong - We aren't properly numbering or mangling lambda expressions that occur in default function arguments or in data member initializers. - We aren't (de-)serializing the lambda numbering tables git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150982 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaLambda.cpp')
-rw-r--r--lib/Sema/SemaLambda.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Sema/SemaLambda.cpp b/lib/Sema/SemaLambda.cpp
index 1a362d48e2..d1f87a2c18 100644
--- a/lib/Sema/SemaLambda.cpp
+++ b/lib/Sema/SemaLambda.cpp
@@ -483,7 +483,9 @@ static void addBlockPointerConversion(Sema &S,
}
ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body,
- Scope *CurScope, bool IsInstantiation) {
+ Scope *CurScope,
+ llvm::Optional<unsigned> ManglingNumber,
+ bool IsInstantiation) {
// Leave the expression-evaluation context.
DiscardCleanupsInEvaluationContext();
PopExpressionEvaluationContext();
@@ -633,11 +635,19 @@ ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body,
if (LambdaExprNeedsCleanups)
ExprNeedsCleanups = true;
+ // If we don't already have a mangling number for this lambda expression,
+ // allocate one now.
+ if (!ManglingNumber) {
+ // FIXME: Default arguments, data member initializers are special.
+ ManglingNumber = Context.getLambdaManglingNumber(CallOperator);
+ }
+
LambdaExpr *Lambda = LambdaExpr::Create(Context, Class, IntroducerRange,
CaptureDefault, Captures,
ExplicitParams, ExplicitResultType,
CaptureInits, ArrayIndexVars,
- ArrayIndexStarts, Body->getLocEnd());
+ ArrayIndexStarts, Body->getLocEnd(),
+ *ManglingNumber);
// C++11 [expr.prim.lambda]p2:
// A lambda-expression shall not appear in an unevaluated operand