[clang] [Clang] Fix ICE in constraint normalization when substituting concept template parameters (PR #184406)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 4 08:28:59 PST 2026
================
@@ -4481,11 +4481,39 @@ ExprResult Sema::SubstConceptTemplateArguments(
ExprResult TransformUnresolvedLookupExpr(UnresolvedLookupExpr *E,
bool IsAddressOfOperand = false) {
- if (E->isConceptReference()) {
- ExprResult Res = SemaRef.SubstExpr(E, MLTAL);
- return Res;
- }
- return E;
+ if (!E->isConceptReference())
+ return E;
+
+ NamedDecl *D = *E->decls_begin();
+ ConceptDecl *ResolvedConcept = nullptr;
+
+ if (const auto * const TTP = dyn_cast<TemplateTemplateParmDecl>(D)) {
+ const auto Depth = TTP->getDepth();
+ const auto Pos = TTP->getPosition();
+ if (Depth < MLTAL.getNumLevels() &&
+ MLTAL.hasTemplateArgument(Depth, Pos)) {
+ TemplateArgument Arg = MLTAL(Depth, Pos);
+ if (Arg.getKind() == TemplateArgument::Template)
+ ResolvedConcept = dyn_cast_or_null<ConceptDecl>(
+ Arg.getAsTemplate().getAsTemplateDecl());
+ }
+ } else
+ ResolvedConcept = dyn_cast<ConceptDecl>(D);
+
+ if (ResolvedConcept == nullptr)
----------------
wx257osn2 wrote:
no, `dyn_cast_or_null<ConceptDecl>(Arg.getAsTemplate().getAsTemplateDecl())` can be null. however it doesn't on `else` branch, so moved it into the `if` branch
https://github.com/llvm/llvm-project/pull/184406
More information about the cfe-commits
mailing list