[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 00:00:57 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:

It's still unclear to me why it's OK to do nothing here. A ParmVarDecl could refer to a template parameter pack, no?

https://github.com/llvm/llvm-project/pull/215235


More information about the cfe-commits mailing list