royjacobson updated this revision to Diff 412229. royjacobson edited the summary of this revision. royjacobson set the repository for this revision to rG LLVM Github Monorepo. royjacobson added a comment. Herald added projects: clang, All.
Updated test so it checks actual instantiation and update the description. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D120255/new/ https://reviews.llvm.org/D120255 Files: clang/lib/Sema/SemaTemplateInstantiate.cpp clang/test/SemaTemplate/constraints-instantiation.cpp Index: clang/test/SemaTemplate/constraints-instantiation.cpp =================================================================== --- /dev/null +++ clang/test/SemaTemplate/constraints-instantiation.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -S -std=c++20 -emit-llvm %s -o - | FileCheck %s + +// void PR46029::A<1>::f() +// CHECK: define {{.*}} @_ZN7PR460291AILi1EE1fEv +// void PR46029::A<2>::f() +// CHECK: define {{.*}} @_ZN7PR460291AILi2EE1fEv +// void PR46029::A<3>::f() +// CHECK-NOT: define {{.*}} @_ZN7PR460291AILi3EE1fEv + +namespace PR46029 { +template <int N> +struct A { + void f() requires(N == 1) { + static_assert(N == 1); + } + void f() requires(N == 2) { + static_assert(N == 2); + } +}; + +template struct A<1>; +template struct A<2>; +template struct A<3>; +} Index: clang/lib/Sema/SemaTemplateInstantiate.cpp =================================================================== --- clang/lib/Sema/SemaTemplateInstantiate.cpp +++ clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -3230,6 +3230,14 @@ if (FunctionDecl *Pattern = Function->getInstantiatedFromMemberFunction()) { + if (Function->getTrailingRequiresClause()) { + ConstraintSatisfaction Satisfaction; + if (CheckFunctionConstraints(Function, Satisfaction) || + !Satisfaction.IsSatisfied) { + continue; + } + } + if (Function->hasAttr<ExcludeFromExplicitInstantiationAttr>()) continue;
Index: clang/test/SemaTemplate/constraints-instantiation.cpp =================================================================== --- /dev/null +++ clang/test/SemaTemplate/constraints-instantiation.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -S -std=c++20 -emit-llvm %s -o - | FileCheck %s + +// void PR46029::A<1>::f() +// CHECK: define {{.*}} @_ZN7PR460291AILi1EE1fEv +// void PR46029::A<2>::f() +// CHECK: define {{.*}} @_ZN7PR460291AILi2EE1fEv +// void PR46029::A<3>::f() +// CHECK-NOT: define {{.*}} @_ZN7PR460291AILi3EE1fEv + +namespace PR46029 { +template <int N> +struct A { + void f() requires(N == 1) { + static_assert(N == 1); + } + void f() requires(N == 2) { + static_assert(N == 2); + } +}; + +template struct A<1>; +template struct A<2>; +template struct A<3>; +} Index: clang/lib/Sema/SemaTemplateInstantiate.cpp =================================================================== --- clang/lib/Sema/SemaTemplateInstantiate.cpp +++ clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -3230,6 +3230,14 @@ if (FunctionDecl *Pattern = Function->getInstantiatedFromMemberFunction()) { + if (Function->getTrailingRequiresClause()) { + ConstraintSatisfaction Satisfaction; + if (CheckFunctionConstraints(Function, Satisfaction) || + !Satisfaction.IsSatisfied) { + continue; + } + } + if (Function->hasAttr<ExcludeFromExplicitInstantiationAttr>()) continue;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits