HomePhabricator

[SemaCXX] Handle lack of TypeSourceInfo on special member functions in…

Authored by bruno on Jun 22 2021, 3:14 PM.

Description

[SemaCXX] Handle lack of TypeSourceInfo on special member functions in templated lambdas

During template instantiation involving templated lambdas, clang
could hit an assertion in TemplateDeclInstantiator::SubstFunctionType
since the functions are not associated with any TypeSourceInfo:

assert(OldTInfo && "substituting function without type source info");

This path is triggered when using templated lambdas like the one added as
a test to this patch. To fix this:

  • Create TypeSourceInfos for special members and make sure the template

instantiator can get through all patterns.

  • Introduce a SpecialMemberTypeInfoRebuilder tree transform to rewrite

such member function arguments. Without this, we get errors like:

error: only special member functions and comparison operators may be defaulted

since getDefaultedFunctionKind can't properly recognize these functions
as special members as part of SetDeclDefaulted.

Fixes PR45828 and PR44848

Differential Revision: https://reviews.llvm.org/D88327