[cfe-commits] r150166 - /cfe/trunk/lib/Sema/SemaLambda.cpp

Douglas Gregor dgregor at apple.com
Thu Feb 9 00:52:43 PST 2012


Author: dgregor
Date: Thu Feb  9 02:52:43 2012
New Revision: 150166

URL: http://llvm.org/viewvc/llvm-project?rev=150166&view=rev
Log:
Restore the appropriate lexical declaration context for a lambda's
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.

Modified:
    cfe/trunk/lib/Sema/SemaLambda.cpp

Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=150166&r1=150165&r2=150166&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Thu Feb  9 02:52:43 2012
@@ -351,7 +351,9 @@
     // 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)





More information about the cfe-commits mailing list