]> granicus.if.org Git - clang/commit
Rework the Sema/AST/IRgen dance for the lambda closure type's
authorDouglas Gregor <dgregor@apple.com>
Fri, 17 Feb 2012 03:02:34 +0000 (03:02 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 17 Feb 2012 03:02:34 +0000 (03:02 +0000)
commit27dd7d962bbf774988bc5e59d04a7743ed503514
treee26142ffbfa9e462cf1800ab500b902bd5437b22
parent92dc03546ccfd417108c1fc74321091a82cbeeee
Rework the Sema/AST/IRgen dance for the lambda closure type's
conversion to function pointer. Rather than having IRgen synthesize
the body of this function, we instead introduce a static member
function "__invoke" with the same signature as the lambda's
operator() in the AST. Sema then generates a body for the conversion
to function pointer which simply returns the address of __invoke. This
approach makes it easier to evaluate a call to the conversion function
as a constant, makes the linkage of the __invoke function follow the
normal rules for member functions, and may make life easier down the
road if we ever want to constexpr'ify some of lambdas.

Note that IR generation is responsible for filling in the body of
__invoke (Sema just adds a dummy body), because the body can't
generally be expressed in C++.

Eli, please review!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150783 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/AST/DeclCXX.h
lib/AST/DeclCXX.cpp
lib/CodeGen/CGClass.cpp
lib/CodeGen/CodeGenFunction.cpp
lib/CodeGen/CodeGenFunction.h
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaLambda.cpp
test/CodeGenCXX/lambda-expressions.cpp