================
@@ -4159,7 +4159,7 @@ FunctionTemplateDecl *FunctionDecl::getPrimaryTemplate()
const {
if (FunctionTemplateSpecializationInfo *Info
= TemplateOrSpecialization
.dyn_cast<FunctionTemplateSpecializationInfo*>()) {
- return Info->getTemplate();
+ return Info->getTemplate()->getMostRecentDecl();
----------------
sdkrystian wrote:
> Why do we need to get the most recent declaration in all these places?
@mizvekov One of the changes made by this patch is to set the
`isMemberSpecialization` flag on a per-declaration basis. This ensures that
`getTemplateInstantiationArgs` behaves correctly for implicitly instantiated
declarations that are explicitly specialized for an implicitly instantiated
specialization of their enclosing class template.
When we look up the name of a template, we typically find the most recent
declaration of that template. If that declaration is an explicit specialization
of a member template, we use the correct declaration when we try to find the
definition of that template. However, if the member template is explicitly
specialized _after_ we lookup its name, we end up with an expression naming the
implicitly instantiated in-class declaration of that template. If we call
`getTemplateInstantiationPattern` on that declaration, it will incorrectly
return the pattern from the primary template.
https://github.com/llvm/llvm-project/pull/111173
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits