]> granicus.if.org Git - clang/commitdiff
Restore the appropriate lexical declaration context for a lambda's
authorDouglas Gregor <dgregor@apple.com>
Thu, 9 Feb 2012 08:52:43 +0000 (08:52 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 9 Feb 2012 08:52:43 +0000 (08:52 +0000)
function call operator (to the lambda class). This allows us to IRgen
calls to simple (non-capturing) lambdas, e.g.,

  [](int i, int j) -> int { return i + j; }(1, 2)

Eli will be providing test cases as he brings up more IRgen.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150166 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaLambda.cpp

index d59018dedc923ca7d2d60c16452f919b2f53f931..6d8e6a1029a432a7a8369c03e468755a347adfd5 100644 (file)
@@ -351,7 +351,9 @@ ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc,
     // C++ [expr.prim.lambda]p7:
     //   The lambda-expression's compound-statement yields the
     //   function-body (8.4) of the function call operator [...].
-    ActOnFinishFunctionBody(LSI->CallOperator, Body, /*IsInstantation=*/false);
+    CXXMethodDecl *CallOperator = LSI->CallOperator;
+    ActOnFinishFunctionBody(CallOperator, Body, /*IsInstantation=*/false);
+    CallOperator->setLexicalDeclContext(Class);
   }
 
   if (LambdaExprNeedsCleanups)