]> granicus.if.org Git - clang/commit
Fix and simplify handling of return type for (generic) lambda conversion function...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 2 Jan 2018 23:52:42 +0000 (23:52 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 2 Jan 2018 23:52:42 +0000 (23:52 +0000)
commit78f3c1f12f22bb890addc680a9955297d5155aff
tree6da14fb19511730a6c130e2ea4c71b279baf3e60
parent606fddaecab7587d3470a6f118c852cfbc0d7912
Fix and simplify handling of return type for (generic) lambda conversion function to function pointer.

Previously, we would:
 * compute the type of the conversion function and static invoker as a
   side-effect of template argument deduction for a conversion
 * re-compute the type as part of deduced return type deduction when building
   the conversion function itself

Neither of these turns out to be quite correct. There are other ways to reach a
declaration of the conversion function than in a conversion (such as an
explicit call or friend declaration), and performing auto deduction causes the
function type to be rebuilt in the context of the lambda closure type (which is
different from the context in which it originally appeared, resulting in
spurious substitution failures for constructs that are valid in one context but
not the other, such as the use of an enclosing class's "this" pointer).

This patch switches us to use a different strategy: as before, we use the
declared type of the operator() to form the type of the conversion function and
invoker, but we now populate that type as part of return type deduction for the
conversion function. And the invoker is now treated as simply being an
implementation detail of building the conversion function, and isn't given
special treatment by template argument deduction for the conversion function
any more.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321683 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Sema/Sema.h
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaLambda.cpp
lib/Sema/SemaOverload.cpp
lib/Sema/SemaStmt.cpp
lib/Sema/SemaTemplateDeduction.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp
test/SemaCXX/cxx1y-generic-lambdas.cpp
test/SemaCXX/lambda-expressions.cpp