diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-02-21 02:22:07 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-02-21 02:22:07 +0000 |
commit | 552e29985a710f4ced62b39d70557501bd31ca9b (patch) | |
tree | 40f70512749090c477d5be59542b3306f320b2aa /lib/Sema/SemaLambda.cpp | |
parent | c9e0f925bfadfce815143aa82980376d73b1ea77 (diff) |
Implement name mangling for lambda expressions that occur within the
initializers of data members (both static and non-static).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151017 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaLambda.cpp')
-rw-r--r-- | lib/Sema/SemaLambda.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/Sema/SemaLambda.cpp b/lib/Sema/SemaLambda.cpp index 047a28436f..7b729e7018 100644 --- a/lib/Sema/SemaLambda.cpp +++ b/lib/Sema/SemaLambda.cpp @@ -641,20 +641,28 @@ ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body, if (!ManglingNumber) { ContextDecl = ExprEvalContexts.back().LambdaContextDecl; - // FIXME: Data member initializers. enum ContextKind { Normal, - DefaultArgument + DefaultArgument, + DataMember } Kind = Normal; // Default arguments of member function parameters that appear in a class - // definition receive special treatment. Identify them. - if (ParmVarDecl *Param = dyn_cast_or_null<ParmVarDecl>(ContextDecl)) { - if (const DeclContext *LexicalDC - = Param->getDeclContext()->getLexicalParent()) - if (LexicalDC->isRecord()) - Kind = DefaultArgument; - } + // definition, as well as the initializers of data members, receive special + // treatment. Identify them. + if (ContextDecl) { + if (ParmVarDecl *Param = dyn_cast<ParmVarDecl>(ContextDecl)) { + if (const DeclContext *LexicalDC + = Param->getDeclContext()->getLexicalParent()) + if (LexicalDC->isRecord()) + Kind = DefaultArgument; + } else if (VarDecl *Var = dyn_cast<VarDecl>(ContextDecl)) { + if (Var->getDeclContext()->isRecord()) + Kind = DataMember; + } else if (isa<FieldDecl>(ContextDecl)) { + Kind = DataMember; + } + } switch (Kind) { case Normal: @@ -663,6 +671,7 @@ ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body, break; case DefaultArgument: + case DataMember: ManglingNumber = ExprEvalContexts.back().getLambdaMangleContext() .getManglingNumber(CallOperator); break; |