aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/Analysis.cpp
diff options
context:
space:
mode:
authorKrystian Stasiowski <sdkrystian@gmail.com>2024-05-07 21:41:33 -0400
committerGitHub <noreply@github.com>2024-05-07 21:41:33 -0400
commit34ae2265e88c8a04350de5a244d0d888e74a8388 (patch)
treece210841290cde80dd71aa91ceee3ec4e0766df3 /llvm/lib/CodeGen/Analysis.cpp
parent83f3b1cb480b41e3347035aff14fd4bc2ba21d24 (diff)
downloadllvm-34ae2265e88c8a04350de5a244d0d888e74a8388.zip
llvm-34ae2265e88c8a04350de5a244d0d888e74a8388.tar.gz
llvm-34ae2265e88c8a04350de5a244d0d888e74a8388.tar.bz2
[Clang][Sema] Improve support for explicit specializations of constrained member functions & member function templates (#88963)
Consider the following snippet from the discussion of CWG2847 on the core reflector: ``` template<typename T> concept C = sizeof(T) <= sizeof(long); template<typename T> struct A { template<typename U> void f(U) requires C<U>; // #1, declares a function template void g() requires C<T>; // #2, declares a function template<> void f(char); // #3, an explicit specialization of a function template that declares a function }; template<> template<typename U> void A<short>::f(U) requires C<U>; // #4, an explicit specialization of a function template that declares a function template template<> template<> void A<int>::f(int); // #5, an explicit specialization of a function template that declares a function template<> void A<long>::g(); // #6, an explicit specialization of a function that declares a function ``` A number of problems exist: - Clang rejects `#4` because the trailing _requires-clause_ has `U` substituted with the wrong template parameter depth when `Sema::AreConstraintExpressionsEqual` is called to determine whether it matches the trailing _requires-clause_ of the implicitly instantiated function template. - Clang rejects `#5` because the function template specialization instantiated from `A<int>::f` has a trailing _requires-clause_, but `#5` does not (nor can it have one as it isn't a templated function). - Clang rejects `#6` for the same reasons it rejects `#5`. This patch resolves these issues by making the following changes: - To fix `#4`, `Sema::AreConstraintExpressionsEqual` is passed `FunctionTemplateDecl`s when comparing the trailing _requires-clauses_ of `#4` and the function template instantiated from `#1`. - To fix `#5` and `#6`, the trailing _requires-clauses_ are not compared for explicit specializations that declare functions. In addition to these changes, `CheckMemberSpecialization` now considers constraint satisfaction/constraint partial ordering when determining which member function is specialized by an explicit specialization of a member function for an implicit instantiation of a class template (we previously would select the first function that has the same type as the explicit specialization). With constraints taken under consideration, we match EDG's behavior for these declarations.
Diffstat (limited to 'llvm/lib/CodeGen/Analysis.cpp')
0 files changed, 0 insertions, 0 deletions