[clang] Reland: [clang] Track function template instantiation from definition (PR #125266)

via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 1 21:40:28 PST 2025


================
@@ -2298,6 +2298,13 @@ class FunctionDecl : public DeclaratorDecl,
     FunctionDeclBits.IsLateTemplateParsed = ILT;
   }
 
+  bool isInstantiatedFromMemberTemplate() const {
+    return FunctionDeclBits.IsInstantiatedFromMemberTemplate;
+  }
+  void setInstantiatedFromMemberTemplate(bool Val = true) {
+    FunctionDeclBits.IsInstantiatedFromMemberTemplate = Val;
+  }
+
----------------
cor3ntin wrote:

`ASTReader / Writer.`, sure.
However, I don't understand where `IsInstantiatedFromMemberTemplate` is initially set
(and i don't understand why we would need it - we already store that information on the `FunctionTemplateDecl` - which is what you have in your changes to `InstantiateFunctionDefinition`.

Go through the different calls to `setInstantiatedFromMemberTemplate` and see that this is _only_ used in ASTreader, and the new `FunctionTemplateDecl::setInstantiatedFromMemberTemplate` is not used - unless I am blind, which is always a possibility at 7am :) 

Note that `RedeclarableTemplateDecl::setInstantiatedFromMemberTemplate` is already called everywhere it needs to (hopefully)  and `isCompatibleWithDefinition()` can just be   `return `isInstantiatedFromMemberTemplate() || isThisDeclarationADefinition();` - unless I am missing something, but in that case the PR needs more explanation.

>From a FunctionFecl, `FunctionDecl::getInstantiatedFromDecl/FunctionDecl::getInstantiatedFromMemberFunction` _should_ also have the information

@erichkeane @AaronBallman 

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


More information about the cfe-commits mailing list