Skip to content

Commit 4583b08

Browse files
author
git apple-llvm automerger
committed
Merge commit '3e512ba17d90' from llvm.org/release/19.x into stable/20240723
2 parents be81d6b + 3e512ba commit 4583b08

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

clang/lib/Sema/SemaConcept.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,8 +969,30 @@ static const Expr *SubstituteConstraintExpressionWithoutSatisfaction(
969969
// equivalence.
970970
LocalInstantiationScope ScopeForParameters(S);
971971
if (auto *FD = DeclInfo.getDecl()->getAsFunction())
972-
for (auto *PVD : FD->parameters())
973-
ScopeForParameters.InstantiatedLocal(PVD, PVD);
972+
for (auto *PVD : FD->parameters()) {
973+
if (!PVD->isParameterPack()) {
974+
ScopeForParameters.InstantiatedLocal(PVD, PVD);
975+
continue;
976+
}
977+
// This is hacky: we're mapping the parameter pack to a size-of-1 argument
978+
// to avoid building SubstTemplateTypeParmPackTypes for
979+
// PackExpansionTypes. The SubstTemplateTypeParmPackType node would
980+
// otherwise reference the AssociatedDecl of the template arguments, which
981+
// is, in this case, the template declaration.
982+
//
983+
// However, as we are in the process of comparing potential
984+
// re-declarations, the canonical declaration is the declaration itself at
985+
// this point. So if we didn't expand these packs, we would end up with an
986+
// incorrect profile difference because we will be profiling the
987+
// canonical types!
988+
//
989+
// FIXME: Improve the "no-transform" machinery in FindInstantiatedDecl so
990+
// that we can eliminate the Scope in the cases where the declarations are
991+
// not necessarily instantiated. It would also benefit the noexcept
992+
// specifier comparison.
993+
ScopeForParameters.MakeInstantiatedLocalArgPack(PVD);
994+
ScopeForParameters.InstantiatedLocalPackArg(PVD, PVD);
995+
}
974996

975997
std::optional<Sema::CXXThisScopeRAII> ThisScope;
976998

clang/test/SemaTemplate/concepts-out-of-line-def.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,3 +599,26 @@ template <class DerT>
599599
unsigned long DerivedCollection<DerTs...>::index() {}
600600

601601
} // namespace GH72557
602+
603+
namespace GH101735 {
604+
605+
template <class, class>
606+
concept True = true;
607+
608+
template <typename T>
609+
class A {
610+
template <typename... Ts>
611+
void method(Ts&... ts)
612+
requires requires (T t) {
613+
{ t.method(static_cast<Ts &&>(ts)...) } -> True<void>;
614+
};
615+
};
616+
617+
template <typename T>
618+
template <typename... Ts>
619+
void A<T>::method(Ts&... ts)
620+
requires requires (T t) {
621+
{ t.method(static_cast<Ts &&>(ts)...) } -> True<void>;
622+
} {}
623+
624+
}

0 commit comments

Comments
 (0)