[all-commits] [llvm/llvm-project] 463a4f: [Clang][Concepts] Normalize SizeOfPackExpr's pack ...

Younan Zhang via All-commits all-commits at lists.llvm.org
Mon Sep 30 21:28:52 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 463a4f15044c04279583d6d0da73ae49f4c242ec
      https://github.com/llvm/llvm-project/commit/463a4f15044c04279583d6d0da73ae49f4c242ec
  Author: Younan Zhang <zyn7109 at gmail.com>
  Date:   2024-10-01 (Tue, 01 Oct 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/Sema/SemaConcept.cpp
    M clang/lib/Sema/SemaTemplateInstantiate.cpp
    M clang/test/SemaTemplate/concepts-out-of-line-def.cpp

  Log Message:
  -----------
  [Clang][Concepts] Normalize SizeOfPackExpr's pack declaration (#110238)

SizeOfPackExpr has a pointer to the referenced pack declaration, which
is left as-is during the transformation process.

The situation could be subtle when a friend class template declaration
comes into play. The declaration per se would be instantiated into its
parent declaration context, and consequently, the template parameter
list would have a depth adjustment; however, as we don't evaluate
constraints during instantiation, those constraints would still
reference the original template parameters, which is fine for constraint
evaluation because we have handled friend cases in the template argument
collection.

However, things are different when we want to profile the constraint
expression with dependent template arguments. The hash algorithm of
SizeOfPackExpr takes its pack declaration as a factor, which is the
original template parameter that might still have untransformed template
depths after the constraint normalization.

This patch transforms the pack declaration when normalizing constraint
expressions and pluses a fix in HandleFunctionTemplateDecl() where the
associated declaration is incorrect for nested specifiers.

Note that the fix in HandleFunctionTemplateDecl(), as well as the
handling logic for NestedNameSpecifier, would be removed once Krystian's
refactoring patch lands. But I still want to incorporate it in the patch
for the correction purpose, though it hasn't caused any problems so far
- I just tripped over that in getFullyPackExpandedSize() when I tried to
extract the transformed declarations from the TemplateArgument.

Fixes #93099

---------

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