[all-commits] [llvm/llvm-project] cdd71d: [Clang][Sema] Refactor collection of multi-level t...

Krystian Stasiowski via All-commits all-commits at lists.llvm.org
Fri Sep 20 11:58:02 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cdd71d61664b63ae57bdba9ee0d891f78ef79c07
      https://github.com/llvm/llvm-project/commit/cdd71d61664b63ae57bdba9ee0d891f78ef79c07
  Author: Krystian Stasiowski <sdkrystian at gmail.com>
  Date:   2024-09-20 (Fri, 20 Sep 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/AST/DeclTemplate.h
    M clang/include/clang/Sema/Sema.h
    M clang/lib/AST/DeclTemplate.cpp
    M clang/lib/Sema/SemaConcept.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaDeclCXX.cpp
    M clang/lib/Sema/SemaTemplate.cpp
    M clang/lib/Sema/SemaTemplateDeduction.cpp
    M clang/lib/Sema/SemaTemplateDeductionGuide.cpp
    M clang/lib/Sema/SemaTemplateInstantiate.cpp
    M clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
    M clang/lib/Serialization/ASTReader.cpp
    M clang/lib/Serialization/ASTReaderDecl.cpp
    M clang/lib/Serialization/ASTWriterDecl.cpp
    A clang/test/CXX/temp/temp.constr/temp.constr.decl/p4.cpp

  Log Message:
  -----------
  [Clang][Sema] Refactor collection of multi-level template argument lists (#106585)

Currently, clang rejects the following explicit specialization of `f`
due to the constraints not being equivalent:
```
template<typename T>
struct A
{
    template<bool B>
    void f() requires B;
};

template<>
template<bool B>
void A<int>::f() requires B { }
```
This happens because, in most cases, we do not set the flag indicating
whether a `RedeclarableTemplate` is an explicit specialization of a
member of an implicitly instantiated class template specialization until
_after_ we compare constraints for equivalence. This patch addresses the
issue (and a number of other issues) by:
- storing the flag indicating whether a declaration is a member
specialization on a per declaration basis, and
- significantly refactoring `Sema::getTemplateInstantiationArgs` so we
collect the right set of template argument in all cases.

Many of our declaration matching & constraint evaluation woes can be
traced back to bugs in `Sema::getTemplateInstantiationArgs`. This
change/refactor should fix a lot of them. It also paves the way for
fixing #101330 and #105462 per my suggestion in #102267 (which I have
implemented on top of this patch but will merge in a subsequent PR).



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list