[clang] [clang] Track function template instantiation from definition (PR #110387)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 5 19:41:20 PDT 2024
================
@@ -1994,8 +1995,10 @@ TemplateDeclInstantiator::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
// Link the instantiation back to the pattern *unless* this is a
// non-definition friend declaration.
if (!InstTemplate->getInstantiatedFromMemberTemplate() &&
- !(isFriend && !D->getTemplatedDecl()->isThisDeclarationADefinition()))
+ !(isFriend && !D->getTemplatedDecl()->isThisDeclarationADefinition())) {
+ InstTemplate->setInstantiatedFromDefinition();
----------------
zyn0217 wrote:
> That's true, but the only problematic cases are the friends.
I was thinking if we can move it to a separate if branch then, for example it might not be conditioned on `isFriend`
```cpp
if (D->getTemplatedDecl()->isThisDeclarationADefinition())
InstTemplate->setInstantiatedFromDefinition();
```
(I presume a new if won't impact anything other than friends, as you said the friends are the only problematic ones.)
https://github.com/llvm/llvm-project/pull/110387
More information about the cfe-commits
mailing list