[clang] [clang][Sema] Handle function parameter packs in `getDepthAndIndex(UnexpandedParameterPack)` (PR #215235)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 11 03:32:06 PDT 2026
================
@@ -77,11 +77,13 @@ inline std::optional<std::pair<unsigned, unsigned>>
getDepthAndIndex(UnexpandedParameterPack UPP) {
if (const auto *TTP = dyn_cast<const TemplateTypeParmType *>(UPP.first))
return std::make_pair(TTP->getDepth(), TTP->getIndex());
- if (isa<NamedDecl *>(UPP.first))
- return getDepthAndIndex(cast<NamedDecl *>(UPP.first));
- assert((isa<const TemplateSpecializationType *,
- const SubstBuiltinTemplatePackType *>(UPP.first)));
- return std::nullopt;
+ if (isa<const TemplateSpecializationType *,
+ const SubstBuiltinTemplatePackType *>(UPP.first))
+ return std::nullopt;
+ const auto *ND = cast<NamedDecl *>(UPP.first);
+ if (isa<ParmVarDecl>(ND))
+ return std::nullopt;
----------------
zyn0217 wrote:
I'm asking why a function named getDepthAndIndex should simply fail for a particular kind of parameter it's accepting, especially given the fact that there are also users out of template deduction.
If this is specific to template deduction, can you move the check into addPacks?
https://github.com/llvm/llvm-project/pull/215235
More information about the cfe-commits
mailing list