[all-commits] [llvm/llvm-project] 85a94e: [Clang] Transform SubstNonTypeTemplateParmExpr rep...

I via All-commits all-commits at lists.llvm.org
Wed Jun 24 19:36:11 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 85a94e312513301805adb4c73c1e8a5581097a94
      https://github.com/llvm/llvm-project/commit/85a94e312513301805adb4c73c1e8a5581097a94
  Author: I <1091761+wx257osn2 at users.noreply.github.com>
  Date:   2026-06-25 (Thu, 25 Jun 2026)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/Sema/TreeTransform.h
    M clang/test/SemaTemplate/concepts.cpp

  Log Message:
  -----------
  [Clang] Transform SubstNonTypeTemplateParmExpr replacements in a constant-evaluated context (#196791)

Fixes #175831.

When transforming a `SubstNonTypeTemplateParmExpr`,
`TreeTransform::TransformSubstNonTypeTemplateParmExpr` calls
`Sema::CheckTemplateArgument` so that any sema annotations (such as
implicit casts) that were stripped from the replacement are recovered.
This is done in whatever evaluation context the node happens to appear
in after substitutions.

Since the normalization of constraints, a `SubstNonTypeTemplateParmExpr`
can end up inside an unevaluated operand, so the replacement gets
rebuilt in an unevaluated context.
Entities it refers to are then not odr-used: for example, when a call
materializes a by-value function parameter of class type, the copy
constructor is never marked odr-used and its definition is never
instantiated.
The constant evaluation performed by `CheckTemplateArgument` afterwards
then fails for otherwise valid arguments.
This caused rejects-valid regressions on real code such as mp-units.

This PR inserts a constant-evaluated context in
`TransformSubstNonTypeTemplateParmExpr`, so that the replacement is
rebuilt and re-checked on the context, regardless of where normalization
has placed it.

--

Co-authored-by: A. Jiang <de34 at live.cn>
Co-authored-by: Matheus Izvekov <mizvekov at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list