[clang] [Clang] Fix another parameter mapping substitution bug (PR #162155)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 6 19:46:06 PDT 2025


================
@@ -277,7 +277,8 @@ class HashParameterMapping : public RecursiveASTVisitor<HashParameterMapping> {
   bool VisitTemplateTypeParmType(TemplateTypeParmType *T) {
     // A lambda expression can introduce template parameters that don't have
     // corresponding template arguments yet.
-    if (T->getDepth() >= TemplateArgs.getNumLevels())
+    if (T->getDepth() >= TemplateArgs.getNumLevels() ||
+        !TemplateArgs.hasTemplateArgument(T->getDepth(), T->getIndex()))
----------------
zyn0217 wrote:

Can we

```suggestion
    // There might not be a corresponding template argument before substituting into the parameter mapping, e.g. a lambda expression ... 
    if (!TemplateArgs.hasTemplateArgument(T->getDepth(), T->getIndex()))
```

?

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


More information about the cfe-commits mailing list