Skip to content
Unverified Commit 29b5f8f9 authored by Younan Zhang's avatar Younan Zhang Committed by GitHub
Browse files

[Clang][Sema] Extract ellipsis location from CXXFoldExpr for reattaching...

[Clang][Sema] Extract ellipsis location from CXXFoldExpr for reattaching constraints on NTTPs (#78080)

We build up a `CXXFoldExpr` for immediately declared constraints as per
C++20 [temp.param]/4. This is done by
`formImmediatelyDeclaredConstraint` where an `EllipsisLoc` is essential
to determine whether this is a pack.

On the other hand, when attempting to instantiate a class template,
member templates might not be instantiated immediately, so we leave them
intact. For function templates with NTTPs, we reattach constraints if
possible so that they can be evaluated later. To properly form that, we
attempted to extract an ellipsis location if the param per se was a
parameter pack. Unfortunately, for the following NTTP case, we seemingly
failed to handle:

```cpp
template <Constraint auto... Pack>
void member();
```

The NTTPD Pack is neither an `ExpandedParameterPack` nor a
`PackExpansion` (its type does not expand anything). As a result, we end
up losing track of the constraints on packs, although we have them
inside the associated `CXXFoldExpr`.

This patch fixes that by extracting the ellipsis location out of the
previous constraint expression. Closes
https://github.com/llvm/llvm-project/issues/63837.
parent a4cd99ea
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment