llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: None (llvmbot) <details> <summary>Changes</summary> Backport 13138b3cb90cda070e47d24f5f73f47dc2ad9c4a Requested by: @<!-- -->zyn0217 --- Full diff: https://github.com/llvm/llvm-project/pull/187226.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaConcept.cpp (+9-1) - (modified) clang/test/SemaTemplate/concepts.cpp (+19) ``````````diff diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index f55f3a9a61ab8..e17332ac90980 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -2544,7 +2544,15 @@ bool Sema::IsAtLeastAsConstrained(const NamedDecl *D1, } SubsumptionChecker SC(*this); - std::optional<bool> Subsumes = SC.Subsumes(D1, AC1, D2, AC2); + // Associated declarations are used as a cache key in the event they were + // normalized earlier during concept checking. However we cannot reuse these + // cached results if any of the template depths have been adjusted. + const NamedDecl *DeclAC1 = D1, *DeclAC2 = D2; + if (Depth2 > Depth1) + DeclAC1 = nullptr; + else if (Depth1 > Depth2) + DeclAC2 = nullptr; + std::optional<bool> Subsumes = SC.Subsumes(DeclAC1, AC1, DeclAC2, AC2); if (!Subsumes) { // Normalization failed return true; diff --git a/clang/test/SemaTemplate/concepts.cpp b/clang/test/SemaTemplate/concepts.cpp index d93391baf9926..da6e29003f7f0 100644 --- a/clang/test/SemaTemplate/concepts.cpp +++ b/clang/test/SemaTemplate/concepts.cpp @@ -1659,6 +1659,25 @@ void foo() { call(""); } } +namespace GH186624 { + +template <class T> +concept C = __is_unsigned(T); + +template <C T> +struct encoder_interface {}; + +template <template <C> class CodecInterface, C T> +CodecInterface<T>* create_codec() { + return nullptr; +} + +encoder_interface<unsigned>* create_encoder() { + return create_codec<encoder_interface, unsigned>(); +} + +} + namespace GH170856 { template <unsigned N, unsigned M> struct symbol_text { `````````` </details> https://github.com/llvm/llvm-project/pull/187226 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
