================
@@ -6901,8 +6901,20 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation 
Loc, NamedDecl *D,
   //    whose type is not instantiation dependent, do nothing to the decl
   //  - otherwise find its instantiated decl.
   if (isa<ParmVarDecl>(D) && !ParentDependsOnArgs &&
-      !cast<ParmVarDecl>(D)->getType()->isInstantiationDependentType())
-    return D;
+      !cast<ParmVarDecl>(D)->getType()->isInstantiationDependentType()) {
+    // Check if D belongs to a function template
+    auto *PVD = cast<ParmVarDecl>(D);
+    bool IsFromFunctionTemplate =
+        llvm::any_of(ParentDC->decls(), [PVD](Decl *D) {
+          if (auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
+            return llvm::is_contained(FTD->getTemplatedDecl()->parameters(),
+                                      PVD);
+          return false;
+        });
----------------
hekota wrote:

Could you please explain why is this needed?

If `D` is a` ParmVarDecl`, then its `ParentDC` should be a `FunctionDecl`, 
which has methods like `getDescribedFunctionTemplate()` or 
`getPrimaryTemplate()`. Could these be helpful here?

https://github.com/llvm/llvm-project/pull/176058
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to