[Concepts] Fix Concepts on generic lambda in a VarTemplateSpecDecl
authorErich Keane <erich.keane@intel.com>
Tue, 27 Sep 2022 13:35:27 +0000 (06:35 -0700)
committerErich Keane <erich.keane@intel.com>
Mon, 3 Oct 2022 19:44:21 +0000 (12:44 -0700)
commit939a3d22e21f80246fc6a417da7193c0b93a7a44
tree320a43a20c48fdaa5fbe9adb0d0036af2567a02d
parent791935037b0b3b211bee54fae694aeb5b7b75125
[Concepts] Fix Concepts on generic lambda in a VarTemplateSpecDecl

As fallout of the Deferred Concept Instantiation patch (babdef27c5), we
got a number of reports of a regression, where we asserted when
instantiating a constraint on a generic lambda inside of a variable
template. See: https://github.com/llvm/llvm-project/issues/57958

The problem was that getTemplateInstantiationArgs function only walked
up declaration contexts, and missed that this is not necessarily the
case with a lambda (which can ALSO be in a separate context).

This patch refactors the getTemplateInstantiationArgs function in a way
that is hopefully more readable, and fixes the problem with the concepts
on a generic lambda.

Differential Revision: https://reviews.llvm.org/D134874
clang/include/clang/AST/DeclBase.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/DeclBase.cpp
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/SemaTemplate/concepts-lambda.cpp